diff --git a/misc/config_tools/configurator/packages/configurator/src/lib/acrn.ts b/misc/config_tools/configurator/packages/configurator/src/lib/acrn.ts
index 14b06fa6f..cb5302eb1 100644
--- a/misc/config_tools/configurator/packages/configurator/src/lib/acrn.ts
+++ b/misc/config_tools/configurator/packages/configurator/src/lib/acrn.ts
@@ -651,6 +651,10 @@ class PythonObject {
generateConfigSummary(boardXMLText, scenarioXMLText) {
return this.api('generateConfigSummary', 'plaintext', boardXMLText, scenarioXMLText)
}
+
+ updateSchema(boardXMLText, scenarioXMLText) {
+ return this.api('updateSchema', 'plaintext', boardXMLText, scenarioXMLText)
+ }
}
class Configurator {
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue
index effd1fdfe..83caf1089 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config.vue
@@ -140,6 +140,8 @@ export default {
errors: [],
totalMsg: "",
showTotalMessageFlag: false,
+ isSaved:false,
+ isLoaded:false
}
},
computed: {
@@ -151,6 +153,18 @@ export default {
}
},
methods: {
+ updateSchema(i){
+ let current_selected_pcis=this.scenario.vm[i]['pci_devs']['pci_dev']
+ let total_pcis=this.schemas.PreLaunchedVM.BasicConfigType.definitions.PCIDevsConfiguration.properties.pci_dev.items
+ console.log('before:',total_pcis.enum.length)
+ let s=new Set(total_pcis.enum)
+ current_selected_pcis.map(e=>{
+ s.delete(e)
+ })
+ let to_updated=Array.from(s).sort()
+ total_pcis.enum=total_pcis.enumNames=to_updated
+ console.log('after:',total_pcis.enum.length)
+ },
back() {
this.$router.back()
},
@@ -175,10 +189,28 @@ export default {
this.updateCurrentBoardInfo()
this.switchTab(-1)
},
+ updateLoadSchema(){
+ let total=[]
+ this.scenario.vm.map((vmConfig)=>{
+ if(vmConfig.pci_devs!==undefined){//at least typeof pci_devs=='object', i.e.,{}
+ total.push(...vmConfig.pci_devs.pci_dev)
+ }
+ })
+ let current=configurator.pythonObject.updateSchema(this.board.content,total)
+ let retSch=JSON.parse(current)
+ this.schemas.PreLaunchedVM.BasicConfigType.definitions.PCIDevsConfiguration.properties.pci_dev.items.enum=this.schemas.PreLaunchedVM.BasicConfigType.definitions.PCIDevsConfiguration.properties.pci_dev.items.enumNames=retSch
+ },
updateCurrentFormSchema() {
if (this.activeVMID === -1) {
this.currentFormSchema = this.schemas.HV
} else {
+ if(!this.isLoaded){
+ this.updateLoadSchema()
+ this.isLoaded=true
+ }
+ if(this.isSaved){
+ this.updateLoadSchema()
+ }
this.scenario.vm.map((vmConfig) => {
if (vmConfig['@id'] === this.activeVMID) {
let vm_schema = {
@@ -221,6 +253,9 @@ export default {
for (let i = 0; i < this.scenario.vm.length; i++) {
if (this.scenario.vm[i]['@id'] === this.activeVMID) {
this.currentFormData = this.scenario.vm[i]
+ if(this.scenario.vm[i]['load_order']=='PRE_LAUNCHED_VM'&&this.isSaved){
+ this.updateSchema(i)
+ }
}
}
},
@@ -490,7 +525,10 @@ export default {
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
.then(() => {
+ this.isSaved=true
this.updateCurrentFormData()
+ this.isSaved=false
+ this.isLoaded=false
})
.then(() => {
// validate scenario and clean up the launch script
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/Scenario/NewScenario.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/Scenario/NewScenario.vue
index b9a82443f..511ac48fd 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/Scenario/NewScenario.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/Scenario/NewScenario.vue
@@ -32,7 +32,7 @@
- Partitioned (Pre-launched VMs only)
+ Partitioned (Pre-launched VMs or with Main VM)
@@ -53,6 +53,10 @@
Service VM:
+
+ Main VM:
+
+
Post-launch VMs:
@@ -83,7 +87,8 @@ export default {
version: branchVersion,
scenarioTemplate: "shared",
preLaunch: 1,
- postLaunch: 1
+ postLaunch: 1,
+ mainVM: 1
}
},
methods: {
@@ -102,6 +107,7 @@ export default {
post = this.postLaunch
} else if (this.scenarioTemplate === 'partitioned') {
pre = this.preLaunch
+ service = this.mainVM;
} else if (this.scenarioTemplate === 'hybrid') {
pre = this.preLaunch;
service = 1;
diff --git a/misc/config_tools/configurator/pyodide/updateSchema.py b/misc/config_tools/configurator/pyodide/updateSchema.py
new file mode 100644
index 000000000..4098d3fc2
--- /dev/null
+++ b/misc/config_tools/configurator/pyodide/updateSchema.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+__package__ = 'configurator.pyodide'
+
+from .pyodide import convert_result, nuc11_board, nuc11_scenario
+
+import re
+from lxml import etree
+
+
+class GenerateSchema:
+
+ def __init__(self, board, scenario):
+ parser = etree.XMLParser(remove_blank_text=True)
+ self.board_etree = etree.fromstring(board, parser)
+ self.scenario = scenario
+
+ @property
+ def pcis(self):
+ line = self.board_etree.xpath('/acrn-config/PCI_DEVICE/text()')[0]
+ cnt = []
+ for line in line.replace('\t', '').split('\n'):
+ re_cpi = re.compile(r'^([0-9A-Fa-f]{1,2}:[0-1][0-9A-Fa-f]\.[0-7].*)\(')
+ ret_ = re_cpi.search(line)
+ if ret_:
+ ret = ret_.group(1).strip()
+ if re.search(r'^00:00.0', ret): # omit 00:00.0
+ continue
+ cnt.append(ret)
+ return cnt
+
+ @property
+ def schemas(self):
+ return self.scenario
+
+ def update(self):
+ return sorted(list(set(self.pcis) - set(self.schemas)))
+
+
+def updateSchema(board, scenario):
+ return convert_result(GenerateSchema(board, scenario).update())
+
+
+main = updateSchema
+
+
+def test():
+ main(nuc11_board, nuc11_scenario)
+
+
+if __name__ == '__main__':
+ test()