mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
acrn-config: refine VM number macro from scenario config
1. refine vm number macro from scenario config. 2. add sanity check for load order. Tracked-On: #4458 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
a8c2ba03fc
commit
830df76f1e
@ -260,48 +260,6 @@ def get_order_type_by_vmid(idx):
|
|||||||
return order_type
|
return order_type
|
||||||
|
|
||||||
|
|
||||||
def get_vmid_by_order_type(type_str):
|
|
||||||
"""
|
|
||||||
This is mapping table for {id:order type}
|
|
||||||
:param type_str: vm loader type
|
|
||||||
:return: table of id:order type dictionary
|
|
||||||
"""
|
|
||||||
|
|
||||||
idx_list = []
|
|
||||||
order_id_dic = common.order_type_map_vmid(SCENARIO_INFO_FILE, VM_COUNT)
|
|
||||||
|
|
||||||
for idx, order_type in order_id_dic.items():
|
|
||||||
if type_str == order_type:
|
|
||||||
idx_list.append(idx)
|
|
||||||
|
|
||||||
return idx_list
|
|
||||||
|
|
||||||
|
|
||||||
def is_pre_launch_vm(idx):
|
|
||||||
"""
|
|
||||||
Identification the vm id loader type is pre launched
|
|
||||||
:param idx: vm id number
|
|
||||||
:return: True if it is a pre launched vm
|
|
||||||
"""
|
|
||||||
order_type = get_order_type_by_vmid(idx)
|
|
||||||
if order_type == "PRE_LAUNCHED_VM":
|
|
||||||
status = True
|
|
||||||
else:
|
|
||||||
status = False
|
|
||||||
|
|
||||||
return status
|
|
||||||
|
|
||||||
def pre_launch_vm_ids():
|
|
||||||
""" Get pre launched vm ids as list """
|
|
||||||
pre_vm = []
|
|
||||||
|
|
||||||
for i in range(VM_COUNT):
|
|
||||||
if is_pre_launch_vm(i):
|
|
||||||
pre_vm.append(i)
|
|
||||||
|
|
||||||
return pre_vm
|
|
||||||
|
|
||||||
|
|
||||||
def vm_name_check(vm_names, item):
|
def vm_name_check(vm_names, item):
|
||||||
"""
|
"""
|
||||||
Check vm name
|
Check vm name
|
||||||
@ -323,7 +281,18 @@ def load_order_check(load_orders, item):
|
|||||||
:param item: vm name item in xml
|
:param item: vm name item in xml
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
sos_vm_ids = []
|
||||||
|
pre_vm_ids = []
|
||||||
|
post_vm_ids = []
|
||||||
for order_i, load_str in load_orders.items():
|
for order_i, load_str in load_orders.items():
|
||||||
|
if load_str == "SOS_VM":
|
||||||
|
sos_vm_ids.append(order_i)
|
||||||
|
|
||||||
|
if load_str == "PRE_LAUNCHED_VM":
|
||||||
|
pre_vm_ids.append(order_i)
|
||||||
|
|
||||||
|
if load_str == "POST_LAUNCHED_VM":
|
||||||
|
post_vm_ids.append(order_i)
|
||||||
|
|
||||||
if not load_str:
|
if not load_str:
|
||||||
key = "vm:id={},{}".format(order_i, item)
|
key = "vm:id={},{}".format(order_i, item)
|
||||||
@ -334,6 +303,35 @@ def load_order_check(load_orders, item):
|
|||||||
key = "vm:id={},{}".format(order_i, item)
|
key = "vm:id={},{}".format(order_i, item)
|
||||||
ERR_LIST[key] = "VM load order unknown"
|
ERR_LIST[key] = "VM load order unknown"
|
||||||
|
|
||||||
|
if len(sos_vm_ids) >= 2:
|
||||||
|
key = "vm:id={},{}".format(sos_vm_ids[0], item)
|
||||||
|
ERR_LIST[key] = "SOS_VM number should not be greater than 1"
|
||||||
|
|
||||||
|
if post_vm_ids and sos_vm_ids:
|
||||||
|
if post_vm_ids[0] < sos_vm_ids[-1]:
|
||||||
|
key = "vm:id={},{}".format(post_vm_ids[0], item)
|
||||||
|
ERR_LIST[key] = "POST_LAUNCHED_VM should be configured after SOS_VM"
|
||||||
|
|
||||||
|
if pre_vm_ids and sos_vm_ids:
|
||||||
|
if sos_vm_ids[-1] < pre_vm_ids[-1]:
|
||||||
|
key = "vm:id={},{}".format(sos_vm_ids[0], item)
|
||||||
|
ERR_LIST[key] = "PRE_LAUNCHED_VM should be configured before SOS_VM"
|
||||||
|
|
||||||
|
|
||||||
|
def get_load_order_cnt(load_orders, type_name):
|
||||||
|
"""
|
||||||
|
Get load order type count
|
||||||
|
:param load_orders: dictionary of vm load_order
|
||||||
|
:param type_name: load order type for vm
|
||||||
|
:return: number for this load order type name
|
||||||
|
"""
|
||||||
|
type_cnt = 0
|
||||||
|
for load_str in load_orders.values():
|
||||||
|
if type_name == load_str:
|
||||||
|
type_cnt += 1
|
||||||
|
|
||||||
|
return type_cnt
|
||||||
|
|
||||||
|
|
||||||
def guest_flag_check(guest_flag_idx, branch_tag, leaf_tag):
|
def guest_flag_check(guest_flag_idx, branch_tag, leaf_tag):
|
||||||
|
|
||||||
|
@ -261,6 +261,18 @@ class EpcSection:
|
|||||||
self.size = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "epc_section", "size")
|
self.size = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "epc_section", "size")
|
||||||
|
|
||||||
|
|
||||||
|
class LoadOrderNum:
|
||||||
|
""" This is Abstract of VM number for different load order """
|
||||||
|
def __init__(self):
|
||||||
|
self.pre_vm = 0
|
||||||
|
self.sos_vm = 0
|
||||||
|
self.post_vm = 0
|
||||||
|
|
||||||
|
def get_info(self, load_order):
|
||||||
|
self.pre_vm = scenario_cfg_lib.get_load_order_cnt(load_order, "PRE_LAUNCHED_VM")
|
||||||
|
self.sos_vm = scenario_cfg_lib.get_load_order_cnt(load_order, "SOS_VM")
|
||||||
|
self.post_vm = scenario_cfg_lib.get_load_order_cnt(load_order, "POST_LAUNCHED_VM")
|
||||||
|
|
||||||
class VmInfo:
|
class VmInfo:
|
||||||
""" This is Abstract of class of VM setting """
|
""" This is Abstract of class of VM setting """
|
||||||
name = {}
|
name = {}
|
||||||
@ -281,6 +293,7 @@ class VmInfo:
|
|||||||
self.os_cfg = CfgOsKern(self.scenario_info)
|
self.os_cfg = CfgOsKern(self.scenario_info)
|
||||||
self.vuart = VuartInfo(self.scenario_info)
|
self.vuart = VuartInfo(self.scenario_info)
|
||||||
self.cfg_pci = CfgPci(self.scenario_info)
|
self.cfg_pci = CfgPci(self.scenario_info)
|
||||||
|
self.load_order_cnt = LoadOrderNum()
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
"""
|
"""
|
||||||
@ -301,6 +314,7 @@ class VmInfo:
|
|||||||
self.os_cfg.get_info()
|
self.os_cfg.get_info()
|
||||||
self.vuart.get_info()
|
self.vuart.get_info()
|
||||||
self.cfg_pci.get_info()
|
self.cfg_pci.get_info()
|
||||||
|
self.load_order_cnt.get_info(self.load_order)
|
||||||
|
|
||||||
def get_cpu_bitmap(self, index):
|
def get_cpu_bitmap(self, index):
|
||||||
"""
|
"""
|
||||||
|
@ -36,6 +36,12 @@ def cpu_affinity_output(vm_info, i, config):
|
|||||||
i, cpu_bits['cpu_map']), file=config)
|
i, cpu_bits['cpu_map']), file=config)
|
||||||
|
|
||||||
|
|
||||||
|
def scenario_vm_num(load_type_cnt, config):
|
||||||
|
|
||||||
|
print("#define PRE_VM_NUM\t\t{}U".format(load_type_cnt.pre_vm), file=config)
|
||||||
|
print("#define SOS_VM_NUM\t\t{}U".format(load_type_cnt.sos_vm), file=config)
|
||||||
|
print("#define MAX_POST_VM_NUM\t\t{}U".format(load_type_cnt.post_vm), file=config)
|
||||||
|
|
||||||
def gen_sdc_header(vm_info, config):
|
def gen_sdc_header(vm_info, config):
|
||||||
"""
|
"""
|
||||||
Generate vm_configuration.h of sdc scenario
|
Generate vm_configuration.h of sdc scenario
|
||||||
@ -45,7 +51,7 @@ def gen_sdc_header(vm_info, config):
|
|||||||
gen_common_header(config)
|
gen_common_header(config)
|
||||||
print("#include <misc_cfg.h>\n", file=config)
|
print("#include <misc_cfg.h>\n", file=config)
|
||||||
|
|
||||||
print("#define CONFIG_MAX_VM_NUM\t\t(2U + CONFIG_MAX_KATA_VM_NUM)", file=config)
|
scenario_vm_num(vm_info.load_order_cnt, config)
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("/* Bits mask of guest flags that can be programmed by device model." +
|
print("/* Bits mask of guest flags that can be programmed by device model." +
|
||||||
" Other bits are set by hypervisor only */", file=config)
|
" Other bits are set by hypervisor only */", file=config)
|
||||||
@ -86,8 +92,7 @@ def gen_sdc2_header(vm_info, config):
|
|||||||
"""
|
"""
|
||||||
gen_common_header(config)
|
gen_common_header(config)
|
||||||
print("#include <misc_cfg.h>\n", file=config)
|
print("#include <misc_cfg.h>\n", file=config)
|
||||||
print("#define CONFIG_MAX_VM_NUM\t\t({0}U + CONFIG_MAX_KATA_VM_NUM)".format(
|
scenario_vm_num(vm_info.load_order_cnt, config)
|
||||||
scenario_cfg_lib.VM_COUNT), file=config)
|
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("/* Bits mask of guest flags that can be programmed by device model." +
|
print("/* Bits mask of guest flags that can be programmed by device model." +
|
||||||
" Other bits are set by hypervisor only */", file=config)
|
" Other bits are set by hypervisor only */", file=config)
|
||||||
@ -107,14 +112,14 @@ def gen_sdc2_header(vm_info, config):
|
|||||||
print("{0}".format(VM_END_DEFINE), file=config)
|
print("{0}".format(VM_END_DEFINE), file=config)
|
||||||
|
|
||||||
|
|
||||||
def logic_max_vm_num(config):
|
def logic_max_vm_num(vm_info, config):
|
||||||
"""
|
"""
|
||||||
This is logical max vm number comment
|
This is logical max vm number comment
|
||||||
:param config: it is the pointer which file write to
|
:param config: it is the pointer which file write to
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("#define CONFIG_MAX_VM_NUM\t\t{0}U".format(scenario_cfg_lib.VM_COUNT), file=config)
|
scenario_vm_num(vm_info.load_order_cnt, config)
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("/* The VM CONFIGs like:", file=config)
|
print("/* The VM CONFIGs like:", file=config)
|
||||||
print(" *\tVMX_CONFIG_VCPU_AFFINITY", file=config)
|
print(" *\tVMX_CONFIG_VCPU_AFFINITY", file=config)
|
||||||
@ -146,7 +151,7 @@ def gen_logical_partition_header(vm_info, config):
|
|||||||
" Other bits are set by hypervisor only */", file=config)
|
" Other bits are set by hypervisor only */", file=config)
|
||||||
print("#define DM_OWNED_GUEST_FLAG_MASK\t0UL", file=config)
|
print("#define DM_OWNED_GUEST_FLAG_MASK\t0UL", file=config)
|
||||||
|
|
||||||
logic_max_vm_num(config)
|
logic_max_vm_num(vm_info, config)
|
||||||
|
|
||||||
for i in range(scenario_cfg_lib.VM_COUNT):
|
for i in range(scenario_cfg_lib.VM_COUNT):
|
||||||
|
|
||||||
@ -206,8 +211,7 @@ def gen_industry_header(vm_info, config):
|
|||||||
gen_common_header(config)
|
gen_common_header(config)
|
||||||
print("#include <misc_cfg.h>", file=config)
|
print("#include <misc_cfg.h>", file=config)
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("#define CONFIG_MAX_VM_NUM\t\t({0}U + CONFIG_MAX_KATA_VM_NUM)".format(
|
scenario_vm_num(vm_info.load_order_cnt, config)
|
||||||
scenario_cfg_lib.VM_COUNT), file=config)
|
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("/* Bits mask of guest flags that can be programmed by device model." +
|
print("/* Bits mask of guest flags that can be programmed by device model." +
|
||||||
" Other bits are set by hypervisor only */", file=config)
|
" Other bits are set by hypervisor only */", file=config)
|
||||||
@ -241,8 +245,7 @@ def gen_hybrid_header(vm_info, config):
|
|||||||
"\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
|
"\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
|
||||||
|
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("#define CONFIG_MAX_VM_NUM\t\t({0}U + CONFIG_MAX_KATA_VM_NUM)".format(
|
scenario_vm_num(vm_info.load_order_cnt, config)
|
||||||
scenario_cfg_lib.VM_COUNT), file=config)
|
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
for i in range(scenario_cfg_lib.VM_COUNT):
|
for i in range(scenario_cfg_lib.VM_COUNT):
|
||||||
cpu_affinity_output(vm_info, i, config)
|
cpu_affinity_output(vm_info, i, config)
|
||||||
|
Loading…
Reference in New Issue
Block a user