config_tools: fix service vm cat settings

Sometimes service vm cat settings will not generate successfully, now fix it.

Tracked-On: #6691
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng 2022-05-27 17:39:16 +08:00 committed by acrnsi-robot
parent 35ffff7b3b
commit 877cde416a
5 changed files with 484 additions and 341 deletions

View File

@ -129,7 +129,7 @@ class Configurator {
return this.readFile(path).then((fileContent) => { return this.readFile(path).then((fileContent) => {
let syntactical_errors = this.pythonObject.validateScenarioStructure(fileContent); let syntactical_errors = this.pythonObject.validateScenarioStructure(fileContent);
if (syntactical_errors !== "") { if (syntactical_errors !== "") {
throw Error("The file has broken structure."); throw Error("The file has broken structure.\n" + syntactical_errors);
} }
return this.pythonObject.loadScenario(fileContent) return this.pythonObject.loadScenario(fileContent)
}) })
@ -140,14 +140,7 @@ class Configurator {
'@id': vmid, '@id': vmid,
load_order: load_order, load_order: load_order,
name: `VM${vmid}`, name: `VM${vmid}`,
cpu_affinity: { cpu_affinity: null
pcpu: [
{
pcpu_id: null,
real_time_vcpu: 'n'
}
]
}
} }
} }

View File

@ -250,7 +250,7 @@ export default {
msg = "Post-launched VMs require the Service VM. If you proceed, all post-launched VMs and their settings will also be deleted. Are you sure you want to proceed?" msg = "Post-launched VMs require the Service VM. If you proceed, all post-launched VMs and their settings will also be deleted. Are you sure you want to proceed?"
isserivevm = true isserivevm = true
} else { } else {
let vmName= this.scenario.vm[this.activeVMID].name let vmName = this.scenario.vm[this.activeVMID].name
msg = `Delete this virtual machine? ${vmName}\n\nThe associated launch script will also be deleted if it exists.` msg = `Delete this virtual machine? ${vmName}\n\nThe associated launch script will also be deleted if it exists.`
} }
confirm(msg).then((r) => { confirm(msg).then((r) => {
@ -357,12 +357,16 @@ export default {
let errorFlag = false let errorFlag = false
errorFlag = this.confirmVmName() errorFlag = this.confirmVmName()
this.assignVMID() this.assignVMID()
let msg = ["Settings validated\n", let msg = [
"scenario xml saved\n", "scenario xml saved\n",
"launch scripts generated\n"]; "Settings validated\n",
let errmsg = ["Settings validate failed\n", "launch scripts generated\n"
];
let errmsg = [
"scenario xml save failed\n", "scenario xml save failed\n",
"launch scripts generate failed\n"]; "Settings validate failed\n",
"launch scripts generate failed\n"
];
let stepDone = 0 let stepDone = 0
let totalMsg = msg.length // msg and errMsg must be same length. let totalMsg = msg.length // msg and errMsg must be same length.
let needSaveLaunchScript = false let needSaveLaunchScript = false
@ -379,10 +383,21 @@ export default {
console.log(scenarioWithDefault) console.log(scenarioWithDefault)
// write defaults to frontend // write defaults to frontend
this.scenario = scenarioWithDefault.json['acrn-config'] this.scenario = scenarioWithDefault.json['acrn-config']
console.log(this.scenario.hv.FEATURES)
if (this.scenario.hv.FEATURES.RDT.RDT_ENABLED === 'n') {
delete this.scenario.hv.CACHE_REGION
}
this.updateCurrentFormData() this.updateCurrentFormData()
// get scenario XML with defaults // get scenario XML with defaults
scenarioXMLData = scenarioWithDefault.xml scenarioXMLData = configurator.convertScenarioToXML(
if (!errorFlag) { {
// simple deep copy
"acrn-config": JSON.parse(JSON.stringify(this.scenario))
}
);
console.log(scenarioXMLData)
this.scenario.vm.map((vmConfig) => { this.scenario.vm.map((vmConfig) => {
if (vmConfig['load_order'] === 'POST_LAUNCHED_VM') { if (vmConfig['load_order'] === 'POST_LAUNCHED_VM') {
needSaveLaunchScript = true needSaveLaunchScript = true
@ -391,19 +406,21 @@ export default {
if (!needSaveLaunchScript) { if (!needSaveLaunchScript) {
totalMsg = totalMsg - 1 // remove the 'launch script' related mssage. totalMsg = totalMsg - 1 // remove the 'launch script' related mssage.
} }
// begin verify and write down // begin write down and verify
console.log("validate settings...")
try { try {
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
.then(() => {
stepDone = 1
if (!errorFlag) {
console.log("validate settings...")
this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData) this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
// noinspection ExceptionCaughtLocallyJS
if (this.errors.length !== 0) { if (this.errors.length !== 0) {
throw "validation failed" throw new Error("validation failed")
} }
console.log("validation ok") console.log("validation ok")
stepDone = 1
this.cleanLaunchScript()
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
.then(()=> {
stepDone = 2 stepDone = 2
this.cleanLaunchScript()
if (needSaveLaunchScript) { if (needSaveLaunchScript) {
let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData) let launchScripts = configurator.pythonObject.generateLaunchScript(this.board.content, scenarioXMLData)
for (let filename in launchScripts) { for (let filename in launchScripts) {
@ -411,11 +428,13 @@ export default {
} }
stepDone = 3 stepDone = 3
} }
}
}) })
.then(() => { .then(() => {
alert(`${msg.slice(0,stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`) alert(`${msg.slice(0, stepDone).join('')} \nAll files successfully saved to your working folder ${this.WorkingFolder}`)
}) })
} catch(err) { } catch (err) {
console.log("error" + err) console.log("error" + err)
let outmsg = '' let outmsg = ''
for (var i = 0; i < stepDone; i++) for (var i = 0; i < stepDone; i++)
@ -426,7 +445,7 @@ export default {
} }
} }
} }
}
} }
</script> </script>

View File

@ -31,13 +31,14 @@
</b-form-checkbox> </b-form-checkbox>
</div> </div>
</div> </div>
<p> <div class="py-4" v-for="CACHE_ALLOCATION in CAT_INFO" v-if="RDT_ENABLED==='y'">
<p v-if="CACHE_ALLOCATION.level===3">
L3 Cache Allocation Technology L3 Cache Allocation Technology
<br/> <br/>
Drag the ends of the boxes to cover the cache chunks you want to allocate to specific VMs. If you have a real-time Drag the ends of the boxes to cover the cache chunks you want to allocate to specific VMs. If you have a
real-time
VM,ensure its cache chunks do not overlap with any other VM's cache chunks. VM,ensure its cache chunks do not overlap with any other VM's cache chunks.
</p> </p>
<div class="py-4" v-for="CACHE_ALLOCATION in CAT_INFO" v-if="RDT_ENABLED==='y'">
<div class="d-flex justify-content-between py-2 align-items-center"> <div class="d-flex justify-content-between py-2 align-items-center">
<text> <text>
L{{ CACHE_ALLOCATION.level }} Cache Allocation Technology {{ L{{ CACHE_ALLOCATION.level }} Cache Allocation Technology {{
@ -106,7 +107,8 @@ function count(source, target) {
return (source.match(new RegExp(target, 'g')) || []).length; return (source.match(new RegExp(target, 'g')) || []).length;
} }
// noinspection JSUnusedLocalSymbols
// noinspection JSUnresolvedVariable
export default { export default {
name: "CAT", name: "CAT",
components: {HexBlockRangeSelector}, components: {HexBlockRangeSelector},
@ -117,21 +119,17 @@ export default {
this.updateCatInfo() this.updateCatInfo()
}, },
computed: { computed: {
VCAT_ENABLED: {
get() {
return vueUtils.getPathVal(this.rootFormData, 'FEATURES.RDT.VCAT_ENABLED')
},
set(value) {
vueUtils.setPathVal(this.rootFormData, 'FEATURES.RDT.VCAT_ENABLED', value)
this.updateCatInfo()
}
},
SSRAM_ENABLED: { SSRAM_ENABLED: {
get() { get() {
return vueUtils.getPathVal(this.rootFormData, 'FEATURES.SSRAM.SSRAM_ENABLED') return vueUtils.getPathVal(this.rootFormData, 'FEATURES.SSRAM.SSRAM_ENABLED')
}, },
set(value) { set(value) {
vueUtils.setPathVal(this.rootFormData, 'FEATURES.SSRAM.SSRAM_ENABLED', value) vueUtils.setPathVal(this.rootFormData, 'FEATURES.SSRAM.SSRAM_ENABLED', value)
if (value === 'y') {
if (this.RDT_ENABLED === 'y') {
this.RDT_ENABLED = 'n'
}
}
} }
}, },
RDT_ENABLED: { RDT_ENABLED: {
@ -140,6 +138,19 @@ export default {
}, },
set(value) { set(value) {
vueUtils.setPathVal(this.rootFormData, 'FEATURES.RDT.RDT_ENABLED', value) vueUtils.setPathVal(this.rootFormData, 'FEATURES.RDT.RDT_ENABLED', value)
if (value === 'y') {
if (this.SSRAM_ENABLED === 'y') {
this.SSRAM_ENABLED = 'n'
}
}
if (value === 'n') {
if (this.CDP_ENABLED === 'y') {
this.CDP_ENABLED = 'n'
}
if (this.VCAT_ENABLED === 'y') {
this.VCAT_ENABLED = 'n'
}
}
this.updateCatInfo() this.updateCatInfo()
} }
}, },
@ -149,15 +160,38 @@ export default {
}, },
set(value) { set(value) {
vueUtils.setPathVal(this.rootFormData, 'FEATURES.RDT.CDP_ENABLED', value) vueUtils.setPathVal(this.rootFormData, 'FEATURES.RDT.CDP_ENABLED', value)
if (value === 'y') {
if (this.SSRAM_ENABLED === 'y') {
this.SSRAM_ENABLED = 'n' this.SSRAM_ENABLED = 'n'
}
if (this.VCAT_ENABLED === 'y') {
this.VCAT_ENABLED = 'n' this.VCAT_ENABLED = 'n'
}
}
if (this.RDT_ENABLED !== value) { if (this.RDT_ENABLED !== value) {
this.RDT_ENABLED = value this.RDT_ENABLED = value
} else {
this.updateCatInfo()
} }
} }
},
VCAT_ENABLED: {
get() {
return vueUtils.getPathVal(this.rootFormData, 'FEATURES.RDT.VCAT_ENABLED')
},
set(value) {
vueUtils.setPathVal(this.rootFormData, 'FEATURES.RDT.VCAT_ENABLED', value)
if (value === 'y') {
if (this.SSRAM_ENABLED === 'y') {
this.SSRAM_ENABLED = 'n'
} }
if (this.CDP_ENABLED === 'y') {
this.CDP_ENABLED = 'n'
}
}
if (this.RDT_ENABLED !== value) {
this.RDT_ENABLED = value
}
}
},
}, },
watch: { watch: {
CAT_INFO: { CAT_INFO: {
@ -203,69 +237,71 @@ export default {
} }
}, },
updateCatInfo() { updateCatInfo() {
// Intel Resource Director Tech
// Intel Resource Director Technology (RDT) provides cache and memory bandwidth allocation features. The features can be used to improve an application's real-time performance.
//
//
// FEATURES.RDT.RDT_ENABLED
// Intel Resource Director Tech
//
// FEATURES.RDT.CDP_ENABLED
// Code and Data Prioritization
//
// FEATURES.RDT.VCAT_ENABLED
// Virtual Cache Allocation Tech
//
// Software SRAM
// Configure Software SRAM. This feature reserves memory buffers as always-cached memory to improve an application's real-time performance.
//
//
// FEATURES.SSRAM.SSRAM_ENABLED
// Software SRAM
// get settings from formData // get settings from formData
let RDT_ENABLED = this.RDT_ENABLED === 'y' let RDT_ENABLED = this.RDT_ENABLED === 'y'
let CDP_ENABLED = this.CDP_ENABLED === 'y' let CDP_ENABLED = this.CDP_ENABLED === 'y'
let VCAT_ENABLED = this.VCAT_ENABLED === 'y' let VCAT_ENABLED = this.VCAT_ENABLED === 'y'
if (!RDT_ENABLED) { if (!RDT_ENABLED) {
this.CAT_INFO = null // keep CAT_INFO
return return
} }
// get CAT info from board xml // get vmConfig from formData
let board_cat_info = window.getBoardData().CAT_INFO; // let getCPUAffinity = () => {
// // vmName: {pcpu_id:0, vcpu_id:0, isRT:false}
// let vmCpuAffinity = {};
// window.getCurrentScenarioData().vm.map((vmConfig) => {
// // if this vm is service vm, skip it
// if (vmConfig.load_order === 'SERVICE_VM') {
// return;
// }
//
// })
// }
// noinspection JSUnusedLocalSymbols
let board_cat_info_example = [
{
"id": "0x0", "level": 3, "type": "3", "cache_size": 31457280, "capacity_mask_length": 12,
"processors": [0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15]
}
]
// get scenario pcpu config
let pcpu_vms = {}
// noinspection JSUnusedLocalSymbols
let pcpu_vms_example = {
0: [
{"VM": "POST_VM_1", "VCPU": 0},
{"VM": "POST_VM_2", "VCPU": 2}
],
1: [
{"VM": "POST_VM_1", "VCPU": 1},
{"VM": "POST_VM_5", "VCPU": 2}
]
}
let getCurrentFormDataCPUAffinitySettings = () => {
/**
* let vCatsExample = [
* // VCPU is force set to 0
* // CLOS_MASK is force set to width of capacity_mask_length (for vcat only)
* {"VM": "VM_C", "VCPU": 0, "CLOS_MASK": 2},
* {"VM": "VM_D", "VCPU": 0, "CLOS_MASK": 5},
* ]
*/
let vCats = [] let vCats = []
// noinspection JSUnusedLocalSymbols /**
let vCatsExample = [ * get pcpu config from current formData
{"VM": "VM_C", "VCPU": 0, "CLOS_MASK": 2} * let pcpu_vms_example = {
] * 0: {
* 'y': [],
* 'n': [
* {"VM": "POST_VM_1", "VCPU": 0},
* {"VM": "POST_VM_2", "VCPU": 2}
* ]
* },
* 1: {
* 'y': [
* {"VM": "POST_VM_1", "VCPU": 1}
* ],
* 'n': [
* {"VM": "POST_VM_2", "VCPU": 2}
* ]
* }
* }
*/
let pcpu_vms = {}
let serviceVM = null;
window.getCurrentScenarioData().vm.map((vmConfig) => { window.getCurrentScenarioData().vm.map((vmConfig) => {
// if this vm is service vm, we got it and skip it
if (vmConfig.load_order === 'SERVICE_VM') {
serviceVM = vmConfig;
return;
}
// no cpu affinity, skip it
if ( if (
!vmConfig.hasOwnProperty('cpu_affinity') || !vmConfig.hasOwnProperty('cpu_affinity') ||
!vmConfig.cpu_affinity.hasOwnProperty('pcpu') || !vmConfig.cpu_affinity.hasOwnProperty('pcpu') ||
@ -274,18 +310,23 @@ export default {
return return
} }
// now, we got pre/post vm config with cpu affinity data here
// if vcat is enabled in hv, we need to check current vm is enabled vcat
// noinspection JSUnresolvedVariable // noinspection JSUnresolvedVariable
if ( if (
VCAT_ENABLED && VCAT_ENABLED &&
vmConfig.hasOwnProperty('virtual_cat_support') && vmConfig.hasOwnProperty('virtual_cat_support') &&
vmConfig.virtual_cat_support === "y" vmConfig.virtual_cat_support === "y"
) { ) {
// if enabled vcat in vmConfig, add vm's vcat config to vCats
// noinspection JSUnresolvedVariable // noinspection JSUnresolvedVariable
vCats.push({"VM": vmConfig.name, "VCPU": 0, "CLOS_MASK": vmConfig.virtual_cat_number}) vCats.push({"VM": vmConfig.name, "VCPU": 0, "CLOS_MASK": vmConfig.virtual_cat_number})
// for enabled virtual_cat_support vm, it doesn't need set CAT // for enabled virtual_cat_support vm, it doesn't need set CAT
return; return;
} }
// get cpu affinity settings from pre/post vms which are not enabled vCAT
vmConfig.cpu_affinity.pcpu.map((pcpu, index) => { vmConfig.cpu_affinity.pcpu.map((pcpu, index) => {
if (!pcpu_vms.hasOwnProperty(pcpu.pcpu_id)) { if (!pcpu_vms.hasOwnProperty(pcpu.pcpu_id)) {
pcpu_vms[pcpu.pcpu_id] = {'y': [], 'n': []} pcpu_vms[pcpu.pcpu_id] = {'y': [], 'n': []}
@ -298,36 +339,80 @@ export default {
// doesn't have it, auto set to no // doesn't have it, auto set to no
'n' 'n'
].push({ ].push({
// '@id': vmConfig['@id'],
"VM": vmConfig.name, "VM": vmConfig.name,
"VCPU": index "VCPU": index,
}) })
}) })
}) })
// generate service vm cpu affinity setting
if (serviceVM !== null) {
let serviceVMCPUIndex = 0;
Object.keys(pcpu_vms).map((pcpu_id) => {
// if this core is not used as rt core,
// use it as service vm cpu
if (pcpu_vms[pcpu_id].y.length === 0) {
pcpu_vms[pcpu_id].n.push({
// '@id': serviceVM['@id'],
"VM": serviceVM.name,
"VCPU": serviceVMCPUIndex
})
serviceVMCPUIndex++;
}
})
}
return {
vCats: vCats,
pcpu_vms: pcpu_vms,
serviceVM: serviceVM
}
}
let getScenarioCATData = () => {
/**
* load data from scenario
* let scenarioHVCACHE_REGIONData_data_example = {
* "CACHE_ALLOCATION": [
* {
* "CACHE_ID": "0x8", "CACHE_LEVEL": 2, "POLICY": [
* {"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
* {"VM": "POST_RT_VM1", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
* {"VM": "VM4-RTVM2", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
* {"VM": "VM4-RTVM2", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
* ]
* },
* {
* "CACHE_ID": "0x9", "CACHE_LEVEL": 2, "POLICY": [
* {"VM": "VM5-RTVM3", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
* {"VM": "VM5-RTVM3", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
* {"VM": "VM6-RTVM4", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
* {"VM": "VM6-RTVM4", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
* ]
* }
* ]
* }
*/
let scenarioHVCACHE_REGIONData = vueUtils.getPathVal(this.rootFormData, this.curNodePath); let scenarioHVCACHE_REGIONData = vueUtils.getPathVal(this.rootFormData, this.curNodePath);
// noinspection JSUnusedLocalSymbols
let scenarioHVCACHE_REGIONData_data_example = {
"CACHE_ALLOCATION": [
{
"CACHE_ID": "0x8", "CACHE_LEVEL": 2, "POLICY": [
{"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
{"VM": "POST_RT_VM1", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
{"VM": "VM4-RTVM2", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
{"VM": "VM4-RTVM2", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
]
},
{
"CACHE_ID": "0x9", "CACHE_LEVEL": 2, "POLICY": [
{"VM": "VM5-RTVM3", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
{"VM": "VM5-RTVM3", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
{"VM": "VM6-RTVM4", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"},
{"VM": "VM6-RTVM4", "VCPU": 1, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
]
}
]
}
// load data from scenario /**
* let scenario_cat_data_example = {
* 2: {
* '0x7': {
* "CACHE_ID": "0x7", "CACHE_LEVEL": 2, "POLICY": [
* {"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
* ]
* },
* '0x8': {
* "CACHE_ID": "0x8", "CACHE_LEVEL": 2, "POLICY": [
* {"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
* ]
* }
* },
* 3: {
* '0x0': {}
* }
* }
*/
let scenario_cat_data = {} let scenario_cat_data = {}
// noinspection JSUnresolvedVariable // noinspection JSUnresolvedVariable
if ( if (
@ -343,40 +428,47 @@ export default {
scenario_cat_data[cache_region['CACHE_LEVEL']][cache_region['CACHE_ID']] = cache_region scenario_cat_data[cache_region['CACHE_LEVEL']][cache_region['CACHE_ID']] = cache_region
}) })
} }
return scenario_cat_data
}
// noinspection JSUnusedLocalSymbols
let scenario_cat_data_example = { let mergeAndGenerateData = (currentFormDataCPUAffinitySettings, scenarioCatData) => {
2: {
'0x7': { /**
"CACHE_ID": "0x7", "CACHE_LEVEL": 2, "POLICY": [ * get CAT info from board xml
{"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"} * let board_cat_info_example = [
] * {
}, * "id": "0x0", "level": 3, "type": "3", "cache_size": 31457280, "capacity_mask_length": 12,
'0x8': { * "processors": [0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15]
"CACHE_ID": "0x8", "CACHE_LEVEL": 2, "POLICY": [ * }
{"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"} * ]
] */
}
}, /**
3: { * let cat_level_region_sum_example = {
'0x0': {} * 2: {
} * count: 2,
} * '0x8': 1,
* '0x9': 2
* },
* 3: {
* count: 1,
* '0x0': 1
* }
* }
*/
let scenario_cat_data = scenarioCatData
let {pcpu_vms, vCats} = currentFormDataCPUAffinitySettings;
this.cat_level_region_sum = {} this.cat_level_region_sum = {}
// noinspection JSUnusedLocalSymbols
let cat_level_region_sum_example = { let board_cat_info = _.cloneDeep(window.getBoardData().CAT_INFO);
2: {
count: 2, board_cat_info.map((
'0x8': 1, cat_region_info
'0x9': 2 ) => {
},
3: {
count: 1,
'0x0': 1
}
}
board_cat_info.map((cat_region_info) => {
// count regions for each cat level // count regions for each cat level
if (!this.cat_level_region_sum.hasOwnProperty(cat_region_info.level)) { if (!this.cat_level_region_sum.hasOwnProperty(cat_region_info.level)) {
this.cat_level_region_sum[cat_region_info.level] = {count: 0}; this.cat_level_region_sum[cat_region_info.level] = {count: 0};
@ -384,26 +476,30 @@ export default {
this.cat_level_region_sum[cat_region_info.level].count += 1 this.cat_level_region_sum[cat_region_info.level].count += 1
this.cat_level_region_sum[cat_region_info.level][cat_region_info.id] = this.cat_level_region_sum[cat_region_info.level].count; this.cat_level_region_sum[cat_region_info.level][cat_region_info.id] = this.cat_level_region_sum[cat_region_info.level].count;
// get vm cpu clos_mask from scenario /**
* get vm cpu clos_mask from scenario
* let vmCPUClosMasks_example = {
* 'VM_NAME': {
* // vcpu_id: {type: clos_mask}
* 0: {"Unified": '0xfff'},
* 1: {"Code": '0xff0', "Data": '0x00f'} // CDP_ENABLED
* }
* }
*/
let vmCPUClosMasks = {} let vmCPUClosMasks = {}
// noinspection JSUnusedLocalSymbols
let vmCPUClosMasks_example = {
'VM_NAME': {
0: {"Unified": '0xfff'},
1: {"Code": '0xff0', "Data": '0x00f'} // CDP_ENABLED
}
}
if ( if (
scenario_cat_data.hasOwnProperty(cat_region_info.level) && scenario_cat_data.hasOwnProperty(cat_region_info.level) &&
scenario_cat_data[cat_region_info.level].hasOwnProperty(cat_region_info.id) scenario_cat_data[cat_region_info.level].hasOwnProperty(cat_region_info.id)
) { ) {
/**
* let current_region_scenario_cat_data_example = {
* "CACHE_ID": "0x7", "CACHE_LEVEL": 2, "POLICY": [
* {"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
* ]
* }
*/
let current_region_scenario_cat_data = scenario_cat_data[cat_region_info.level][cat_region_info.id]; let current_region_scenario_cat_data = scenario_cat_data[cat_region_info.level][cat_region_info.id];
// noinspection JSUnusedLocalSymbols
let current_region_scenario_cat_data_example = {
"CACHE_ID": "0x7", "CACHE_LEVEL": 2, "POLICY": [
{"VM": "POST_RT_VM1", "VCPU": 0, "TYPE": "Unified", "CLOS_MASK": "0x0fff"}
]
}
for (let i = 0; i < current_region_scenario_cat_data.POLICY.length; i++) { for (let i = 0; i < current_region_scenario_cat_data.POLICY.length; i++) {
let currentRegionScenarioPolicy = current_region_scenario_cat_data.POLICY[i] let currentRegionScenarioPolicy = current_region_scenario_cat_data.POLICY[i]
if (!vmCPUClosMasks.hasOwnProperty(currentRegionScenarioPolicy.VM)) { if (!vmCPUClosMasks.hasOwnProperty(currentRegionScenarioPolicy.VM)) {
@ -424,41 +520,44 @@ export default {
"POLICY": [] "POLICY": []
} }
function addCATPolicy(cpu_policies_line, line_type, vcat_mask_length = null) { function addCATPolicy(cpu_policy_line, line_type, vcat_mask_length = null) {
cpu_policies_line['TYPE'] = line_type; let cpu_policy = _.cloneDeep(cpu_policy_line)
cpu_policy['TYPE'] = line_type;
// noinspection JSUnresolvedVariable
let clos_mask = "0x" + parseInt('1'.repeat( let clos_mask = "0x" + parseInt('1'.repeat(
// if vcat_mask_length is null // if vcat_mask_length is not null
vcat_mask_length === null ? vcat_mask_length !== null ?
// filled by capacity_mask_length
cat_region_info.capacity_mask_length :
// filled by vcat_mask_length // filled by vcat_mask_length
vcat_mask_length vcat_mask_length :
// filled by capacity_mask_length
cat_region_info.capacity_mask_length
), 2).toString(16); ), 2).toString(16);
if ( if (
vmCPUClosMasks.hasOwnProperty(cpu_policies_line.VM) && vmCPUClosMasks.hasOwnProperty(cpu_policy.VM) &&
vmCPUClosMasks[cpu_policies_line.VM].hasOwnProperty(cpu_policies_line.VCPU) && vmCPUClosMasks[cpu_policy.VM].hasOwnProperty(cpu_policy.VCPU) &&
vmCPUClosMasks[cpu_policies_line.VM][cpu_policies_line.VCPU].hasOwnProperty(line_type) vmCPUClosMasks[cpu_policy.VM][cpu_policy.VCPU].hasOwnProperty(line_type)
) { ) {
let scenario_clos_mask = vmCPUClosMasks[cpu_policies_line.VM][cpu_policies_line.VCPU][line_type]; let scenario_clos_mask = vmCPUClosMasks[cpu_policy.VM][cpu_policy.VCPU][line_type];
if (vcat_mask_length === null || count(Number.parseInt(scenario_clos_mask).toString(2), '1') === vcat_mask_length) { if (vcat_mask_length === null || count(Number.parseInt(scenario_clos_mask).toString(2), '1') === vcat_mask_length) {
clos_mask = scenario_clos_mask clos_mask = scenario_clos_mask
} }
} }
cpu_policies_line['CLOS_MASK'] = clos_mask; cpu_policy['CLOS_MASK'] = clos_mask;
cat_region_info.data.POLICY.push(cpu_policies_line) cat_region_info.data.POLICY.push(cpu_policy)
} }
/**
* let cpu_policies_example = [
* {"VM": "POST_VM_1", "VCPU": 0},
* {"VM": "POST_VM_2", "VCPU": 2}
* ]
*/
function addPolicy(cpu_policies) { function addPolicy(cpu_policies) {
// noinspection JSUnusedLocalSymbols
let cpu_policies_example = [
{"VM": "POST_VM_1", "VCPU": 0},
{"VM": "POST_VM_2", "VCPU": 2}
]
for (let j = 0; j < cpu_policies.length; j++) { for (let j = 0; j < cpu_policies.length; j++) {
let cpu_policies_line = cpu_policies[j]; let cpu_policies_line = cpu_policies[j];
if (CDP_ENABLED) { if (CDP_ENABLED) {
addCATPolicy(cpu_policies_line, "Code") addCATPolicy(cpu_policies_line, "Code")
addCATPolicy(_.cloneDeep(cpu_policies_line), "Data") addCATPolicy(cpu_policies_line, "Data")
} else { } else {
addCATPolicy(cpu_policies_line, "Unified") addCATPolicy(cpu_policies_line, "Unified")
} }
@ -468,29 +567,47 @@ export default {
// add rt vm policy // add rt vm policy
cat_region_info.real_time_count = 0 cat_region_info.real_time_count = 0
// noinspection JSUnresolvedVariable
for (let i = 0; i < cat_region_info.processors.length; i++) { for (let i = 0; i < cat_region_info.processors.length; i++) {
// noinspection JSUnresolvedVariable
let pcpu_id = cat_region_info.processors[i]; let pcpu_id = cat_region_info.processors[i];
let cpu_policies = _.cloneDeep(pcpu_vms[pcpu_id] ? pcpu_vms[pcpu_id]['y'] || [] : []); let cpu_policies = pcpu_vms[pcpu_id] ? pcpu_vms[pcpu_id]['y'] : [];
cat_region_info.real_time_count += addPolicy(cpu_policies) cat_region_info.real_time_count += addPolicy(cpu_policies)
} }
// add std vm policy // add std vm policy
cat_region_info.cat_count = _.cloneDeep(cat_region_info.real_time_count) cat_region_info.cat_count = _.cloneDeep(cat_region_info.real_time_count)
// noinspection JSUnresolvedVariable
for (let i = 0; i < cat_region_info.processors.length; i++) { for (let i = 0; i < cat_region_info.processors.length; i++) {
// noinspection JSUnresolvedVariable
let pcpu_id = cat_region_info.processors[i]; let pcpu_id = cat_region_info.processors[i];
let cpu_policies = _.cloneDeep(pcpu_vms[pcpu_id] ? pcpu_vms[pcpu_id]['n'] || [] : []); let cpu_policies = pcpu_vms[pcpu_id] ? pcpu_vms[pcpu_id]['n'] : [];
cat_region_info.cat_count += addPolicy(cpu_policies) cat_region_info.cat_count += addPolicy(cpu_policies)
} }
// add cat vm policy // add vcat vm policy
// noinspection JSUnresolvedVariable
if (cat_region_info.processors.indexOf(0) !== -1) { if (cat_region_info.processors.indexOf(0) !== -1) {
for (let i = 0; i < vCats.length; i++) { for (let i = 0; i < vCats.length; i++) {
addCATPolicy(_.cloneDeep(vCats[i]), 'Unified', vCats[i].CLOS_MASK) addCATPolicy(vCats[i], 'Unified', vCats[i].CLOS_MASK)
} }
} }
// order policy by @id
// cat_region_info.data.POLICY.sort(function (a, b) {
// return a['@id'] - b['@id']
// });
}) })
return board_cat_info;
}
this.CAT_INFO = board_cat_info; let generate = () => {
let currentFormDataCPUAffinitySettings = getCurrentFormDataCPUAffinitySettings();
let scenarioCatData = getScenarioCATData();
this.CAT_INFO = mergeAndGenerateData(currentFormDataCPUAffinitySettings, scenarioCatData);
}
generate()
} }
} }
} }

View File

@ -6,18 +6,21 @@ from tempfile import TemporaryDirectory
from scenario_config.default_populator import DefaultValuePopulatingStage from scenario_config.default_populator import DefaultValuePopulatingStage
from scenario_config.pipeline import PipelineObject, PipelineEngine from scenario_config.pipeline import PipelineObject, PipelineEngine
from scenario_config.validator import ValidatorConstructionByFileStage, SemanticValidationStage from scenario_config.validator import ValidatorConstructionByFileStage, SemanticValidationStage, \
SyntacticValidationStage
from scenario_config.xml_loader import XMLLoadStage from scenario_config.xml_loader import XMLLoadStage
from .pyodide import ( from .pyodide import (
convert_result, write_temp_file, convert_result, write_temp_file,
# Todo: add debug switch
# is_debug,
nuc11_board, nuc11_scenario, scenario_xml_schema_path, datachecks_xml_schema_path nuc11_board, nuc11_scenario, scenario_xml_schema_path, datachecks_xml_schema_path
) )
def main(board, scenario): def main(board, scenario):
pipeline = PipelineEngine(["board_path", "scenario_path", "schema_path", "datachecks_path"]) pipeline = PipelineEngine(["board_path", "scenario_path", "schema_path", "datachecks_path"])
pipeline.add_stages([ stages = [
ValidatorConstructionByFileStage(), ValidatorConstructionByFileStage(),
XMLLoadStage("schema"), XMLLoadStage("schema"),
@ -25,7 +28,12 @@ def main(board, scenario):
XMLLoadStage("scenario"), XMLLoadStage("scenario"),
DefaultValuePopulatingStage(), DefaultValuePopulatingStage(),
SemanticValidationStage(), SemanticValidationStage(),
]) ]
#
# if is_debug:
# stages.append(SyntacticValidationStage())
pipeline.add_stages(stages)
with TemporaryDirectory() as tmpdir: with TemporaryDirectory() as tmpdir:
write_temp_file(tmpdir, { write_temp_file(tmpdir, {
'board.xml': board, 'board.xml': board,

View File

@ -5,6 +5,12 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:acrn="https://projectacrn.org"> xmlns:acrn="https://projectacrn.org">
<xs:assert test="every $vm in /acrn-config/vm[load_order != 'SERVICE_VM'] satisfies count($vm//cpu_affinity//pcpu_id) &gt;= 1">
<xs:annotation acrn:severity="error" acrn:report-on="$vm//cpu_affinity">
<xs:documentation>VM "{$vm/name}" needs at least one vCPU.</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $cpu in vm//cpu_affinity//pcpu_id satisfies count(processors//thread[cpu_id = $cpu]) = 1"> <xs:assert test="every $cpu in vm//cpu_affinity//pcpu_id satisfies count(processors//thread[cpu_id = $cpu]) = 1">
<xs:annotation acrn:severity="warning" acrn:report-on="$cpu"> <xs:annotation acrn:severity="warning" acrn:report-on="$cpu">
<xs:documentation>The physical CPU {$cpu} allocated to VM "{$cpu/ancestor::vm/name}" does not exist on the target board. Remove this CPU from the CPU affinity setting.</xs:documentation> <xs:documentation>The physical CPU {$cpu} allocated to VM "{$cpu/ancestor::vm/name}" does not exist on the target board. Remove this CPU from the CPU affinity setting.</xs:documentation>