mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
acrn-config: refine the data type for member of class
Unify the data type for scenario item. 1. Unified the scenario item, the type modified from list to dictionary. 2. remove some unused function. 3. add 'pci_dev_num'/'pci_devs' to hybrid xml for future support. Tracked-On: #3798 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
ee66a94ccf
commit
db909edda5
@ -251,13 +251,13 @@ def get_order_type_by_vmid(idx):
|
||||
"""
|
||||
This is get pre launched vm count
|
||||
:param idx: index of vm id
|
||||
:return: idx and vm type mapping
|
||||
:return: vm type of index to vmid
|
||||
"""
|
||||
(err_dic, order_id_dic) = common.get_load_order_by_vmid(SCENARIO_INFO_FILE, VM_COUNT, idx)
|
||||
(err_dic, order_type) = common.get_load_order_by_vmid(SCENARIO_INFO_FILE, VM_COUNT, idx)
|
||||
if err_dic:
|
||||
ERR_LIST.update(err_dic)
|
||||
|
||||
return order_id_dic
|
||||
return order_type
|
||||
|
||||
|
||||
def get_valid_irq(board_info):
|
||||
|
@ -189,7 +189,6 @@ def get_board_private_info(config_file):
|
||||
dev_private_tags = ['rootfs', 'console']
|
||||
for tag_str in dev_private_tags:
|
||||
dev_setting = get_sub_leaf_tag(config_file, branch_tag, tag_str)
|
||||
#dev_info = get_sub_tree_tag(config_file, )
|
||||
if not dev_setting and tag_str == "console":
|
||||
continue
|
||||
|
||||
@ -216,16 +215,6 @@ def get_vm_num(config_file):
|
||||
return common.get_vm_count(config_file)
|
||||
|
||||
|
||||
def get_sub_tree_tag(config_file, tag_str):
|
||||
"""
|
||||
This is get tag value by tag_str from config file
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:param tag_str: it is key of pattern to config file item
|
||||
:return: value of tag_str item
|
||||
"""
|
||||
return common.get_branch_tag_val(config_file, tag_str)
|
||||
|
||||
|
||||
def get_sub_leaf_tag(config_file, branch_tag, tag_str):
|
||||
"""
|
||||
This is get tag value by tag_str from config file
|
||||
@ -242,13 +231,13 @@ def get_order_type_by_vmid(idx):
|
||||
Get load order by vm id
|
||||
|
||||
:param idx: index of vm id
|
||||
:return: load order type of vm
|
||||
:return: load order type of index to vmid
|
||||
"""
|
||||
(err_dic, order_id_dic) = common.get_load_order_by_vmid(SCENARIO_INFO_FILE, VM_COUNT, idx)
|
||||
(err_dic, order_type) = common.get_load_order_by_vmid(SCENARIO_INFO_FILE, VM_COUNT, idx)
|
||||
if err_dic:
|
||||
ERR_LIST.update(err_dic)
|
||||
|
||||
return order_id_dic
|
||||
return order_type
|
||||
|
||||
|
||||
def get_vmid_by_order_type(type_str):
|
||||
@ -296,12 +285,12 @@ def pre_launch_vm_ids():
|
||||
def vm_name_check(vm_names, item):
|
||||
"""
|
||||
Check vm name
|
||||
:param vm_names: list of vm name
|
||||
:param vm_names: dictionary of vm name
|
||||
:param item: vm name item in xml
|
||||
:return: None
|
||||
"""
|
||||
for name_i in range(len(vm_names)):
|
||||
name_len = len(vm_names[name_i])
|
||||
for name_i, name_str in vm_names.items():
|
||||
name_len = len(name_str)
|
||||
if name_len > 32 or name_len == 0:
|
||||
key = "vm:id={},{}".format(name_i, item)
|
||||
ERR_LIST[key] = "VM name length should be in range [1,32] bytes"
|
||||
@ -310,12 +299,11 @@ def vm_name_check(vm_names, item):
|
||||
def load_order_check(load_orders, item):
|
||||
"""
|
||||
Check load order type
|
||||
:param load_orders: list of vm load_order
|
||||
:param load_orders: dictionary of vm load_order
|
||||
:param item: vm name item in xml
|
||||
:return: None
|
||||
"""
|
||||
for order_i in range(len(load_orders)):
|
||||
load_str = load_orders[order_i]
|
||||
for order_i, load_str in load_orders.items():
|
||||
|
||||
if not load_str:
|
||||
key = "vm:id={},{}".format(order_i, item)
|
||||
@ -347,17 +335,16 @@ def guest_flag_check(guest_flag_idx, branch_tag, leaf_tag):
|
||||
# ERR_LIST[key] = "Invalid guest flag"
|
||||
|
||||
|
||||
def uuid_format_check(uuid_lists, item):
|
||||
def uuid_format_check(uuid_dic, item):
|
||||
"""
|
||||
Check uuid
|
||||
:param uuid_lists: list of vm uuid
|
||||
:param uuid_dic: dictionary of vm uuid
|
||||
:param item: vm uuid item in xml
|
||||
:return: None
|
||||
"""
|
||||
uuid_len = 36
|
||||
|
||||
for uuid_i in range(len(uuid_lists)):
|
||||
uuid_str = uuid_lists[uuid_i]
|
||||
for uuid_i, uuid_str in uuid_dic.items():
|
||||
|
||||
if not uuid_str:
|
||||
key = "vm:id={},{}".format(uuid_i, item)
|
||||
@ -374,14 +361,23 @@ def uuid_format_check(uuid_lists, item):
|
||||
ERR_LIST[key] = "VM uuid format unknown"
|
||||
|
||||
|
||||
def cpus_per_vm_check(item):
|
||||
def get_leaf_tag_map(info_file, prime_item, item):
|
||||
"""
|
||||
Check cpu of per vm
|
||||
:param info_file: some configurations in the info file
|
||||
:param prime_item: the prime item in xml file
|
||||
:param item: the item in xml file
|
||||
:return: dictionary which item value could be indexed by vmid
|
||||
"""
|
||||
vmid_item_dic = common.get_leaf_tag_map(info_file, prime_item, item)
|
||||
return vmid_item_dic
|
||||
|
||||
|
||||
def cpus_per_vm_check(id_cpus_per_vm_dic, item):
|
||||
"""
|
||||
Check cpu number of per vm
|
||||
:param item: vm pcpu_id item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "pcpu_ids"
|
||||
id_cpus_per_vm_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key in id_cpus_per_vm_dic.keys():
|
||||
vm_type = get_order_type_by_vmid(id_key)
|
||||
@ -391,14 +387,12 @@ def cpus_per_vm_check(item):
|
||||
ERR_LIST[key] = "VM have no assignment cpus"
|
||||
|
||||
|
||||
def mem_start_hpa_check(item):
|
||||
def mem_start_hpa_check(id_start_hpa_dic, item):
|
||||
"""
|
||||
Check host physical address
|
||||
:param item: vm start_hpa item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check host physical address
|
||||
:param item: vm start_hpa item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "memory"
|
||||
id_start_hpa_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, hpa_str in id_start_hpa_dic.items():
|
||||
hpa_strip_ul = hpa_str.strip('UL')
|
||||
@ -415,14 +409,12 @@ def mem_start_hpa_check(item):
|
||||
ERR_LIST[key] = "Address should be Hex format"
|
||||
|
||||
|
||||
def mem_size_check(item):
|
||||
def mem_size_check(id_hpa_size_dic, item):
|
||||
"""
|
||||
Check host physical size
|
||||
:param item: vm size item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check host physical size
|
||||
:param item: vm size item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "memory"
|
||||
id_hpa_size_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, hpa_size in id_hpa_size_dic.items():
|
||||
hpa_sz_strip_ul = hpa_size.strip('UL')
|
||||
@ -443,14 +435,12 @@ def mem_size_check(item):
|
||||
ERR_LIST[key] = "Mem size should less than 2GB"
|
||||
|
||||
|
||||
def os_kern_name_check(item):
|
||||
def os_kern_name_check(id_kern_name_dic, item):
|
||||
"""
|
||||
Check os kernel name
|
||||
:param item: vm os config name item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel name
|
||||
:param item: vm os config name item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_name_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_name in id_kern_name_dic.items():
|
||||
if len(kern_name) > 32 or len(kern_name) == 0:
|
||||
@ -458,14 +448,12 @@ def os_kern_name_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel name length should be in range [1,32] bytes"
|
||||
|
||||
|
||||
def os_kern_type_check(item):
|
||||
def os_kern_type_check(id_kern_type_dic, item):
|
||||
"""
|
||||
Check os kernel type
|
||||
:param item: vm os config type item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel type
|
||||
:param item: vm os config type item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_type_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_type in id_kern_type_dic.items():
|
||||
|
||||
@ -479,14 +467,12 @@ def os_kern_type_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel type unknown"
|
||||
|
||||
|
||||
def os_kern_mod_check(item):
|
||||
def os_kern_mod_check(id_kern_mod_dic, item):
|
||||
"""
|
||||
Check os kernel mod
|
||||
:param item: vm os config mod item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel mod
|
||||
:param item: vm os config mod item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_mod_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_mod in id_kern_mod_dic.items():
|
||||
if len(kern_mod) > 32 or len(kern_mod) == 0:
|
||||
@ -494,14 +480,12 @@ def os_kern_mod_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel mod tag should be in range [1,32] bytes"
|
||||
|
||||
|
||||
def os_kern_args_check(item):
|
||||
def os_kern_args_check(id_kern_args_dic, item):
|
||||
"""
|
||||
Check os kernel args
|
||||
:param item: vm os config args item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel args
|
||||
:param item: vm os config args item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_args_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_args in id_kern_args_dic.items():
|
||||
vm_type = get_order_type_by_vmid(id_key)
|
||||
@ -511,14 +495,12 @@ def os_kern_args_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel service os should be SOS_VM_BOOTARGS"
|
||||
|
||||
|
||||
def os_kern_console_check(item):
|
||||
def os_kern_console_check(id_kern_console_dic, item):
|
||||
"""
|
||||
Check os kernel console
|
||||
:param item: vm os config console item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel console
|
||||
:param item: vm os config console item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_console_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_console in id_kern_console_dic.items():
|
||||
if kern_console and "ttyS" not in kern_console:
|
||||
@ -526,14 +508,12 @@ def os_kern_console_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel console should be ttyS[0..3]"
|
||||
|
||||
|
||||
def os_kern_load_addr_check(item):
|
||||
def os_kern_load_addr_check(id_kern_load_addr_dic, item):
|
||||
"""
|
||||
Check os kernel load address
|
||||
:param item: vm os config load address item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel load address
|
||||
:param item: vm os config load address item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_load_addr_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_load_addr in id_kern_load_addr_dic.items():
|
||||
|
||||
@ -547,14 +527,12 @@ def os_kern_load_addr_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel load address should Hex format"
|
||||
|
||||
|
||||
def os_kern_entry_addr_check(item):
|
||||
def os_kern_entry_addr_check(id_kern_entry_addr_dic, item):
|
||||
"""
|
||||
Check os kernel entry address
|
||||
:param item: vm os config entry address item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel entry address
|
||||
:param item: vm os config entry address item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_entry_addr_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_entry_addr in id_kern_entry_addr_dic.items():
|
||||
|
||||
@ -568,14 +546,12 @@ def os_kern_entry_addr_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel entry address should Hex format"
|
||||
|
||||
|
||||
def os_kern_root_dev_check(item):
|
||||
def os_kern_root_dev_check(id_kern_rootdev_dic, item):
|
||||
"""
|
||||
Check os kernel rootfs partitions
|
||||
:param item: vm os config rootdev item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check os kernel rootfs partitions
|
||||
:param item: vm os config rootdev item in xml
|
||||
:return: None
|
||||
"""
|
||||
prime_item = "os_config"
|
||||
id_kern_rootdev_dic = common.get_leaf_tag_map(SCENARIO_INFO_FILE, prime_item, item)
|
||||
|
||||
for id_key, kern_rootdev in id_kern_rootdev_dic.items():
|
||||
if not kern_rootdev:
|
||||
@ -583,13 +559,22 @@ def os_kern_root_dev_check(item):
|
||||
ERR_LIST[key] = "VM os config kernel root device should not empty"
|
||||
|
||||
|
||||
def pci_dev_num_check(item):
|
||||
def get_branch_tag_map(info_file, item):
|
||||
"""
|
||||
:param info_file: some configurations in the info file
|
||||
:param item: the item in xml file
|
||||
:return: dictionary which item value could be indexed by vmid
|
||||
"""
|
||||
vmid_item_dic = common.get_branch_tag_map(info_file, item)
|
||||
return vmid_item_dic
|
||||
|
||||
|
||||
def pci_dev_num_check(id_dev_num_dic, item):
|
||||
"""
|
||||
Check vm pci device number
|
||||
:param item: vm pci_dev_num item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check vm pci device number
|
||||
:param item: vm pci_dev_num item in xml
|
||||
:return: None
|
||||
"""
|
||||
id_dev_num_dic = common.get_branch_tag_map(SCENARIO_INFO_FILE, item)
|
||||
|
||||
for id_key, pci_dev_num in id_dev_num_dic.items():
|
||||
|
||||
@ -599,13 +584,12 @@ def pci_dev_num_check(item):
|
||||
key = "vm:id={},{}".format(id_key, item)
|
||||
ERR_LIST[key] = "VM pci device number shoud be one of {}".format(PCI_DEV_NUM_LIST)
|
||||
|
||||
def pci_devs_check(item):
|
||||
def pci_devs_check(id_devs_dic, item):
|
||||
"""
|
||||
Check vm pci devices
|
||||
:param item: vm pci_devs item in xml
|
||||
:return: None
|
||||
"""
|
||||
Check vm pci devices
|
||||
:param item: vm pci_devs item in xml
|
||||
:return: None
|
||||
"""
|
||||
id_devs_dic = common.get_branch_tag_map(SCENARIO_INFO_FILE, item)
|
||||
|
||||
for id_key, pci_dev in id_devs_dic.items():
|
||||
|
||||
@ -748,40 +732,6 @@ def avl_vuart_ui_select(scenario_info):
|
||||
return tmp_vuart
|
||||
|
||||
|
||||
def vmid_map_epc(config_file, tag, item):
|
||||
"""
|
||||
This is mapping table for {id:item}
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:param item: the item in xml file
|
||||
:return: table of id:item type dictionary
|
||||
"""
|
||||
epc_order = {}
|
||||
vm_cnt = VM_COUNT
|
||||
|
||||
item_list = common.get_leaf_tag_val(config_file, tag, item)
|
||||
load_type_list = common.get_branch_tag_val(config_file, "load_order")
|
||||
|
||||
if 'SOS_VM' in load_type_list:
|
||||
vm_cnt = VM_COUNT - 1
|
||||
for i in range(vm_cnt):
|
||||
epc_order[i] = item_list[i]
|
||||
|
||||
return epc_order
|
||||
|
||||
|
||||
def get_epc_base(scenario_info):
|
||||
|
||||
base_dic = {}
|
||||
base_dic = vmid_map_epc(scenario_info, "epc_section", "base")
|
||||
return base_dic
|
||||
|
||||
|
||||
def get_epc_size(scenario_info):
|
||||
|
||||
size_dic = {}
|
||||
size_dic = vmid_map_epc(scenario_info, "epc_section", "size")
|
||||
return size_dic
|
||||
|
||||
def get_first_post_vm():
|
||||
|
||||
for i in range(VM_COUNT):
|
||||
|
@ -67,15 +67,15 @@ class HwInfo:
|
||||
|
||||
class CfgOsKern:
|
||||
""" This is Abstract of class of configuration of vm os kernel setting """
|
||||
kern_name = []
|
||||
kern_type = []
|
||||
kern_mod = []
|
||||
kern_args = []
|
||||
kern_console = []
|
||||
kern_load_addr = []
|
||||
kern_entry_addr = []
|
||||
kern_root_dev = []
|
||||
kern_args_append = []
|
||||
kern_name = {}
|
||||
kern_type = {}
|
||||
kern_mod = {}
|
||||
kern_args = {}
|
||||
kern_console = {}
|
||||
kern_load_addr = {}
|
||||
kern_entry_addr = {}
|
||||
kern_root_dev = {}
|
||||
kern_args_append = {}
|
||||
|
||||
def __init__(self, scenario_file):
|
||||
self.scenario_info = scenario_file
|
||||
@ -85,38 +85,37 @@ class CfgOsKern:
|
||||
Get all items which belong to this class
|
||||
:return: None
|
||||
"""
|
||||
self.kern_name = scenario_cfg_lib.get_sub_leaf_tag(self.scenario_info, "os_config", "name")
|
||||
self.kern_type = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_name = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "os_config", "name")
|
||||
self.kern_type = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "kern_type")
|
||||
self.kern_mod = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_mod = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "kern_mod")
|
||||
self.kern_args = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_args = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "bootargs")
|
||||
self.kern_console = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_console = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "console")
|
||||
self.kern_load_addr = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_load_addr = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "kern_load_addr")
|
||||
self.kern_entry_addr = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_entry_addr = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "kern_entry_addr")
|
||||
self.kern_root_dev = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_root_dev = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "rootfs")
|
||||
self.kern_args_append = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.kern_args_append = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "boot_private", "bootargs")
|
||||
|
||||
@staticmethod
|
||||
def check_item():
|
||||
def check_item(self):
|
||||
"""
|
||||
Check all items in this class
|
||||
:return: None
|
||||
"""
|
||||
scenario_cfg_lib.os_kern_name_check("name")
|
||||
scenario_cfg_lib.os_kern_type_check("kern_type")
|
||||
scenario_cfg_lib.os_kern_mod_check("kern_mod")
|
||||
scenario_cfg_lib.os_kern_args_check("kern_args")
|
||||
scenario_cfg_lib.os_kern_console_check("console")
|
||||
scenario_cfg_lib.os_kern_load_addr_check("kern_load_addr")
|
||||
scenario_cfg_lib.os_kern_entry_addr_check("kern_entry_addr")
|
||||
scenario_cfg_lib.os_kern_root_dev_check("rootdev")
|
||||
scenario_cfg_lib.os_kern_name_check(self.kern_name, "name")
|
||||
scenario_cfg_lib.os_kern_type_check(self.kern_type, "kern_type")
|
||||
scenario_cfg_lib.os_kern_mod_check(self.kern_mod, "kern_mod")
|
||||
scenario_cfg_lib.os_kern_args_check(self.kern_args, "kern_args")
|
||||
scenario_cfg_lib.os_kern_console_check(self.kern_console, "console")
|
||||
scenario_cfg_lib.os_kern_load_addr_check(self.kern_load_addr, "kern_load_addr")
|
||||
scenario_cfg_lib.os_kern_entry_addr_check(self.kern_entry_addr, "kern_entry_addr")
|
||||
scenario_cfg_lib.os_kern_root_dev_check(self.kern_root_dev, "rootdev")
|
||||
|
||||
|
||||
class VuartTarget:
|
||||
@ -175,8 +174,8 @@ class VuartInfo:
|
||||
|
||||
class MemInfo:
|
||||
""" This is Abstract of class of memory setting information """
|
||||
mem_start_hpa = []
|
||||
mem_size = []
|
||||
mem_start_hpa = {}
|
||||
mem_size = {}
|
||||
|
||||
def __init__(self, scenario_file):
|
||||
self.scenario_info = scenario_file
|
||||
@ -186,25 +185,24 @@ class MemInfo:
|
||||
Get all items which belong to this class
|
||||
:return: None
|
||||
"""
|
||||
self.mem_start_hpa = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.mem_start_hpa = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "memory", "start_hpa")
|
||||
self.mem_size = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.mem_size = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "memory", "size")
|
||||
|
||||
@staticmethod
|
||||
def check_item():
|
||||
def check_item(self):
|
||||
"""
|
||||
Check all items in this class
|
||||
:return: None
|
||||
"""
|
||||
scenario_cfg_lib.mem_start_hpa_check("start_hpa")
|
||||
scenario_cfg_lib.mem_size_check("size")
|
||||
scenario_cfg_lib.mem_start_hpa_check(self.mem_start_hpa, "start_hpa")
|
||||
scenario_cfg_lib.mem_size_check(self.mem_size, "size")
|
||||
|
||||
|
||||
class CfgPci:
|
||||
""" This is Abstract of class of PCi devices setting information """
|
||||
pci_dev_num = []
|
||||
pci_devs = []
|
||||
pci_dev_num = {}
|
||||
pci_devs = {}
|
||||
|
||||
def __init__(self, scenario_file):
|
||||
self.scenario_info = scenario_file
|
||||
@ -214,14 +212,14 @@ class CfgPci:
|
||||
Get pci device number items
|
||||
:return: None
|
||||
"""
|
||||
self.pci_dev_num = scenario_cfg_lib.get_sub_tree_tag(self.scenario_info, "pci_dev_num")
|
||||
self.pci_dev_num = scenario_cfg_lib.get_branch_tag_map(self.scenario_info, "pci_dev_num")
|
||||
|
||||
def get_pci_devs(self):
|
||||
"""
|
||||
Get pci devices items
|
||||
:return: None
|
||||
"""
|
||||
self.pci_devs = scenario_cfg_lib.get_sub_tree_tag(self.scenario_info, "pci_devs")
|
||||
self.pci_devs = scenario_cfg_lib.get_branch_tag_map(self.scenario_info, "pci_devs")
|
||||
|
||||
def get_info(self):
|
||||
"""
|
||||
@ -231,13 +229,12 @@ class CfgPci:
|
||||
self.get_pci_dev_num()
|
||||
self.get_pci_devs()
|
||||
|
||||
@staticmethod
|
||||
def check_item():
|
||||
def check_item(self):
|
||||
""" Check all items in this class
|
||||
:return: None
|
||||
"""
|
||||
scenario_cfg_lib.pci_dev_num_check("pci_dev_num")
|
||||
scenario_cfg_lib.pci_devs_check("pci_devs")
|
||||
scenario_cfg_lib.pci_dev_num_check(self.pci_dev_num, "pci_dev_num")
|
||||
scenario_cfg_lib.pci_devs_check(self.pci_devs, "pci_devs")
|
||||
|
||||
|
||||
class EpcSection:
|
||||
@ -248,18 +245,18 @@ class EpcSection:
|
||||
self.scenario_info = scenario_info
|
||||
|
||||
def get_info(self):
|
||||
self.base = scenario_cfg_lib.get_epc_base(self.scenario_info)
|
||||
self.size = scenario_cfg_lib.get_epc_size(self.scenario_info)
|
||||
self.base = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "epc_section", "base")
|
||||
self.size = scenario_cfg_lib.get_leaf_tag_map(self.scenario_info, "epc_section", "size")
|
||||
|
||||
|
||||
class VmInfo:
|
||||
""" This is Abstract of class of VM setting """
|
||||
name = []
|
||||
load_order = []
|
||||
uuid = []
|
||||
clos_set = []
|
||||
guest_flag_idx = []
|
||||
cpus_per_vm = []
|
||||
name = {}
|
||||
load_order = {}
|
||||
uuid = {}
|
||||
clos_set = {}
|
||||
guest_flag_idx = {}
|
||||
cpus_per_vm = {}
|
||||
|
||||
def __init__(self, board_file, scenario_file):
|
||||
self.board_info = board_file
|
||||
@ -277,14 +274,14 @@ class VmInfo:
|
||||
Get all items which belong to this class
|
||||
:return: None
|
||||
"""
|
||||
self.name = scenario_cfg_lib.get_sub_tree_tag(self.scenario_info, "name")
|
||||
self.load_order = scenario_cfg_lib.get_sub_tree_tag(self.scenario_info, "load_order")
|
||||
self.uuid = scenario_cfg_lib.get_sub_tree_tag(self.scenario_info, "uuid")
|
||||
self.name = scenario_cfg_lib.get_branch_tag_map(self.scenario_info, "name")
|
||||
self.load_order = scenario_cfg_lib.get_branch_tag_map(self.scenario_info, "load_order")
|
||||
self.uuid = scenario_cfg_lib.get_branch_tag_map(self.scenario_info, "uuid")
|
||||
self.guest_flag_idx = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.scenario_info, "guest_flags", "guest_flag")
|
||||
self.cpus_per_vm = scenario_cfg_lib.get_sub_leaf_tag(
|
||||
self.cpus_per_vm = scenario_cfg_lib.get_leaf_tag_map(
|
||||
self.scenario_info, "pcpu_ids", "pcpu_id")
|
||||
self.clos_set = scenario_cfg_lib.get_sub_tree_tag(self.scenario_info, "clos")
|
||||
self.clos_set = scenario_cfg_lib.get_branch_tag_map(self.scenario_info, "clos")
|
||||
self.epc_section.get_info()
|
||||
self.mem_info.get_info()
|
||||
self.os_cfg.get_info()
|
||||
@ -307,7 +304,7 @@ class VmInfo:
|
||||
scenario_cfg_lib.load_order_check(self.load_order, "load_order")
|
||||
scenario_cfg_lib.uuid_format_check(self.uuid, "uuid")
|
||||
scenario_cfg_lib.guest_flag_check(self.guest_flag_idx, "guest_flags", "guest_flag")
|
||||
scenario_cfg_lib.cpus_per_vm_check("pcpu_id")
|
||||
scenario_cfg_lib.cpus_per_vm_check(self.cpus_per_vm, "pcpu_id")
|
||||
|
||||
self.mem_info.check_item()
|
||||
self.os_cfg.check_item()
|
||||
|
@ -124,23 +124,28 @@ def vuart_output(i, vm_info, config):
|
||||
print("\t\t},", file=config)
|
||||
|
||||
# pci_dev_num/pci_devs only for SOS_VM or logical_partition pre_launched_vm
|
||||
if vm_type == "SOS_VM":
|
||||
print("\t\t.pci_dev_num = {},".format(vm_info.cfg_pci.pci_dev_num[0]), file=config)
|
||||
print("\t\t.pci_devs = {},".format(vm_info.cfg_pci.pci_devs[0]), file=config)
|
||||
if vm_type == "SOS_VM" or vm_type == "PRE_LAUNCHED_VM":
|
||||
if vm_info.cfg_pci.pci_dev_num[i] and vm_info.cfg_pci.pci_dev_num[i] != None:
|
||||
print("\t\t.pci_dev_num = {},".format(vm_info.cfg_pci.pci_dev_num[i]), file=config)
|
||||
if vm_info.cfg_pci.pci_devs[i] and vm_info.cfg_pci.pci_devs[i] != None:
|
||||
print("\t\t.pci_devs = {},".format(vm_info.cfg_pci.pci_devs[i]), file=config)
|
||||
|
||||
(err_dic, scenario_name) = scenario_cfg_lib.get_scenario_name()
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
if scenario_name == "logical_partition":
|
||||
print("\t\t.pci_dev_num = VM{}_CONFIG_PCI_DEV_NUM,".format(i), file=config)
|
||||
print("\t\t.pci_devs = vm{}_pci_devs,".format(i), file=config)
|
||||
print("\t},", file=config)
|
||||
|
||||
return err_dic
|
||||
|
||||
|
||||
def is_need_epc(epc_section, i, config):
|
||||
"""
|
||||
Check if it is need epc section
|
||||
:param epc_section: struct epc_scectoin conatins base/size
|
||||
:param i: the index of vm id
|
||||
:param config: it is file pointer to store the information
|
||||
:return: None
|
||||
"""
|
||||
# SOS_VM have not set epc section
|
||||
vm_type = scenario_cfg_lib.get_order_type_by_vmid(i)
|
||||
if vm_type == "SOS_VM":
|
||||
return
|
||||
|
||||
if epc_section.base[i] == '0' and epc_section.size[i] == '0':
|
||||
return
|
||||
else:
|
||||
@ -149,6 +154,7 @@ def is_need_epc(epc_section, i, config):
|
||||
print('\t\t\t.size = {0},'.format(epc_section.size), file=config)
|
||||
print("\t\t},", file=config)
|
||||
|
||||
|
||||
def get_guest_flag(flag_index):
|
||||
"""
|
||||
This is get flag index list
|
||||
@ -242,7 +248,7 @@ def gen_sdc_source(vm_info, config):
|
||||
print("\t\t.load_order = {0},".format(vm_info.load_order[1]), file=config)
|
||||
# UUID
|
||||
uuid_output(uuid_1, vm_info.uuid[1], config)
|
||||
is_need_epc(vm_info.epc_section, 0, config)
|
||||
is_need_epc(vm_info.epc_section, 1, config)
|
||||
# VUART
|
||||
err_dic = vuart_output(1, vm_info, config)
|
||||
if err_dic:
|
||||
@ -252,7 +258,7 @@ def gen_sdc_source(vm_info, config):
|
||||
print("\t{", file=config)
|
||||
print("\t\t.load_order = POST_LAUNCHED_VM,", file=config)
|
||||
uuid_output(uuid_2, vm_info.uuid[2], config)
|
||||
is_need_epc(vm_info.epc_section, 1, config)
|
||||
is_need_epc(vm_info.epc_section, 2, config)
|
||||
print("\t\t.vuart[0] = {", file=config)
|
||||
print("\t\t\t.type = VUART_LEGACY_PIO,", file=config)
|
||||
print("\t\t\t.addr.port_base = INVALID_COM_BASE,", file=config)
|
||||
@ -323,7 +329,7 @@ def gen_sdc2_source(vm_info, config):
|
||||
print("\t\t.load_order = {0},".format(vm_info.load_order[1]), file=config)
|
||||
# UUID
|
||||
uuid_output(uuid_1, vm_info.uuid[1], config)
|
||||
is_need_epc(vm_info.epc_section, 0, config)
|
||||
is_need_epc(vm_info.epc_section, 1, config)
|
||||
# VUART
|
||||
err_dic = vuart_output(1, vm_info, config)
|
||||
if err_dic:
|
||||
@ -334,7 +340,7 @@ def gen_sdc2_source(vm_info, config):
|
||||
print("\t\t.load_order = {0},".format(vm_info.load_order[1]), file=config)
|
||||
# UUID
|
||||
uuid_output(uuid_2, vm_info.uuid[2], config)
|
||||
is_need_epc(vm_info.epc_section, 1, config)
|
||||
is_need_epc(vm_info.epc_section, 2, config)
|
||||
# VUART
|
||||
err_dic = vuart_output(1, vm_info, config)
|
||||
if err_dic:
|
||||
@ -345,7 +351,7 @@ def gen_sdc2_source(vm_info, config):
|
||||
print("\t{", file=config)
|
||||
print("\t\t.load_order = POST_LAUNCHED_VM,", file=config)
|
||||
uuid_output(uuid_3, vm_info.uuid[3], config)
|
||||
is_need_epc(vm_info.epc_section, 2, config)
|
||||
is_need_epc(vm_info.epc_section, 3, config)
|
||||
print("\t\t.vuart[0] = {", file=config)
|
||||
print("\t\t\t.type = VUART_LEGACY_PIO,", file=config)
|
||||
print("\t\t\t.addr.port_base = INVALID_COM_BASE,", file=config)
|
||||
@ -466,8 +472,7 @@ def gen_industry_source(vm_info, config):
|
||||
|
||||
# UUID
|
||||
uuid_output(uuid, vm_info.uuid[i], config)
|
||||
if i != 0:
|
||||
is_need_epc(vm_info.epc_section, i - 1, config)
|
||||
is_need_epc(vm_info.epc_section, i, config)
|
||||
|
||||
if i == 0:
|
||||
(err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flag_idx[i])
|
||||
@ -553,10 +558,7 @@ def gen_hybrid_source(vm_info, config):
|
||||
print("\t\t\t.start_hpa = 0UL,", file=config)
|
||||
print("\t\t\t.size = CONFIG_SOS_RAM_SIZE,", file=config)
|
||||
print("\t\t},", file=config)
|
||||
if i == 0:
|
||||
is_need_epc(vm_info.epc_section, i, config)
|
||||
elif i == scenario_cfg_lib.VM_COUNT:
|
||||
is_need_epc(vm_info.epc_section, i - 1, config)
|
||||
is_need_epc(vm_info.epc_section, i, config)
|
||||
print("\t\t.os_config = {", file=config)
|
||||
print('\t\t\t.name = "{0}",'.format(vm_info.os_cfg.kern_name[i]), file=config)
|
||||
print('\t\t\t.kernel_type = {0},'.format(
|
||||
|
@ -38,6 +38,8 @@
|
||||
<target_vm_id desc="COM2 is used for VM communications. When it is enabled, please specify which target VM that current VM connect to.">1</target_vm_id>
|
||||
<target_uart_id configurable="0" desc="target vUART ID that vCOM2 connect to">1</target_uart_id>
|
||||
</vuart>
|
||||
<pci_dev_num configurable="0" desc="pci devices number"></pci_dev_num>
|
||||
<pci_devs configurable="0" desc="pci devices list"></pci_devs>
|
||||
</vm>
|
||||
<vm id="1">
|
||||
<load_order desc="Specify the VM by its load order: PRE_LAUNCHED_VM, SOS_VM or POST_LAUNCHED_VM." readonly="true">SOS_VM</load_order>
|
||||
|
@ -38,6 +38,8 @@
|
||||
<target_vm_id desc="COM2 is used for VM communications. When it is enabled, please specify which target VM that current VM connect to.">1</target_vm_id>
|
||||
<target_uart_id configurable="0" desc="target vUART ID that vCOM2 connect to">1</target_uart_id>
|
||||
</vuart>
|
||||
<pci_dev_num configurable="0" desc="pci devices number"></pci_dev_num>
|
||||
<pci_devs configurable="0" desc="pci devices list"></pci_devs>
|
||||
</vm>
|
||||
<vm id="1">
|
||||
<load_order desc="Specify the VM by its load order: PRE_LAUNCHED_VM, SOS_VM or POST_LAUNCHED_VM." readonly="true">SOS_VM</load_order>
|
||||
|
@ -38,6 +38,8 @@
|
||||
<target_vm_id desc="COM2 is used for VM communications. When it is enabled, please specify which target VM that current VM connect to.">1</target_vm_id>
|
||||
<target_uart_id configurable="0" desc="target vUART ID that vCOM2 connect to">1</target_uart_id>
|
||||
</vuart>
|
||||
<pci_dev_num configurable="0" desc="pci devices number"></pci_dev_num>
|
||||
<pci_devs configurable="0" desc="pci devices list"></pci_devs>
|
||||
</vm>
|
||||
<vm id="1">
|
||||
<load_order desc="Specify the VM by its load order: PRE_LAUNCHED_VM, SOS_VM or POST_LAUNCHED_VM." readonly="true">SOS_VM</load_order>
|
||||
|
@ -38,6 +38,8 @@
|
||||
<target_vm_id desc="COM2 is used for VM communications. When it is enabled, please specify which target VM that current VM connect to.">1</target_vm_id>
|
||||
<target_uart_id configurable="0" desc="target vUART ID that vCOM2 connect to">1</target_uart_id>
|
||||
</vuart>
|
||||
<pci_dev_num configurable="0" desc="pci devices number"></pci_dev_num>
|
||||
<pci_devs configurable="0" desc="pci devices list"></pci_devs>
|
||||
</vm>
|
||||
<vm id="1">
|
||||
<load_order desc="Specify the VM by its load order: PRE_LAUNCHED_VM, SOS_VM or POST_LAUNCHED_VM." readonly="true">SOS_VM</load_order>
|
||||
|
@ -38,6 +38,8 @@
|
||||
<target_vm_id desc="COM2 is used for VM communications. When it is enabled, please specify which target VM that current VM connect to.">1</target_vm_id>
|
||||
<target_uart_id configurable="0" desc="target vUART ID that vCOM2 connect to">1</target_uart_id>
|
||||
</vuart>
|
||||
<pci_dev_num configurable="0" desc="pci devices number"></pci_dev_num>
|
||||
<pci_devs configurable="0" desc="pci devices list"></pci_devs>
|
||||
</vm>
|
||||
<vm id="1">
|
||||
<load_order desc="Specify the VM by its load order: PRE_LAUNCHED_VM, SOS_VM or POST_LAUNCHED_VM." readonly="true">SOS_VM</load_order>
|
||||
|
Loading…
Reference in New Issue
Block a user