mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-17 23:08:07 +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:
@@ -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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user