diff --git a/misc/acrn-config/board_config/board_cfg_gen.py b/misc/acrn-config/board_config/board_cfg_gen.py
index ba8c83e15..73b93b4f9 100755
--- a/misc/acrn-config/board_config/board_cfg_gen.py
+++ b/misc/acrn-config/board_config/board_cfg_gen.py
@@ -40,6 +40,7 @@ def main(args):
common.BOARD_INFO_FILE = params['--board']
common.SCENARIO_INFO_FILE = params['--scenario']
common.get_vm_num(params['--scenario'])
+ common.get_vm_types()
# get board name
(err_dic, board) = common.get_board_name()
diff --git a/misc/acrn-config/board_config/misc_cfg_h.py b/misc/acrn-config/board_config/misc_cfg_h.py
index 8edf63ef6..68f24d9e0 100644
--- a/misc/acrn-config/board_config/misc_cfg_h.py
+++ b/misc/acrn-config/board_config/misc_cfg_h.py
@@ -48,27 +48,18 @@ def sos_bootarg_diff(sos_cmdlines, config):
def parse_boot_info():
err_dic = {}
- vm_types = []
- (err_dic, scenario_name) = common.get_scenario_name()
- if err_dic:
- return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types)
-
- if scenario_name != "logical_partition":
- sos_cmdlines = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "board_private", "bootargs")
- sos_rootfs = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "board_private", "rootfs")
+ if 'SOS_VM' in common.VM_TYPES.values():
+ sos_cmdlines = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "board_private", "bootargs").values())
+ sos_rootfs = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "board_private", "rootfs").values())
(err_dic, vuart0_dic, vuart1_dic) = board_cfg_lib.get_board_private_vuart("board_private", "console")
else:
- sos_cmdlines = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "os_config", "bootargs")
+ sos_cmdlines = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "os_config", "bootargs").values())
- sos_rootfs = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "os_config", "rootfs")
+ sos_rootfs = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "os_config", "rootfs").values())
(err_dic, vuart0_dic, vuart1_dic) = board_cfg_lib.get_board_private_vuart("os_config", "console")
- for i in range(common.VM_COUNT):
- vm_type = board_cfg_lib.get_order_type_by_vmid(i)
- vm_types.append(vm_type)
-
- return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types)
+ return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic)
def find_hi_mmio_window(config):
@@ -129,7 +120,7 @@ def generate_file(config):
return err_dic
# parse sos_bootargs/rootfs/console
- (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types) = parse_boot_info()
+ (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic) = parse_boot_info()
if err_dic:
return err_dic
@@ -176,7 +167,7 @@ def generate_file(config):
# sos rootfs and console
print("", file=config)
- if "SOS_VM" in vm_types:
+ if "SOS_VM" in common.VM_TYPES.values():
print('#define SOS_ROOTFS\t\t"root={} "'.format(sos_rootfs[0]), file=config)
if ttys_n:
print('#define SOS_CONSOLE\t\t"console={} "'.format(ttys_n), file=config)
@@ -185,12 +176,12 @@ def generate_file(config):
# sos com base/irq
i_type = 0
- for vm_type in vm_types:
+ for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == "SOS_VM":
+ i_type = vm_i
break
- i_type += 1
- if "SOS_VM" in vm_types:
+ if "SOS_VM" in common.VM_TYPES.values():
if vuart0_dic:
print("#define SOS_COM1_BASE\t\t{}U".format(vuart0_port_base), file=config)
print("#define SOS_COM1_IRQ\t\t{}U".format(vuart0_irq), file=config)
@@ -204,7 +195,7 @@ def generate_file(config):
# sos boot command line
print("", file=config)
- if "SOS_VM" in vm_types:
+ if "SOS_VM" in common.VM_TYPES.values():
sos_bootarg_diff(sos_cmdlines, config)
# set macro for HIDDEN PTDEVS
diff --git a/misc/acrn-config/hv_config/board_defconfig.py b/misc/acrn-config/hv_config/board_defconfig.py
index f9f914a2d..db28a7c17 100644
--- a/misc/acrn-config/hv_config/board_defconfig.py
+++ b/misc/acrn-config/hv_config/board_defconfig.py
@@ -85,14 +85,10 @@ def get_serial_type():
# Get ttySx information from board config file
ttys_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "", "")
- (err_dic, scenario_name) = common.get_scenario_name()
- if scenario_name == "logical_partition":
- ttyn = 'ttyS0'
- else:
- # Get ttySx from scenario config file which selected by user
- (err_dic, ttyn) = board_cfg_lib.parser_vuart_console()
- if err_dic:
- hv_cfg_lib.ERR_LIST.update(err_dic)
+ # Get ttySx from scenario config file which selected by user
+ (err_dic, ttyn) = board_cfg_lib.parser_vuart_console()
+ if err_dic:
+ hv_cfg_lib.ERR_LIST.update(err_dic)
# query the serial type from board config file
for line in ttys_lines:
@@ -189,7 +185,6 @@ def get_capacities(hv_info, config):
print("CONFIG_MAX_IOAPIC_NUM={}".format(hv_info.cap.max_ioapic_num), file=config)
print("CONFIG_MAX_IR_ENTRIES={}".format(hv_info.cap.max_ir_entries), file=config)
print("CONFIG_MAX_PCI_DEV_NUM={}".format(hv_info.cap.max_pci_dev_num), file=config)
- print("CONFIG_MAX_KATA_VM_NUM={}".format(hv_info.cap.max_kata_vm_num), file=config)
print("CONFIG_MAX_IOAPIC_LINES={}".format(hv_info.cap.max_ioapic_lines), file=config)
print("CONFIG_MAX_PT_IRQ_ENTRIES={}".format(hv_info.cap.max_pt_irq_entries), file=config)
print("CONFIG_MAX_MSIX_TABLE_NUM={}".format(hv_info.cap.max_msix_table_num), file=config)
@@ -219,7 +214,6 @@ def generate_file(hv_info, config):
if hv_info.log.release == 'y':
print("CONFIG_RELEASE=y", file=config)
print('CONFIG_BOARD="{}"'.format(board_name), file=config)
- print("CONFIG_{}=y".format(scenario_name.upper()), file=config)
get_memory(hv_info, config)
get_miscfg(hv_info, config)
diff --git a/misc/acrn-config/launch_config/launch_cfg_gen.py b/misc/acrn-config/launch_config/launch_cfg_gen.py
index 39beff101..244c6acb4 100644
--- a/misc/acrn-config/launch_config/launch_cfg_gen.py
+++ b/misc/acrn-config/launch_config/launch_cfg_gen.py
@@ -164,6 +164,7 @@ def main(args):
common.BOARD_INFO_FILE = board_info_file
common.SCENARIO_INFO_FILE = scenario_info_file
common.LAUNCH_INFO_FILE = launch_info_file
+ common.get_vm_types()
# get post vm dic
post_num_list = launch_cfg_lib.get_post_num_list()
diff --git a/misc/acrn-config/library/board_cfg_lib.py b/misc/acrn-config/library/board_cfg_lib.py
index 3fbf41b71..d7007061d 100644
--- a/misc/acrn-config/library/board_cfg_lib.py
+++ b/misc/acrn-config/library/board_cfg_lib.py
@@ -170,19 +170,6 @@ def clos_info_parser(board_info):
return get_max_clos_mask(board_info)
-def get_order_type_by_vmid(idx):
- """
- This is get pre launched vm count
- :param idx: index of vm id
- :return: vm type of index to vmid
- """
- (err_dic, order_type) = common.get_load_order_by_vmid(common.SCENARIO_INFO_FILE, common.VM_COUNT, idx)
- if err_dic:
- ERR_LIST.update(err_dic)
-
- return order_type
-
-
def get_valid_irq(board_info):
"""
This is get available irq from board info file
@@ -254,8 +241,7 @@ def parser_vuart_console():
3. ttyS2
"""
ttys_n = ''
- (err_dic, scenario_name) = common.get_scenario_name()
-
+ err_dic = {}
ttys = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "DEBUG_OPTIONS", "SERIAL_CONSOLE")
if not ttys or ttys == None:
@@ -345,6 +331,9 @@ def get_vuart_info_id(config_file, idx):
vm_id = 0
root = common.get_config_root(config_file)
for item in root:
+ if item.tag == "vm":
+ vm_id = int(item.attrib['id'])
+
for sub in item:
tmp_vuart = {}
for leaf in sub:
@@ -355,9 +344,6 @@ def get_vuart_info_id(config_file, idx):
if tmp_vuart and sub.tag == "vuart":
tmp_tag[vm_id] = tmp_vuart
- if item.tag == "vm":
- vm_id += 1
-
return tmp_tag
diff --git a/misc/acrn-config/library/common.py b/misc/acrn-config/library/common.py
index 15cd13eed..058b607ed 100644
--- a/misc/acrn-config/library/common.py
+++ b/misc/acrn-config/library/common.py
@@ -31,6 +31,7 @@ VM_COUNT = 0
BOARD_INFO_FILE = ""
SCENARIO_INFO_FILE = ""
LAUNCH_INFO_FILE = ""
+VM_TYPES = {}
class MultiItem():
@@ -204,36 +205,19 @@ def is_config_file_match():
return (err_dic, False)
-def find_index_guest_flag(flag):
+def find_tmp_flag(flag):
"""
Find the index in GUEST_FLAG by flag
:param flag: flag contained by GUEST_FLAG
:return: index of GUEST_FLAG
"""
- if not flag or flag == '0':
- return '0'
+ if flag == None or flag == '0':
+ return '0UL'
- if not flag.isnumeric():
- for i in range(len(GUEST_FLAG)):
- if flag == GUEST_FLAG[i]:
- flag_str = i
- return flag_str
-
-def find_tmp_flag(leaf_text):
- """
- Get flag and append the value
- :param leaf_text: it is a value of guest flag item
- :return: a list of flag or none
- """
- tmp_flag = []
- tmp_flag = find_index_guest_flag(leaf_text)
- #flag_index = find_index_guest_flag(leaf_text)
- #if flag_index == '0':
- # tmp_flag.append(0)
- #else:
- # tmp_flag.append(flag_index)
-
- return tmp_flag
+ flag_str = ''
+ for i in range(len(GUEST_FLAG)):
+ if flag == GUEST_FLAG[i]:
+ return flag_str
def get_config_root(config_file):
@@ -266,67 +250,12 @@ def get_vm_num(config_file):
VM_COUNT = vm_count
-# TODO: This will be abandonment in future
-def get_sub_leaf_tag(config_file, branch_tag, 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 branch_tag: it is key of patter to config file branch tag item
- :param tag_str: it is key of pattern to config file leaf tag item
- :return: value of tag_str item
- """
- tmp_tag = []
- root = get_config_root(config_file)
- for item in root:
- # for each 2th level item
- for sub in item:
- tmp_flag = []
- tmp_cpus = []
- if sub.tag == branch_tag:
- if not tag_str:
- tmp_tag.append(sub.text)
- continue
-
- # for each 3rd level item
- for leaf in sub:
- if leaf.tag == tag_str and tag_str not in MULTI_ITEM and sub.tag != "vuart":
- tmp_tag.append(leaf.text)
- continue
-
- # get guest flag for logical partition vm1
- if leaf.tag == "guest_flag" and tag_str == "guest_flag":
- t_flag = find_tmp_flag(leaf.text)
- tmp_flag.append(t_flag)
- #continue
-
- # get cpu for vm
- if leaf.tag == "pcpu_id" and tag_str == "pcpu_id":
- tmp_cpus.append(leaf.text)
- continue
-
- # get vcpu_clos for vm
- if leaf.tag == "vcpu_clos" and tag_str == "vcpu_clos":
- tmp_cpus.append(leaf.text)
- continue
-
- # append guest flags for each vm
- if tmp_flag and tag_str == "guest_flag":
- tmp_tag.append(tmp_flag)
- continue
-
- # append cpus for vm
- if tmp_cpus and tag_str == "pcpu_id":
- tmp_tag.append(tmp_cpus)
- continue
-
- return tmp_tag
-
-
def get_leaf_value(tmp, tag_str, leaf):
# get guest flag for logical partition vm1
if leaf.tag == "guest_flag" and tag_str == "guest_flag":
t_flag = find_tmp_flag(leaf.text)
+ #print("--debug: tag:{},{}".format(tag_str), t_flag)
tmp.multi.guest_flag.append(t_flag)
# get cpu for vm
@@ -355,7 +284,6 @@ def get_sub_value(tmp, tag_str, vm_id):
# append guest flags for each vm
if tmp.multi.guest_flag and tag_str == "guest_flag":
tmp.tag[vm_id] = tmp.multi.guest_flag
- tmp.tag.append(tmp.multi.guest_flag)
# append cpus for vm
if tmp.multi.pcpu_id and tag_str == "pcpu_id":
@@ -442,37 +370,6 @@ def get_hv_item_tag(config_file, branch_tag, tag_str=''):
return tmp
-def order_type_map_vmid(config_file, vm_count):
- """
- This is mapping table for {id:order type}
- :param config_file: it is a file what contains information for script to read from
- :param vm_count: vm number
- :return: table of id:order type dictionary
- """
- order_id_dic = {}
- load_type_list = get_sub_leaf_tag(config_file, "load_order")
- for i in range(vm_count):
- order_id_dic[i] = load_type_list[i]
-
- return order_id_dic
-
-
-def get_load_order_by_vmid(config_file, vm_count, idx):
- """
- Get load order by vm id
- :param config_file: it is a file what contains information for script to read from
- :param vm_count: vm number
- :param idx: index of vm id
- :return: table of id:order type dictionary
- """
- err_dic = {}
- order_id_dic = order_type_map_vmid(config_file, vm_count)
- if idx >= vm_count or not order_id_dic:
- err_dic['vm number: failue'] = "Toatal vm number is less than index number"
-
- return (err_dic, order_id_dic[idx])
-
-
def undline_name(name):
"""
This convert name which has contain '-' to '_'
@@ -519,3 +416,8 @@ def num2int(str_value):
val = int(str_value, 16)
return val
+
+
+def get_vm_types():
+ global VM_TYPES
+ VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "load_order")
diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py
index 18a021461..82cb7cb90 100644
--- a/misc/acrn-config/library/launch_cfg_lib.py
+++ b/misc/acrn-config/library/launch_cfg_lib.py
@@ -166,9 +166,8 @@ def post_vm_cnt(config_file):
:return: number of post launched vm
"""
post_launch_cnt = 0
- load_type_list = common.get_sub_leaf_tag(config_file, "load_order")
- for vm_type in load_type_list:
+ for vm_type in common.VM_TYPES.values():
if vm_type == "POST_LAUNCHED_VM":
post_launch_cnt += 1
diff --git a/misc/acrn-config/library/scenario_cfg_lib.py b/misc/acrn-config/library/scenario_cfg_lib.py
index 1bf2ed8ef..f4fa3f377 100644
--- a/misc/acrn-config/library/scenario_cfg_lib.py
+++ b/misc/acrn-config/library/scenario_cfg_lib.py
@@ -14,7 +14,6 @@ START_HPA_LIST = ['0', '0x100000000', '0x120000000']
KERN_TYPE_LIST = ['KERNEL_BZIMAGE', 'KERNEL_ZEPHYR']
KERN_BOOT_ADDR_LIST = ['0x100000']
-GUEST_FLAG = common.GUEST_FLAG
VM_SEVERITY = ['SEVERITY_SAFETY_VM', 'SEVERITY_RTVM', 'SEVERITY_SOS', 'SEVERITY_STANDARD_VM']
VUART_TYPE = ['VUART_LEGACY_PIO', 'VUART_PCI']
VUART_BASE = ['SOS_COM1_BASE', 'SOS_COM2_BASE', 'COM1_BASE',
@@ -36,60 +35,25 @@ COMMUNICATE_VM_ID = []
ERR_LIST = {}
-DEFAULT_VM_COUNT = {
- 'sdc':2,
- 'sdc2':4,
- 'industry':3,
- 'hybrid':3,
- 'logical_partition':2,
-}
KATA_VM_COUNT = 0
-def get_board_private_info(config_file):
-
- (err_dic, scenario_name) = common.get_scenario_name()
-
- if scenario_name == "logical_partition":
- branch_tag = "os_config"
- else:
- branch_tag = "board_private"
-
- private_info = {}
- dev_private_tags = ['rootfs', 'console']
- for tag_str in dev_private_tags:
- dev_setting = common.get_sub_leaf_tag(config_file, branch_tag, tag_str)
- if not dev_setting and tag_str == "console":
- continue
-
- private_info[tag_str] = dev_setting
-
- return (err_dic, private_info)
-
-
def check_board_private_info():
- (err_dic, private_info) = get_board_private_info(common.SCENARIO_INFO_FILE)
+ if 'SOS_VM' not in common.VM_TYPES.values():
+ return
+ branch_tag = "board_private"
+ private_info = {}
+ dev_private_tags = ['rootfs']
+ for tag_str in dev_private_tags:
+ dev_setting = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, branch_tag, tag_str)
+ private_info[tag_str] = dev_setting
if not private_info['rootfs'] and err_dic:
ERR_LIST['vm:id=0,boot_private,rootfs'] = "The board have to chose one rootfs partition"
ERR_LIST.update(err_dic)
-def get_order_type_by_vmid(idx):
- """
- Get load order by vm id
-
- :param idx: index of vm id
- :return: load order type of index to vmid
- """
- (err_dic, order_type) = common.get_load_order_by_vmid(common.SCENARIO_INFO_FILE, common.VM_COUNT, idx)
- if err_dic:
- ERR_LIST.update(err_dic)
-
- return order_type
-
-
def vm_name_check(vm_names, item):
"""
Check vm name
@@ -163,24 +127,13 @@ def get_load_order_cnt(load_orders, type_name):
return type_cnt
-def guest_flag_check(guest_flag_idx, branch_tag, leaf_tag):
+def guest_flag_check(guest_flags, branch_tag, leaf_tag):
- guest_flag_len = len(common.GUEST_FLAG)
- guest_num = len(guest_flag_idx)
-
- for vm_i in range(guest_num):
- flag_len = len(guest_flag_idx[vm_i])
- if flag_len <= guest_flag_len:
- continue
- else:
- key = "vm:id={},{},{}".format(vm_i, branch_tag, leaf_tag)
- ERR_LIST[key] = "Unknow guest flag"
- # for flag_i in range(flag_len):
- # if guest_flag_idx[vm_i][flag_i] in common.GUEST_FLAG:
- # continue
- # else:
- # key = "vm:id={},{},{}".format(vm_i, branch_tag, leaf_tag)
- # ERR_LIST[key] = "Invalid guest flag"
+ for vm_i, flags in guest_flags.items():
+ for guest_flag in flags:
+ if guest_flag and guest_flag not in common.GUEST_FLAG:
+ key = "vm:id={},{},{}".format(vm_i, branch_tag, leaf_tag)
+ ERR_LIST[key] = "Unknow guest flag"
def uuid_format_check(uuid_dic, item):
@@ -215,13 +168,19 @@ def cpus_per_vm_check(id_cpus_per_vm_dic, item):
:param item: vm pcpu_id item in xml
:return: None
"""
+ for vm_i, vm_type in common.VM_TYPES.items():
+ if vm_i not in id_cpus_per_vm_dic.keys() and vm_type == "SOS_VM":
+ continue
+ elif vm_i not in id_cpus_per_vm_dic.keys() and vm_type in ("PRE_LAUNCHED_VM", "POST_LAUNCHED"):
+ key = "vm:id={},{}".format(vm_i, item)
+ ERR_LIST[key] = "Pre launched_vm and Post launched vm should have cpus assignment"
+ return
- for id_key in id_cpus_per_vm_dic.keys():
- vm_type = get_order_type_by_vmid(id_key)
- cpus_vm_i = id_cpus_per_vm_dic[id_key]
- if not cpus_vm_i and vm_type == "PRE_LAUNCHED_VM":
- key = "vm:id={},{}".format(id_key, item)
- ERR_LIST[key] = "VM have no assignment cpus"
+ cpus_vm_i = id_cpus_per_vm_dic[vm_i]
+ if not cpus_vm_i:
+ key = "vm:id={},{}".format(vm_i, item)
+ ERR_LIST[key] = "{} VM have no assignment cpus".format(vm_type)
+ return
def mem_start_hpa_check(id_start_hpa_dic, prime_item, item):
@@ -327,11 +286,12 @@ def os_kern_args_check(id_kern_args_dic, prime_item, item):
:return: None
"""
- for id_key, kern_args in id_kern_args_dic.items():
- vm_type = get_order_type_by_vmid(id_key)
-
+ for vm_i,vm_type in common.VM_TYPES.items():
+ if vm_i not in id_kern_args_dic.keys():
+ continue
+ kern_args = id_kern_args_dic[vm_i]
if vm_type == "SOS_VM" and kern_args != "SOS_VM_BOOTARGS":
- key = "vm:id={},{},{}".format(id_key, prime_item, item)
+ key = "vm:id={},{},{}".format(vm_i, prime_item, item)
ERR_LIST[key] = "VM os config kernel service os should be SOS_VM_BOOTARGS"
@@ -409,12 +369,13 @@ def pci_dev_num_check(id_dev_num_dic, item):
:return: None
"""
- for id_key, pci_dev_num in id_dev_num_dic.items():
-
- vm_type = get_order_type_by_vmid(id_key)
+ for vm_i,vm_type in common.VM_TYPES.items():
+ if vm_i not in id_dev_num_dic.keys():
+ continue
+ pci_dev_num = id_dev_num_dic[vm_i]
if vm_type != "POST_LAUNCHED_VM" and pci_dev_num:
if pci_dev_num not in PCI_DEV_NUM_LIST:
- key = "vm:id={},{}".format(id_key, item)
+ key = "vm:id={},{}".format(vm_i, item)
ERR_LIST[key] = "VM pci device number shoud be one of {}".format(PCI_DEV_NUM_LIST)
def pci_devs_check(id_devs_dic, item):
@@ -424,12 +385,13 @@ def pci_devs_check(id_devs_dic, item):
:return: None
"""
- for id_key, pci_dev in id_devs_dic.items():
-
- vm_type = get_order_type_by_vmid(id_key)
+ for vm_i,vm_type in common.VM_TYPES.items():
+ if vm_i not in id_devs_dic.keys():
+ continue
+ pci_dev = id_devs_dic[vm_i]
if vm_type != "POST_LAUNCHED_VM" and pci_dev:
if pci_dev not in PCI_DEVS_LIST:
- key = "vm:id={},{}".format(id_key, item)
+ key = "vm:id={},{}".format(vm_i, item)
ERR_LIST[key] = "VM pci device shoud be one of {}".format(PCI_DEVS_LIST)
@@ -440,7 +402,7 @@ def get_vuart1_vmid(vm_vuart1):
:return: dictionary of vmid:vuart1
"""
vm_id_dic = {}
- for i in range(common.VM_COUNT):
+ for i in list(common.VM_TYPES.keys()):
for key in vm_vuart1[i].keys():
if key == "target_vm_id":
vm_id_dic[i] = vm_vuart1[i][key]
@@ -510,8 +472,7 @@ def clos_assignment(clos_per_vm, index):
def avl_vuart_ui_select(scenario_info):
tmp_vuart = {}
- for vm_i in range(common.VM_COUNT):
- vm_type = get_order_type_by_vmid(vm_i)
+ for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == "SOS_VM":
key = "vm={},vuart=0,base".format(vm_i)
@@ -529,9 +490,10 @@ def avl_vuart_ui_select(scenario_info):
def get_first_post_vm():
- for i in range(common.VM_COUNT):
- (err_dic, vm_type) = common.get_load_order_by_vmid(common.SCENARIO_INFO_FILE, common.VM_COUNT, i)
+ i = 0
+ for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == "POST_LAUNCHED_VM":
+ i = vm_i
break
return (err_dic, i)
diff --git a/misc/acrn-config/scenario_config/pci_dev_c.py b/misc/acrn-config/scenario_config/pci_dev_c.py
index 280d71662..f4eafffbe 100644
--- a/misc/acrn-config/scenario_config/pci_dev_c.py
+++ b/misc/acrn-config/scenario_config/pci_dev_c.py
@@ -29,7 +29,7 @@ def generate_file(config):
print(" * The memory range of vBAR should exactly match with the e820 layout of VM.",
file=config)
print(" */", file=config)
- for i in range(common.VM_COUNT):
+ for i in list(common.VM_TYPES.keys()):
print("", file=config)
print("struct acrn_vm_pci_dev_config " +
"vm{}_pci_devs[VM{}_CONFIG_PCI_DEV_NUM] = {{".format(i, i), file=config)
diff --git a/misc/acrn-config/scenario_config/scenario_cfg_gen.py b/misc/acrn-config/scenario_config/scenario_cfg_gen.py
index 6b1cb2b8a..9896c40e4 100755
--- a/misc/acrn-config/scenario_config/scenario_cfg_gen.py
+++ b/misc/acrn-config/scenario_config/scenario_cfg_gen.py
@@ -38,9 +38,10 @@ def get_scenario_item_values(board_info, scenario_info):
common.BOARD_INFO_FILE = board_info
common.SCENARIO_INFO_FILE = scenario_info
common.get_vm_num(scenario_info)
+ common.get_vm_types()
# pre scenario
- guest_flags = copy.deepcopy(scenario_cfg_lib.GUEST_FLAG)
+ guest_flags = copy.deepcopy(common.GUEST_FLAG)
guest_flags.remove('0UL')
scenario_item_values["vm,vcpu_affinity"] = hw_info.get_processor_val()
scenario_item_values["vm,guest_flags"] = guest_flags
@@ -125,6 +126,7 @@ def main(args):
common.SCENARIO_INFO_FILE = params['--scenario']
common.ACRN_CONFIG_TARGET= os.path.abspath(params['--out']) + '/'
common.get_vm_num(params['--scenario'])
+ common.get_vm_types()
# get board name
(err_dic, board_name) = common.get_board_name()
@@ -174,16 +176,16 @@ def main(args):
# generate vm_configuration.h
with open(vm_config_h, 'w') as config:
- vm_configurations_h.generate_file(scenario, scenario_items['vm'], config)
+ vm_configurations_h.generate_file(scenario_items, config)
# generate vm_configuration.c
with open(vm_config_c, 'w') as config:
- err_dic = vm_configurations_c.generate_file(scenario, scenario_items['vm'], config)
+ err_dic = vm_configurations_c.generate_file(scenario_items['vm'], config)
if err_dic:
return err_dic
- # generate pci_dev.c if scenario is logical_partition
- if scenario == 'logical_partition':
+ # generate pci_dev.c
+ if scenario_items['vm'].load_order_cnt.pre_vm >= 2:
with open(pci_config_c, 'w') as config:
pci_dev_c.generate_file(config)
diff --git a/misc/acrn-config/scenario_config/scenario_item.py b/misc/acrn-config/scenario_config/scenario_item.py
index d1cab98fd..6a7d149c0 100644
--- a/misc/acrn-config/scenario_config/scenario_item.py
+++ b/misc/acrn-config/scenario_config/scenario_item.py
@@ -249,7 +249,7 @@ class VmInfo:
load_order = {}
uuid = {}
clos_per_vm = {}
- guest_flag_idx = {}
+ guest_flags = {}
cpus_per_vm = {}
severity = {}
@@ -273,7 +273,7 @@ class VmInfo:
self.name = common.get_leaf_tag_map(self.scenario_info, "name")
self.load_order = common.get_leaf_tag_map(self.scenario_info, "load_order")
self.uuid = common.get_leaf_tag_map(self.scenario_info, "uuid")
- self.guest_flag_idx = common.get_sub_leaf_tag(
+ self.guest_flags = common.get_leaf_tag_map(
self.scenario_info, "guest_flags", "guest_flag")
self.cpus_per_vm = common.get_leaf_tag_map(
self.scenario_info, "vcpu_affinity", "pcpu_id")
@@ -310,7 +310,7 @@ class VmInfo:
scenario_cfg_lib.vm_name_check(self.name, "name")
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.guest_flag_check(self.guest_flags, "guest_flags", "guest_flag")
scenario_cfg_lib.cpus_per_vm_check(self.cpus_per_vm, "pcpu_id")
self.mem_info.check_item()
diff --git a/misc/acrn-config/scenario_config/vm_configurations_c.py b/misc/acrn-config/scenario_config/vm_configurations_c.py
index 00260ad69..4ee8c055b 100644
--- a/misc/acrn-config/scenario_config/vm_configurations_c.py
+++ b/misc/acrn-config/scenario_config/vm_configurations_c.py
@@ -75,7 +75,7 @@ def vuart0_output(i, vm_type, vm_info, config):
def vuart_map_enable(vm_info):
map_dic = {}
- for i in range(common.VM_COUNT):
+ for i,vm_type in common.VM_TYPES.items():
base_i = vm_info.vuart.v1_vuart[i]['base']
src_t_vm_i = vm_info.vuart.v1_vuart[i]['target_vm_id']
src_t_vuart_i = vm_info.vuart.v1_vuart[i]['target_uart_id']
@@ -124,8 +124,7 @@ def vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config):
print("\t\t\t.t_vuart.vuart_id = {0}U,".format(
vm_info.vuart.v1_vuart[i]['target_uart_id']), file=config)
-
-def vuart_output(i, vm_info, config):
+def vuart_output(vm_type, i, vm_info, config):
"""
This is generate vuart setting
:param i: vm id number
@@ -135,7 +134,6 @@ def vuart_output(i, vm_info, config):
"""
vuart1_vmid_dic = {}
vuart1_vmid_dic = scenario_cfg_lib.get_vuart1_vmid(vm_info.vuart.v1_vuart)
- vm_type = scenario_cfg_lib.get_order_type_by_vmid(i)
vuart0_output(i, vm_type, vm_info, config)
vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config)
@@ -148,8 +146,6 @@ def vuart_output(i, vm_info, 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)
- print("\t},", file=config)
-
def is_need_epc(epc_section, i, config):
"""
@@ -160,7 +156,9 @@ def is_need_epc(epc_section, i, config):
:return: None
"""
# SOS_VM have not set epc section
- vm_type = scenario_cfg_lib.get_order_type_by_vmid(i)
+ if i not in common.VM_TYPES.keys():
+ return
+ vm_type = list(common.VM_TYPES.keys())[i]
if vm_type == "SOS_VM":
return
@@ -204,34 +202,34 @@ def clos_output(vm_info, i, config):
if len(rdt_res) != 0 and common_clos_max !=0 and i in vm_info.clos_per_vm:
print("\t\t.clos = VM{}_VCPU_CLOS,".format(i), file=config)
-def get_guest_flag(flag_index):
+def get_guest_flag(flags):
"""
This is get flag index list
- :param flag_index:
+ :param flags:
:return: flag index list in GUEST_FLAGS
"""
err_dic = {}
flag_str = ''
- if not flag_index:
- err_dic['guest flags'] = "No assign flag to the guest"
- return (err_dic, flag_str)
+ for flag in flags:
+ if flags.count(flag) >= 2:
+ return (err_dic, flag)
- for i in range(len(flag_index)):
+ for i in range(len(flags)):
if i == 0:
- if len(flag_index) == 1:
+ if len(flags) == 1:
# get the guest flag 0UL
- if flag_index[0] == 0:
- return (err_dic, common.GUEST_FLAG[flag_index[0]])
- flag_str = "{0}".format(common.GUEST_FLAG[int(flag_index[0])])
+ if flags[0] == '0UL':
+ return (err_dic, flags[0])
+ flag_str = "{0}".format(flags[0])
else:
- flag_str = "({0}".format(common.GUEST_FLAG[int(flag_index[0])])
+ flag_str = "({0}".format(flags[0])
else:
- # flag_index lenght already minus 1
- if i == len(flag_index) - 1:
- flag_str = flag_str + " | {0})".format(common.GUEST_FLAG[int(flag_index[i])])
+ # flags lenght already minus 1
+ if i == len(flags) - 1:
+ flag_str = flag_str + " | {0})".format(flags[i])
else:
- flag_str = flag_str + " | {0}".format(common.GUEST_FLAG[int(flag_index[i])])
+ flag_str = flag_str + " | {0}".format(flags[i])
return (err_dic, flag_str)
@@ -245,194 +243,119 @@ def gen_source_header(config):
print("{0}".format(C_HEADER), file=config)
-def gen_sdc_source(vm_info, config):
- """
- Generate vm_configuration.c of sdc scenario
- :param vm_info: it is the class which contain all user setting information
- :param config: it is the pointer which file write to
- :return: None
- """
- uuid_0 = uuid2str(vm_info.uuid[0])
- uuid_1 = uuid2str(vm_info.uuid[1])
+def gen_sos_vm(vm_type, vm_i, vm_info, config):
- (err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flag_idx[0])
+ (err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i])
if err_dic:
return err_dic
+ uuid_str = uuid2str(vm_info.uuid[vm_i])
- gen_source_header(config)
- # VM0
- print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
- print("\t{", file=config)
+ print("\t{{\t/* VM{} */".format(vm_i), file=config)
print("\t\t.load_order = {0},".format(
- vm_info.load_order[0]), file=config)
- print('\t\t.name = "{0}",'.format(vm_info.name[0]), file=config)
+ vm_info.load_order[vm_i]), file=config)
+ print('\t\t.name = "{0}",'.format(vm_info.name[vm_i]), file=config)
# UUID
- uuid_output(uuid_0, vm_info.uuid[0], config)
+ uuid_output(uuid_str, vm_info.uuid[vm_i], config)
print("", file=config)
print("\t\t/* Allow SOS to reboot the host since " +
"there is supposed to be the highest severity guest */", file=config)
- print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
- vcpu_affinity_output(vm_info, 0, config)
- print("\t\t.severity = {0},".format(vm_info.severity[0].strip()), file=config)
+ if sos_guest_flags:
+ print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
+ vcpu_affinity_output(vm_info, vm_i, config)
+ print("\t\t.severity = {0},".format(vm_info.severity[vm_i].strip()), file=config)
print("\t\t.memory = {", file=config)
- print("\t\t\t.start_hpa = {}UL,".format(vm_info.mem_info.mem_start_hpa[0]), file=config)
+ print("\t\t\t.start_hpa = {}UL,".format(vm_info.mem_info.mem_start_hpa[vm_i]), file=config)
print("\t\t\t.size = {0},".format("CONFIG_SOS_RAM_SIZE"), file=config)
print("\t\t},", file=config)
print("\t\t.os_config = {", file=config)
- print('\t\t\t.name = "{0}",'.format(vm_info.os_cfg.kern_name[0]), file=config)
- print('\t\t\t.kernel_type = {0},'.format(vm_info.os_cfg.kern_type[0]), file=config)
+ print('\t\t\t.name = "{0}",'.format(vm_info.os_cfg.kern_name[vm_i]), file=config)
+ print('\t\t\t.kernel_type = {0},'.format(vm_info.os_cfg.kern_type[vm_i]), file=config)
print('\t\t\t.kernel_mod_tag = "{0}",'.format(
- vm_info.os_cfg.kern_mod[0]), file=config)
- print('\t\t\t.bootargs = {0},'.format(vm_info.os_cfg.kern_args[0]), file=config)
- if (vm_info.os_cfg.ramdisk_mod[0].strip()):
+ vm_info.os_cfg.kern_mod[vm_i]), file=config)
+ print('\t\t\t.bootargs = {0},'.format(vm_info.os_cfg.kern_args[vm_i]), file=config)
+ if (vm_info.os_cfg.ramdisk_mod[vm_i].strip()):
print('\t\t\t.ramdisk_mod_tag = "{0}",'.format(
- vm_info.os_cfg.ramdisk_mod[0]), file=config)
+ vm_info.os_cfg.ramdisk_mod[vm_i]), file=config)
print("\t\t},", file=config)
# VUART
- err_dic = vuart_output(0, vm_info, config)
- if err_dic:
- return err_dic
- # VM1
- print("\t{", file=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, 1, config)
-
- vm1_id = 1
- vm1_cpu_num = len(vm_info.cpus_per_vm[vm1_id])
- print("\t\t.vcpu_num = {}U,".format(vm1_cpu_num), file=config)
- print("\t\t.vcpu_affinity = VM{}_CONFIG_VCPU_AFFINITY,".format(vm1_id), file=config)
- print("\t\t.severity = {0},".format(vm_info.severity[1].strip()), file=config)
- # VUART
- err_dic = vuart_output(1, vm_info, config)
+ err_dic = vuart_output(vm_type, vm_i, vm_info, config)
if err_dic:
return err_dic
- # VM2
- if scenario_cfg_lib.KATA_VM_COUNT == 1:
- # Setup Kata vm configurations if more than 3 VMs in SDC config file
- uuid_2 = uuid2str(vm_info.uuid[2])
- print("#if CONFIG_MAX_KATA_VM_NUM > 0", file=config)
- print("\t{", file=config)
- print("\t\t.load_order = POST_LAUNCHED_VM,", file=config)
- uuid_output(uuid_2, vm_info.uuid[2], config)
- vcpu_affinity_output(vm_info, 2, config)
- print("\t\t.severity = {0},".format(vm_info.severity[2].strip()), file=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)
- print("\t\t},", file=config)
- print("\t\t.vuart[1] = {", file=config)
- print("\t\t\t.type = VUART_LEGACY_PIO,", file=config)
- print("\t\t\t.addr.port_base = INVALID_COM_BASE,", file=config)
- print("\t\t}", file=config)
- print("\t},", file=config)
- print("#endif", file=config)
-
- print("};", file=config)
- return err_dic
-
-
-def gen_sdc2_source(vm_info, config):
- """
- Generate vm_configuration.c of sdc2 scenario
- :param vm_info: it is the class which contain all user setting information
- :param config: it is the pointer which file write to
- :return: None
- """
- uuid_0 = uuid2str(vm_info.uuid[0])
- uuid_1 = uuid2str(vm_info.uuid[1])
- uuid_2 = uuid2str(vm_info.uuid[2])
- uuid_3 = uuid2str(vm_info.uuid[3])
-
- (err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flag_idx[0])
- if err_dic:
- return err_dic
-
- gen_source_header(config)
-
- # VM0
- print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
- print("\t{", file=config)
- print("\t\t.load_order = {0},".format(
- vm_info.load_order[0]), file=config)
- print('\t\t.name = "{0}",'.format(vm_info.name[0]), file=config)
- # UUID
- uuid_output(uuid_0, vm_info.uuid[0], config)
- print("", file=config)
- print("\t\t/* Allow SOS to reboot the host since " +
- "there is supposed to be the highest severity guest */", file=config)
- print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
- vcpu_affinity_output(vm_info, 0, config)
- clos_output(vm_info, 0, config)
- print("\t\t.severity = {0},".format(vm_info.severity[0].strip()), file=config)
- print("\t\t.memory = {", file=config)
- print("\t\t\t.start_hpa = {}UL,".format(vm_info.mem_info.mem_start_hpa[0]), file=config)
- print("\t\t\t.size = {0},".format("CONFIG_SOS_RAM_SIZE"), file=config)
- print("\t\t},", file=config)
- print("\t\t.os_config = {", file=config)
- print('\t\t\t.name = "{0}",'.format(vm_info.os_cfg.kern_name[0]), file=config)
- print('\t\t\t.kernel_type = {0},'.format(vm_info.os_cfg.kern_type[0]), file=config)
- print('\t\t\t.kernel_mod_tag = "{0}",'.format(
- vm_info.os_cfg.kern_mod[0]), file=config)
- print('\t\t\t.bootargs = {0},'.format(vm_info.os_cfg.kern_args[0]), file=config)
- if (vm_info.os_cfg.ramdisk_mod[0].strip()):
- print('\t\t\t.ramdisk_mod_tag = "{0}",'.format(
- vm_info.os_cfg.ramdisk_mod[0]), file=config)
- print("\t\t},", file=config)
- # VUART
- err_dic = vuart_output(0, vm_info, config)
- if err_dic:
- return err_dic
-
- # VM1
- print("\t{", file=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)
- vcpu_affinity_output(vm_info, 1, config)
- print("\t\t.severity = {0},".format(vm_info.severity[1].strip()), file=config)
- is_need_epc(vm_info.epc_section, 1, config)
- # VUART
- err_dic = vuart_output(1, vm_info, config)
- if err_dic:
- return err_dic
-
- # VM2
- print("\t{", file=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)
- vcpu_affinity_output(vm_info, 2, config)
- print("\t\t.severity = {0},".format(vm_info.severity[2].strip()), file=config)
- is_need_epc(vm_info.epc_section, 2, config)
- # VUART
- err_dic = vuart_output(1, vm_info, config)
- if err_dic:
- return err_dic
- print("", file=config)
-
- # VM3
- 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, 3, config)
- vcpu_affinity_output(vm_info, 3, config)
- print("\t\t.severity = {0},".format(vm_info.severity[3].strip()), file=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)
- print("\t\t},", file=config)
- print("\t\t.vuart[1] = {", file=config)
- print("\t\t\t.type = VUART_LEGACY_PIO,", file=config)
- print("\t\t\t.addr.port_base = INVALID_COM_BASE,", file=config)
- print("\t\t}", file=config)
print("\t},", file=config)
- print("};", file=config)
- return err_dic
+
+def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
+
+ # guest flags
+ (err_dic, guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i])
+ if err_dic:
+ return err_dic
+ uuid_str = uuid2str(vm_info.uuid[vm_i])
+
+ print("\t{{\t/* VM{} */".format(vm_i), file=config)
+ print("\t\t.load_order = {0},".format(vm_info.load_order[vm_i]), file=config)
+ print('\t\t.name = "{0}",'.format(vm_info.name[vm_i]), file=config)
+ # UUID
+ uuid_output(uuid_str, vm_info.uuid[vm_i], config)
+ vcpu_affinity_output(vm_info, vm_i, config)
+ if vm_i in vm_info.severity.keys():
+ print("\t\t.severity = {0},".format(vm_info.severity[vm_i].strip()), file=config)
+ if guest_flags:
+ print("\t\t.guest_flags = {0},".format(guest_flags), file=config)
+ clos_output(vm_info, vm_i, config)
+ print("\t\t.memory = {", file=config)
+ print("\t\t\t.start_hpa = VM{0}_CONFIG_MEM_START_HPA,".format(vm_i), file=config)
+ print("\t\t\t.size = VM{0}_CONFIG_MEM_SIZE,".format(vm_i), file=config)
+ print("\t\t\t.start_hpa2 = VM{0}_CONFIG_MEM_START_HPA2,".format(vm_i), file=config)
+ print("\t\t\t.size_hpa2 = VM{0}_CONFIG_MEM_SIZE_HPA2,".format(vm_i), file=config)
+ print("\t\t},", file=config)
+ is_need_epc(vm_info.epc_section, vm_i, config)
+ print("\t\t.os_config = {", file=config)
+ print('\t\t\t.name = "{0}",'.format(vm_info.os_cfg.kern_name[vm_i]), file=config)
+ print("\t\t\t.kernel_type = {0},".format(
+ vm_info.os_cfg.kern_type[vm_i]), file=config)
+ print('\t\t\t.kernel_mod_tag = "{0}",'.format(
+ vm_info.os_cfg.kern_mod[vm_i]), file=config)
+ if (vm_info.os_cfg.ramdisk_mod[vm_i].strip()):
+ print('\t\t\t.ramdisk_mod_tag = "{0}",'.format(
+ vm_info.os_cfg.ramdisk_mod[vm_i]), file=config)
+
+ if vm_i in vm_info.os_cfg.kern_load_addr.keys() and vm_info.os_cfg.kern_entry_addr[vm_i]:
+ print("\t\t\t.kernel_load_addr = {0},".format(vm_info.os_cfg.kern_load_addr[vm_i]), file=config)
+ if vm_i in vm_info.os_cfg.kern_entry_addr.keys() and vm_info.os_cfg.kern_entry_addr[vm_i]:
+ print("\t\t\t.kernel_entry_addr = {0},".format(vm_info.os_cfg.kern_entry_addr[vm_i]), file=config)
+
+ if vm_i in vm_info.os_cfg.kern_args.keys() and vm_info.os_cfg.kern_args[vm_i]:
+ print("\t\t\t.bootargs = VM{0}_CONFIG_OS_BOOTARG_CONSOLE\t\\".format(vm_i), file=config)
+ print("\t\t\t\tVM{0}_CONFIG_OS_BOOTARG_MAXCPUS\t\t\\".format(vm_i), file=config)
+ print("\t\t\t\tVM{0}_CONFIG_OS_BOOTARG_ROOT\t\t\\".format(vm_i), file=config)
+ split_cmdline(vm_info.os_cfg.kern_args[vm_i].strip(), config)
+ print("\t\t},", file=config)
+ # VUART
+ err_dic = vuart_output(vm_type, vm_i, vm_info, config)
+ if err_dic:
+ return err_dic
+
+ print("\t},", file=config)
+
+
+def gen_post_launch_vm(vm_type, vm_i, vm_info, config):
+
+ uuid_str = uuid2str(vm_info.uuid[vm_i])
+ print("\t{{\t/* VM{} */".format(vm_i), file=config)
+ print("\t\t.load_order = {0},".format(vm_info.load_order[vm_i]), file=config)
+ # UUID
+ uuid_output(uuid_str, vm_info.uuid[vm_i], config)
+ vcpu_affinity_output(vm_info, vm_i, config)
+ print("\t\t.severity = {0},".format(vm_info.severity[vm_i].strip()), file=config)
+ is_need_epc(vm_info.epc_section, vm_i, config)
+ # VUART
+ err_dic = vuart_output(vm_type, vm_i, vm_info, config)
+ if err_dic:
+ return err_dic
+
+ print("\t},", file=config)
def split_cmdline(cmd_str, config):
@@ -458,233 +381,34 @@ def split_cmdline(cmd_str, config):
print('"', file=config)
+def pre_launch_definiation(vm_info, config):
-def gen_logical_partition_source(vm_info, config):
- """
- Generate vm_configuration.c of logical_partition scenario
- :param vm_info: it is the class which contain all user setting information
- :param config: it is the pointer which file write to
- :return: None
- """
- err_dic = {}
- gen_source_header(config)
- for i in range(common.VM_COUNT):
+ for vm_i,vm_type in common.VM_TYPES.items():
+ if vm_type != "PRE_LAUNCHED_VM":
+ continue
print("extern struct acrn_vm_pci_dev_config " +
- "vm{0}_pci_devs[VM{1}_CONFIG_PCI_DEV_NUM];".format(i, i), file=config)
+ "vm{0}_pci_devs[VM{1}_CONFIG_PCI_DEV_NUM];".format(vm_i, vm_i), file=config)
print("", file=config)
- print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
- for i in range(common.VM_COUNT):
- uuid = uuid2str(vm_info.uuid[i])
- print("\t{{\t/* VM{0} */".format(i), file=config)
- print("\t\t.load_order = {0},".format(vm_info.load_order[i]), file=config)
- print('\t\t.name = "{0}",'.format(vm_info.name[i]), file=config)
- # UUID
- uuid_output(uuid, vm_info.uuid[i], config)
- vcpu_affinity_output(vm_info, i, config)
- # skip the vm0 for guest flag
-
- # guest flags
- (err_dic, guest_flags) = get_guest_flag(vm_info.guest_flag_idx[i])
- if err_dic:
- return err_dic
-
- print("\t\t.guest_flags = {0},".format(guest_flags), file=config)
- clos_output(vm_info, i, config)
- print("\t\t.memory = {", file=config)
- print("\t\t\t.start_hpa = VM{0}_CONFIG_MEM_START_HPA,".format(i), file=config)
- print("\t\t\t.size = VM{0}_CONFIG_MEM_SIZE,".format(i), file=config)
- print("\t\t\t.start_hpa2 = VM{0}_CONFIG_MEM_START_HPA2,".format(i), file=config)
- print("\t\t\t.size_hpa2 = VM{0}_CONFIG_MEM_SIZE_HPA2,".format(i), file=config)
- print("\t\t},", file=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(
- vm_info.os_cfg.kern_type[i]), file=config)
- print('\t\t\t.kernel_mod_tag = "{0}",'.format(
- vm_info.os_cfg.kern_mod[i]), file=config)
- if (vm_info.os_cfg.ramdisk_mod[i].strip()):
- print('\t\t\t.ramdisk_mod_tag = "{0}",'.format(
- vm_info.os_cfg.ramdisk_mod[i]), file=config)
- print("\t\t\t.bootargs = VM{0}_CONFIG_OS_BOOTARG_CONSOLE\t\\".format(i), file=config)
- print("\t\t\t\tVM{0}_CONFIG_OS_BOOTARG_MAXCPUS\t\t\\".format(i), file=config)
- print("\t\t\t\tVM{0}_CONFIG_OS_BOOTARG_ROOT\t\t\\".format(i), file=config)
- #print("\t\t\t\t{0}".format(vm_info.os_cfg.kern_args_append[i].strip()), file=config)
- split_cmdline(vm_info.os_cfg.kern_args[i].strip(), config)
- print("\t\t},", file=config)
- # VUART
- err_dic = vuart_output(i, vm_info, config)
- if err_dic:
- return err_dic
-
- print("};", file=config)
-
- return err_dic
-
-
-def gen_industry_source(vm_info, config):
- """
- Generate vm_configuration.c of industry scenario
- :param vm_info: it is the class which contain all user setting information
- :param config: it is the pointer which file write to
- :return: None
- """
- err_dic = {}
- gen_source_header(config)
- print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
- for i in range(common.VM_COUNT):
- uuid = uuid2str(vm_info.uuid[i])
- print("\t{", file=config)
- print("\t\t.load_order = {0},".format(vm_info.load_order[i]), file=config)
- if i == 0:
- print('\t\t.name = "{0}",'.format(vm_info.name[i]), file=config)
-
- # UUID
- uuid_output(uuid, vm_info.uuid[i], 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])
- if err_dic:
- return err_dic
- print("\t\t")
- print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
-
- vcpu_affinity_output(vm_info, i, config)
- print("\t\t.severity = {0},".format(vm_info.severity[i].strip()), file=config)
- clos_output(vm_info, i, config)
-
- if i == 0:
- print("\t\t.memory = {", file=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)
- 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(
- vm_info.os_cfg.kern_type[i]), file=config)
- print('\t\t\t.kernel_mod_tag = "{0}",'.format(
- vm_info.os_cfg.kern_mod[i]), file=config)
- if (vm_info.os_cfg.ramdisk_mod[i].strip()):
- print('\t\t\t.ramdisk_mod_tag = "{0}",'.format(
- vm_info.os_cfg.ramdisk_mod[i]), file=config)
- print("\t\t\t.bootargs = {0}".format(
- vm_info.os_cfg.kern_args[i]), file=config)
- print("\t\t},", file=config)
-
- if i == 2:
- print("\t\t/* The hard RTVM must be launched as VM2 */", file=config)
- (err_dic, vm_guest_flags) = get_guest_flag(vm_info.guest_flag_idx[i])
- if err_dic:
- return err_dic
- print("\t\t.guest_flags = {0},".format(vm_guest_flags), file=config)
- # VUART
- err_dic = vuart_output(i, vm_info, config)
- if err_dic:
- return err_dic
-
- print("};", file=config)
-
- return err_dic
-
-
-def gen_hybrid_source(vm_info, config):
- """
- Generate vm_configuration.c of hybrid scenario
- :param vm_info: it is the class which contain all user setting information
- :param config: it is the pointer which file write to
- :return: None
- """
- err_dic = {}
- (err_dic, post_vm_i) = scenario_cfg_lib.get_first_post_vm()
- if err_dic:
- return err_dic
-
- gen_source_header(config)
- print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
-
- for i in range(common.VM_COUNT):
- uuid = uuid2str(vm_info.uuid[i])
- print("\t{{\t/* VM{0} */".format(i), file=config)
- print("\t\t.load_order = {0},".format(vm_info.load_order[i]), file=config)
- if i != 2:
- print('\t\t.name = "{0}",'.format(vm_info.name[i]), file=config)
-
- # UUID
- uuid_output(uuid, vm_info.uuid[i], config)
-
- if i != 2:
- (err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flag_idx[i])
- if err_dic:
- return err_dic
- print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
-
- vcpu_affinity_output(vm_info, i, config)
- print("\t\t.severity = {0},".format(vm_info.severity[i].strip()), file=config)
-
- if i != 2:
- clos_output(vm_info, i, config)
- print("\t\t.memory = {", file=config)
- if i == 0:
- print("\t\t\t.start_hpa = VM0_CONFIG_MEM_START_HPA,", file=config)
- print("\t\t\t.size = VM0_CONFIG_MEM_SIZE,", file=config)
- print("\t\t\t.start_hpa2 = VM0_CONFIG_MEM_START_HPA2,", file=config)
- print("\t\t\t.size_hpa2 = VM0_CONFIG_MEM_SIZE_HPA2,", file=config)
- elif i == 1:
- 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)
- 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(
- vm_info.os_cfg.kern_type[i]), file=config)
- print('\t\t\t.kernel_mod_tag = "{0}",'.format(
- vm_info.os_cfg.kern_mod[i]), file=config)
- if (vm_info.os_cfg.ramdisk_mod[i].strip()):
- print('\t\t\t.ramdisk_mod_tag = "{0}",'.format(
- vm_info.os_cfg.ramdisk_mod[i]), file=config)
-
- if i < post_vm_i:
- if not vm_info.os_cfg.kern_args[i] or not vm_info.os_cfg.kern_args[i].strip():
- print('\t\t\t.bootargs = "",', file=config)
- else:
- print("\t\t\t.bootargs = {0},".format(
- vm_info.os_cfg.kern_args[i]), file=config)
- if i == 0:
- print("\t\t\t.kernel_load_addr = {0},".format(
- vm_info.os_cfg.kern_load_addr[i]), file=config)
- print("\t\t\t.kernel_entry_addr = {0},".format(
- vm_info.os_cfg.kern_entry_addr[i]), file=config)
-
- print("\t\t},", file=config)
-
- # VUART
- err_dic = vuart_output(i, vm_info, config)
- if err_dic:
- return err_dic
- print("};", file=config)
-
- return err_dic
-
-
-def generate_file(scenario, vm_info, config):
+def generate_file(vm_info, config):
"""
Start to generate vm_configurations.c
:param config: it is a file pointer of board information for writing to
"""
err_dic = {}
- if scenario == 'sdc':
- err_dic = gen_sdc_source(vm_info, config)
- elif scenario == 'sdc2':
- err_dic = gen_sdc2_source(vm_info, config)
- elif scenario == 'logical_partition':
- err_dic = gen_logical_partition_source(vm_info, config)
- elif scenario == 'industry':
- err_dic = gen_industry_source(vm_info, config)
- else:
- # scenario is 'hybrid'
- err_dic = gen_hybrid_source(vm_info, config)
+ gen_source_header(config)
+ if vm_info.load_order_cnt.pre_vm >= 2:
+ pre_launch_definiation(vm_info, config)
+ print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
+ for vm_i, vm_type in common.VM_TYPES.items():
+
+ if vm_type == "SOS_VM":
+ gen_sos_vm(vm_type, vm_i, vm_info, config)
+ elif vm_type == "PRE_LAUNCHED_VM":
+ gen_pre_launch_vm(vm_type, vm_i, vm_info, config)
+ elif vm_type == "POST_LAUNCHED_VM":
+ gen_post_launch_vm(vm_type, vm_i, vm_info, config)
+
+ print("};", file=config)
return err_dic
diff --git a/misc/acrn-config/scenario_config/vm_configurations_h.py b/misc/acrn-config/scenario_config/vm_configurations_h.py
index bfaf97a5e..ce77ab1e1 100644
--- a/misc/acrn-config/scenario_config/vm_configurations_h.py
+++ b/misc/acrn-config/scenario_config/vm_configurations_h.py
@@ -56,256 +56,104 @@ def clos_config_output(vm_info, i, config):
clos_config = vm_info.get_clos_bitmap(i)
print("#define VM{0}_VCPU_CLOS\t\t{1}".format(i, clos_config['clos_map']), file=config)
-def scenario_vm_num(load_type_cnt, config):
+def scenario_vm_num(scenario_items, config):
+ load_type_cnt = scenario_items['vm'].load_order_cnt
+ kata_vm_num = scenario_items['hv'].cap.max_kata_vm_num
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):
- """
- Generate vm_configuration.h of sdc scenario
- :param config: it is the pointer which file write to
- :return: None
- """
- gen_common_header(config)
- print("#include \n", file=config)
-
- scenario_vm_num(vm_info.load_order_cnt, config)
- print("", file=config)
- print("/* Bits mask of guest flags that can be programmed by device model." +
- " Other bits are set by hypervisor only */", file=config)
- print("#define DM_OWNED_GUEST_FLAG_MASK\t" +
- "(GUEST_FLAG_SECURE_WORLD_ENABLED | GUEST_FLAG_LAPIC_PASSTHROUGH | \\\n" +
- "\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
-
- print("", file=config)
- print("#define SOS_VM_BOOTARGS\t\t\tSOS_ROOTFS\t\\", file=config)
- print("\t\t\t\t\tSOS_CONSOLE\t\\", file=config)
- print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
- print("", file=config)
-
- # POST LAUNCHED VM
- if scenario_cfg_lib.KATA_VM_COUNT == 1:
- print("#if CONFIG_MAX_KATA_VM_NUM > 0", file=config)
- # Set VM1 vcpu
- cpu_affinity_output(vm_info, 1, config)
- clos_config_output(vm_info, 1, config)
- # KATA VM
- cpu_affinity_output(vm_info, 2, config)
- clos_config_output(vm_info, 2, config)
- #else:
- print("#else", file=config)
- # Only two VMs in SDC config, setup vcpu affinity for VM1
- cpu_affinity_output(vm_info, 1, config)
- clos_config_output(vm_info, 1, config)
- print("#endif", file=config)
- else:
- cpu_affinity_output(vm_info, 1, config)
- clos_config_output(vm_info, 1, config)
- print("", file=config)
- print("{0}".format(VM_END_DEFINE), file=config)
+ print("#define CONFIG_MAX_KATA_VM_NUM\t\t{}U".format(kata_vm_num), file=config)
-def gen_sdc2_header(vm_info, config):
- """
- Generate vm_configuration.h of sdc2 scenario
- :param config: it is the pointer which file write to
- :return: None
- """
- gen_common_header(config)
- print("#include \n", file=config)
- scenario_vm_num(vm_info.load_order_cnt, config)
- print("", file=config)
- print("/* Bits mask of guest flags that can be programmed by device model." +
- " Other bits are set by hypervisor only */", file=config)
- print("#define DM_OWNED_GUEST_FLAG_MASK\t" +
- "(GUEST_FLAG_SECURE_WORLD_ENABLED | GUEST_FLAG_LAPIC_PASSTHROUGH | \\\n" +
- "\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
+def gen_pre_launch_vm(vm_info, config):
- print("", file=config)
- print("#define SOS_VM_BOOTARGS\t\t\tSOS_ROOTFS\t\\", file=config)
- print("\t\t\t\t\tSOS_CONSOLE\t\\", file=config)
- print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
+ vm_i = 0
+ for vm_type in common.VM_TYPES.values():
+ if vm_type != "PRE_LAUNCHED_VM":
+ vm_i += 1
+ continue
- print("", file=config)
- for i in range(common.VM_COUNT):
- cpu_affinity_output(vm_info, i, config)
- clos_config_output(vm_info, i, config)
- print("", file=config)
- print("{0}".format(VM_END_DEFINE), file=config)
-
-
-def logic_max_vm_num(vm_info, config):
- """
- This is logical max vm number comment
- :param config: it is the pointer which file write to
- :return: None
- """
- print("", file=config)
- scenario_vm_num(vm_info.load_order_cnt, config)
- print("", file=config)
- print("/* The VM CONFIGs like:", file=config)
- print(" *\tVMX_CONFIG_VCPU_AFFINITY", file=config)
- print(" *\tVMX_CONFIG_MEM_START_HPA", file=config)
- print(" *\tVMX_CONFIG_MEM_SIZE", file=config)
- print(" *\tVMX_CONFIG_MEM_START_HPA2", file=config)
- print(" *\tVMX_CONFIG_MEM_SIZE_HPA2", file=config)
- print(" *\tVMX_CONFIG_OS_BOOTARG_ROOT", file=config)
- print(" *\tVMX_CONFIG_OS_BOOTARG_MAX_CPUS", file=config)
- print(" *\tVMX_CONFIG_OS_BOOTARG_CONSOLE", file=config)
- print(" * might be different on your board, please modify them per your needs.", file=config)
- print(" */", file=config)
- print("", file=config)
-
-
-def gen_logical_partition_header(vm_info, config):
- """
- Generate vm_configuration.h of logical_partition scenario
- :param config: it is the pointer which file write to
- :return: None
- """
- gen_common_header(config)
- # map all the needed pci sub class
- print("#include ", file=config)
- print("#include ", file=config)
- print("", file=config)
- print("/* Bits mask of guest flags that can be programmed by device model." +
- " Other bits are set by hypervisor only */", file=config)
- print("#define DM_OWNED_GUEST_FLAG_MASK\t0UL", file=config)
-
- logic_max_vm_num(vm_info, config)
-
- for i in range(common.VM_COUNT):
-
- cpu_bits = vm_info.get_cpu_bitmap(i)
- cpu_affinity_output(vm_info, i, config)
- clos_config_output(vm_info, i, config)
+ cpu_bits = vm_info.get_cpu_bitmap(vm_i)
+ cpu_affinity_output(vm_info, vm_i, config)
+ clos_config_output(vm_info, vm_i, config)
print("#define VM{0}_CONFIG_MEM_START_HPA\t\t{1}UL".format(
- i, vm_info.mem_info.mem_start_hpa[i]), file=config)
+ vm_i, vm_info.mem_info.mem_start_hpa[vm_i]), file=config)
print("#define VM{0}_CONFIG_MEM_SIZE\t\t\t{1}UL".format(
- i, vm_info.mem_info.mem_size[i]), file=config)
- print("#define VM{0}_CONFIG_MEM_START_HPA2\t\t{1}UL".format(
- i, vm_info.mem_info.mem_start_hpa2[i]), file=config)
- print("#define VM{0}_CONFIG_MEM_SIZE_HPA2\t\t{1}UL".format(
- i, vm_info.mem_info.mem_size_hpa2[i]), file=config)
- print('#define VM{0}_CONFIG_OS_BOOTARG_ROOT\t\t"root={1} "'.format(
- i, vm_info.os_cfg.kern_root_dev[i]), file=config)
- print('#define VM{0}_CONFIG_OS_BOOTARG_MAXCPUS\t\t"maxcpus={1} "'.format(
- i, cpu_bits['cpu_num']), file=config)
- print('#define VM{0}_CONFIG_OS_BOOTARG_CONSOLE\t\t"console={1} "'.format(
- i, vm_info.os_cfg.kern_console.strip('/dev/')), file=config)
+ vm_i, vm_info.mem_info.mem_size[vm_i]), file=config)
+ if vm_info.mem_info.mem_start_hpa2[vm_i] not in (None, ''):
+ print("#define VM{0}_CONFIG_MEM_START_HPA2\t\t{1}UL".format(
+ vm_i, vm_info.mem_info.mem_start_hpa2[vm_i]), file=config)
+ print("#define VM{0}_CONFIG_MEM_SIZE_HPA2\t\t{1}UL".format(
+ vm_i, vm_info.mem_info.mem_size_hpa2[vm_i]), file=config)
+ if vm_info.os_cfg.kern_root_dev:
+ print('#define VM{0}_CONFIG_OS_BOOTARG_ROOT\t\t"root={1} "'.format(
+ vm_i, vm_info.os_cfg.kern_root_dev[vm_i]), file=config)
+
+ print('#define VM{0}_CONFIG_OS_BOOTARG_MAXCPUS\t\t"maxcpus={1} "'.format(vm_i, cpu_bits['cpu_num']), file=config)
+ if vm_info.os_cfg.kern_console:
+ print('#define VM{0}_CONFIG_OS_BOOTARG_CONSOLE\t\t"console={1} "'.format(vm_i, vm_info.os_cfg.kern_console.strip('/dev/')), file=config)
print("", file=config)
-
- print('/* VM pass-through devices assign policy:', file=config)
- print(' * VM0: one Mass Storage controller, one Network controller;', file=config)
- print(' * VM1: one Mass Storage controller, one Network controller' +
- '(if a secondary Network controller class device exist);', file=config)
- print(' */', file=config)
- print('#define VM0_STORAGE_CONTROLLER\t\t\tSATA_CONTROLLER_0', file=config)
- print('#define VM0_NETWORK_CONTROLLER\t\t\tETHERNET_CONTROLLER_0', file=config)
- print('#define VM0_CONFIG_PCI_DEV_NUM\t\t\t3U', file=config)
- print('', file=config)
- print('#define VM1_STORAGE_CONTROLLER\t\t\tUSB_CONTROLLER_0', file=config)
- print('#if defined(ETHERNET_CONTROLLER_1)', file=config)
- print('/* if a secondary Ethernet controller subclass exist, assign to VM1 */', file=config)
- print('#define VM1_NETWORK_CONTROLLER\t\t\tETHERNET_CONTROLLER_1', file=config)
- print('#elif defined(NETWORK_CONTROLLER_0)', file=config)
- print('/* if a Network controller subclass exist' +
- '(usually it is a wireless network card), assign to VM1 */', file=config)
- print('#define VM1_NETWORK_CONTROLLER\t\t\tNETWORK_CONTROLLER_0', file=config)
- print('#endif', file=config)
- print('', file=config)
- print('#if defined(VM1_NETWORK_CONTROLLER)', file=config)
- print('#define VM1_CONFIG_PCI_DEV_NUM\t\t\t3U', file=config)
- print('#else', file=config)
- print('/* no network controller could be assigned to VM1 */', file=config)
- print('#define VM1_CONFIG_PCI_DEV_NUM\t\t\t2U', file=config)
- print('#endif', file=config)
- print("", file=config)
- print("{0}".format(VM_END_DEFINE), file=config)
+ vm_i += 1
-def gen_industry_header(vm_info, config):
- """
- Generate vm_configuration.h of industry scenario
- :param config: it is the pointer which file write to
- :return: None
- """
- gen_common_header(config)
- print("#include ", file=config)
- print("", file=config)
- scenario_vm_num(vm_info.load_order_cnt, config)
- print("", file=config)
- print("/* Bits mask of guest flags that can be programmed by device model." +
- " Other bits are set by hypervisor only */", file=config)
- print("#define DM_OWNED_GUEST_FLAG_MASK\t(GUEST_FLAG_SECURE_WORLD_ENABLED | " +
- "GUEST_FLAG_LAPIC_PASSTHROUGH | \\", file=config)
- print("\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
- print("", file=config)
- print("#define SOS_VM_BOOTARGS\t\t\tSOS_ROOTFS\t\\", file=config)
- print("\t\t\t\t\tSOS_CONSOLE\t\\", file=config)
- print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
- print("", file=config)
- for i in range(common.VM_COUNT):
- cpu_affinity_output(vm_info, i, config)
- clos_config_output(vm_info, i, config)
- print("", file=config)
- print("{0}".format(VM_END_DEFINE), file=config)
+def gen_post_launch_header(vm_info, config):
+ vm_i = 0
+ for vm_type in common.VM_TYPES.values():
+ if vm_type != "POST_LAUNCHED_VM":
+ vm_i += 1
+ continue
+ cpu_affinity_output(vm_info, vm_i, config)
+ clos_config_output(vm_info, vm_i, config)
+ vm_i += 1
+def gen_sos_header(vm_info, config):
-def gen_hybrid_header(vm_info, config):
- """
- Generate vm_configuration.h of hybrid scenario
- :param vm_info: it is the class which contain all user setting information
- :param config: it is the pointer which file write to
- :return: None
- """
- gen_common_header(config)
- print("#include \n", file=config)
- print("/* Bits mask of guest flags that can be programmed by device model." +
- " Other bits are set by hypervisor only */", file=config)
- print("#define DM_OWNED_GUEST_FLAG_MASK\t" +
- "(GUEST_FLAG_SECURE_WORLD_ENABLED | GUEST_FLAG_LAPIC_PASSTHROUGH | \\\n" +
- "\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
-
- print("", file=config)
- scenario_vm_num(vm_info.load_order_cnt, config)
- print("", file=config)
- for i in range(common.VM_COUNT):
- cpu_affinity_output(vm_info, i, config)
- clos_config_output(vm_info, i, config)
-
- print("#define VM0_CONFIG_MEM_START_HPA\t{0}UL".format(
- vm_info.mem_info.mem_start_hpa[0]), file=config)
- print("#define VM0_CONFIG_MEM_SIZE\t\t{0}UL".format(vm_info.mem_info.mem_size[0]), file=config)
- print("#define VM0_CONFIG_MEM_START_HPA2\t{0}UL".format(
- vm_info.mem_info.mem_start_hpa2[0]), file=config)
- print("#define VM0_CONFIG_MEM_SIZE_HPA2\t{0}UL".format(vm_info.mem_info.mem_size_hpa2[0]), file=config)
+ if 'SOS_VM' not in common.VM_TYPES.values():
+ return
print("", file=config)
print("#define SOS_VM_BOOTARGS\t\t\tSOS_ROOTFS\t\\", file=config)
print("\t\t\t\t\tSOS_CONSOLE\t\\", file=config)
print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
+
+def gen_header_file(vm_info, config):
+
+ gen_post_launch_header(vm_info, config)
+ gen_pre_launch_vm(vm_info, config)
+ gen_sos_header(vm_info, config)
+
+
+def get_dm_owned_guest_flag_mask(vm_info, config):
+
+ if vm_info.load_order_cnt.pre_vm >= 2:
+ print("#define DM_OWNED_GUEST_FLAG_MASK\t0UL", file=config)
+ else:
+ print("/* Bits mask of guest flags that can be programmed by device model." +
+ " Other bits are set by hypervisor only */", file=config)
+ print("#define DM_OWNED_GUEST_FLAG_MASK\t" +
+ "(GUEST_FLAG_SECURE_WORLD_ENABLED | GUEST_FLAG_LAPIC_PASSTHROUGH | \\\n" +
+ "\t\t\t\t\t\tGUEST_FLAG_RT | GUEST_FLAG_IO_COMPLETION_POLLING)", file=config)
+
print("", file=config)
- print("{0}".format(VM_END_DEFINE), file=config)
-def generate_file(scenario, vm_info, config):
+def generate_file(scenario_items, config):
"""
Start to generate vm_configurations.h
- :param scenario: it is scenario name
- :param vm_info: it is the class which contain all user setting information
+ :param scenario_items: it is the class which contain all user setting information
:param config: it is a file pointer of board information for writing to
"""
- if scenario == 'sdc':
- gen_sdc_header(vm_info, config)
- elif scenario == 'sdc2':
- gen_sdc2_header(vm_info, config)
- elif scenario == 'logical_partition':
- gen_logical_partition_header(vm_info, config)
- elif scenario == 'industry':
- gen_industry_header(vm_info, config)
- else:
- # scenario is 'hybrid'
- gen_hybrid_header(vm_info, config)
+ vm_info = scenario_items['vm']
+ gen_common_header(config)
+
+ print("#include \n", file=config)
+ if 'PRE_LAUNCHED_VM' in common.VM_TYPES.values():
+ print("#include ", file=config)
+ get_dm_owned_guest_flag_mask(vm_info, config)
+ scenario_vm_num(scenario_items, config)
+ print("", file=config)
+
+ gen_header_file(vm_info, config)
+ print("", file=config)
+ print("{0}".format(VM_END_DEFINE), file=config)