misc: configurator: Re-assign VMID based on load order

Previously if user creates a shared scenario and adds a pre-launched VM,
the pre-launched VM will be assigned a VMID that's greater than service
VM, which will be blocked by scenario validation.

This patch re-assigns the VMID before saving as scenario XMLs based on
their load order. The UI-only VM name will have no impact on VMID that's
actually written to scenario XML.

Tracked-On: #7419
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
This commit is contained in:
Yifan Liu 2022-04-27 11:53:03 +08:00 committed by acrnsi-robot
parent ee3a527464
commit 35dc60192f

View File

@ -198,7 +198,20 @@ export default {
}
this.updateCurrentFormData()
},
assignVMID() {
let vm_priority = {
'PRE_LAUNCHED_VM': 0,
'SERVICE_VM': 1,
'POST_LAUNCHED_VM': 2
}
this.scenario.vm.sort((a, b) => {
return vm_priority[a['load_order']] - vm_priority[b['load_order']]
}).map((vmConfig, vmIndex) => {
vmConfig['@id'] = vmIndex
})
},
saveScenario(event) {
this.assignVMID()
let scenarioXMLData = configurator.convertScenarioToXML(
{
// simple deep copy