mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
acrn-config: refinement for CPU affinity check
Refine CPU affinity sanity check for both scenario and launch config xmls. Tracked-On: #4641 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
e8d00c2cec
commit
eb47f8f5cb
@ -35,7 +35,8 @@ class AcrnDmArgs:
|
||||
launch_cfg_lib.mem_size_check(self.args["mem_size"], "mem_size")
|
||||
launch_cfg_lib.args_aval_check(self.args["vbootloader"], "vbootloader", launch_cfg_lib.BOOT_TYPE)
|
||||
launch_cfg_lib.args_aval_check(self.args["vuart0"], "vuart0", launch_cfg_lib.DM_VUART0)
|
||||
err_dic = scenario_cfg_lib.cpus_per_vm_check(self.launch_info, self.args["cpu_affinity"], "pcpu_id")
|
||||
cpu_affinity = launch_cfg_lib.uos_cpu_affinity(self.args["cpu_affinity"])
|
||||
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.launch_info, cpu_affinity, "pcpu_id")
|
||||
launch_cfg_lib.ERR_LIST.update(err_dic)
|
||||
|
||||
|
||||
|
@ -519,3 +519,12 @@ def get_gpu_vpid():
|
||||
if GPU_BDF in vpid_line:
|
||||
vpid = " ".join(vpid_line.split()[2].split(':'))
|
||||
return vpid
|
||||
|
||||
|
||||
def uos_cpu_affinity(uosid_cpu_affinity):
|
||||
|
||||
cpu_affinity = {}
|
||||
sos_vm_id = get_sos_vmid()
|
||||
for uosid,cpu_affinity_list in uosid_cpu_affinity.items():
|
||||
cpu_affinity[uosid + sos_vm_id] = cpu_affinity_list
|
||||
return cpu_affinity
|
||||
|
@ -210,7 +210,7 @@ def guest_flag_check(guest_flags, branch_tag, leaf_tag):
|
||||
ERR_LIST[key] = "Unknow guest flag"
|
||||
|
||||
|
||||
def cpus_per_vm_check(config_file, id_cpus_per_vm_dic, item):
|
||||
def vm_cpu_affinity_check(config_file, id_cpus_per_vm_dic, item):
|
||||
"""
|
||||
Check cpu number of per vm
|
||||
:param item: vm pcpu_id item in xml
|
||||
@ -234,13 +234,17 @@ def cpus_per_vm_check(config_file, id_cpus_per_vm_dic, item):
|
||||
else:
|
||||
use_cpus.append(cpu)
|
||||
|
||||
pre_launch_cpus = []
|
||||
post_launch_cpus = []
|
||||
for vm_i, vm_type in common.VM_TYPES.items():
|
||||
if vm_i not in id_cpus_per_vm_dic.keys() and "SOS_VM" == VM_DB[vm_type]['load_type']:
|
||||
if vm_i not in id_cpus_per_vm_dic.keys():
|
||||
continue
|
||||
elif vm_i not in id_cpus_per_vm_dic.keys() and VM_DB[vm_type]['load_type'] in ("PRE_LAUNCHED_VM", "POST_LAUNCHED_VM"):
|
||||
key = "vm:id={},{}".format(vm_i, item)
|
||||
err_dic[key] = "Pre launched_vm and Post launched vm should have cpus assignment"
|
||||
return err_dic
|
||||
elif VM_DB[vm_type]['load_type'] == "PRE_LAUNCHED_VM":
|
||||
cpus = [x for x in id_cpus_per_vm_dic[vm_i] if not None]
|
||||
pre_launch_cpus.extend(cpus)
|
||||
elif VM_DB[vm_type]['load_type'] == "POST_LAUNCHED_VM":
|
||||
cpus = [x for x in id_cpus_per_vm_dic[vm_i] if not None]
|
||||
post_launch_cpus.extend(cpus)
|
||||
|
||||
# duplicate cpus assign the same VM check
|
||||
cpus_vm_i = id_cpus_per_vm_dic[vm_i]
|
||||
@ -250,6 +254,15 @@ def cpus_per_vm_check(config_file, id_cpus_per_vm_dic, item):
|
||||
err_dic[key] = "VM should not use the same pcpu id:{}".format(cpu_id)
|
||||
return err_dic
|
||||
|
||||
if pre_launch_cpus:
|
||||
for pcpu in pre_launch_cpus:
|
||||
if pre_launch_cpus.count(pcpu) >= 2:
|
||||
key = "Pre launched VM cpu_affinity"
|
||||
err_dic[key] = "Pre_launched_vm vm should not have the same cpus assignment"
|
||||
if pcpu in post_launch_cpus:
|
||||
key = "Pre launched vm and Post launchded VM cpu_affinity"
|
||||
err_dic[key] = "Pre launched_vm and Post launched vm should not have the same cpus assignment"
|
||||
|
||||
return err_dic
|
||||
|
||||
|
||||
|
@ -312,7 +312,7 @@ class VmInfo:
|
||||
scenario_cfg_lib.vm_name_check(self.name, "name")
|
||||
scenario_cfg_lib.load_vm_check(self.load_vm, "load_vm")
|
||||
scenario_cfg_lib.guest_flag_check(self.guest_flags, "guest_flags", "guest_flag")
|
||||
err_dic = scenario_cfg_lib.cpus_per_vm_check(self.scenario_info, self.cpus_per_vm, "pcpu_id")
|
||||
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.scenario_info, self.cpus_per_vm, "pcpu_id")
|
||||
|
||||
self.mem_info.check_item()
|
||||
self.os_cfg.check_item()
|
||||
|
Loading…
Reference in New Issue
Block a user