acrn-config: support to parse RDT information

1.Add parser and sanity check for RDT_ENABLED/CDP_ENABLED/CLOS_MASK.
2.Skip to generate RDT inforamtion when HW not support RDT or usr
select 'n' to disable RDT feature.
3.Add contiguous bit 1 check for CLOS_MASK.

Tracked-On: #4860
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Wei Liu 2020-05-20 17:00:12 +08:00
parent abba0f0e63
commit 6ed2b855bf
11 changed files with 229 additions and 71 deletions

View File

@ -91,17 +91,21 @@ def gen_dmar_structure(config):
print("};", file=config)
def populate_clos_mask_msr(rdt_res, common_clos_max, mask, config):
def populate_clos_mask_msr(rdt_res, common_clos_max, config):
"""
Populate the clos bitmask and msr index for a given RDT resource
:param rdt_res: it is a string representing the RDT resource
:param common_clos_max: Least common clos supported by all RDT resource
:param mask: Max CLOS mask supported by the RDT resource
:param config: it is a file pointer of board information for writing to
"""
cat_mask_list = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "RDT", "CLOS_MASK")
cat_max_mask_settings_len = len(cat_mask_list)
for idx in range(common_clos_max):
print("\t{", file=config)
print("\t\t.clos_mask = {0}U,".format(hex(mask)), file=config)
if idx < cat_max_mask_settings_len:
print("\t\t.clos_mask = {0}U,".format(cat_mask_list[idx]), file=config)
else:
print("\t\t.clos_mask = 0xffU,", file=config)
print("\t\t.msr_index = MSR_IA32_{0}_MASK_BASE + {1},".format(
rdt_res, idx), file=config)
print("\t},", file=config)
@ -129,7 +133,7 @@ def gen_rdt_res(config):
err_dic = {}
rdt_res_str =""
res_present = [0, 0, 0]
(rdt_resources, rdt_res_clos_max, rdt_res_mask_max) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
(rdt_resources, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_res_clos_max) != 0:
common_clos_max = min(rdt_res_clos_max)
else:
@ -151,14 +155,14 @@ def gen_rdt_res(config):
rdt_res_str = "l2"
print("struct platform_clos_info platform_{0}_clos_array[{1}] = {{".format(rdt_res_str,
"MAX_PLATFORM_CLOS_NUM"), file=config)
populate_clos_mask_msr(rdt_res, common_clos_max, int(rdt_res_mask_max[idx].strip('\''), 16), config)
populate_clos_mask_msr(rdt_res, common_clos_max, config)
print("};\n", file=config)
res_present[RDT.L2.value] = 1
elif rdt_res == "L3":
rdt_res_str = "l3"
print("struct platform_clos_info platform_{0}_clos_array[{1}] = {{".format(rdt_res_str,
"MAX_PLATFORM_CLOS_NUM"), file=config)
populate_clos_mask_msr(rdt_res, common_clos_max, int(rdt_res_mask_max[idx].strip('\''), 16), config)
populate_clos_mask_msr(rdt_res, common_clos_max, config)
print("};\n", file=config)
res_present[RDT.L3.value] = 1
elif rdt_res == "MBA":

View File

@ -108,17 +108,6 @@ def get_serial_type():
return (ttys_type, ttys_value)
def is_rdt_supported():
"""
Returns True if platform supports RDT else False
"""
(rdt_resources, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_resources) == 0 or len(rdt_res_clos_max) == 0:
return False
else:
return True
def get_memory(hv_info, config):
# this dictonary mapped with 'address start':'mem range'
@ -181,6 +170,11 @@ def get_features(hv_info, config):
print("CONFIG_{}=y".format(hv_info.features.scheduler), file=config)
print("CONFIG_RELOC={}".format(hv_info.features.reloc), file=config)
print("CONFIG_MULTIBOOT2={}".format(hv_info.features.multiboot2), file=config)
print("CONFIG_RDT_ENABLED={}".format(hv_info.features.rdt_enabled), file=config)
if hv_info.features.rdt_enabled == 'y':
print("CONFIG_CDP_ENABLED={}".format(hv_info.features.cdp_enabled), file=config)
else:
print("CONFIG_CDP_ENABLED=n", file=config)
print("CONFIG_HYPERV_ENABLED={}".format(hv_info.features.hyperv_enabled), file=config)
print("CONFIG_IOMMU_ENFORCE_SNP={}".format(hv_info.features.iommu_enforce_snp), file=config)
print("CONFIG_ACPI_PARSE_ENABLED={}".format(hv_info.features.acpi_parse_enabled), file=config)
@ -231,11 +225,6 @@ def generate_file(hv_info, config):
get_serial_console(config)
get_log_opt(hv_info, config)
if is_rdt_supported():
print("CONFIG_RDT_ENABLED=y", file=config)
else:
print("CONFIG_RDT_ENABLED=n", file=config)
print("CONFIG_ENFORCE_VALIDATED_ACPI_INFO=y", file=config)
return err_dic

View File

@ -102,6 +102,9 @@ class Features:
self.hv_file = hv_file
self.reloc = ''
self.multiboot2 = ''
self.rdt_enabled = ''
self.cdp_enabled = ''
self.cat_max_mask = []
self.scheduler = ''
self.hyperv_enabled = ''
self.iommu_enforce_snp = ''
@ -111,6 +114,9 @@ class Features:
def get_info(self):
self.multiboot2 = common.get_hv_item_tag(self.hv_file, "FEATURES", "MULTIBOOT2")
self.rdt_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "RDT_ENABLED")
self.cdp_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "CDP_ENABLED")
self.cat_max_mask = common.get_hv_item_tag(self.hv_file, "FEATURES", "RDT", "CLOS_MASK")
self.scheduler = common.get_hv_item_tag(self.hv_file, "FEATURES", "SCHEDULER")
self.reloc = common.get_hv_item_tag(self.hv_file, "FEATURES", "RELOC")
self.hyperv_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "HYPERV_ENABLED")
@ -121,6 +127,9 @@ class Features:
def check_item(self):
hv_cfg_lib.ny_support_check(self.multiboot2, "FEATURES", "MULTIBOOT2")
hv_cfg_lib.ny_support_check(self.rdt_enabled, "FEATURES", "RDT", "RDT_ENABLED")
hv_cfg_lib.ny_support_check(self.cdp_enabled, "FEATURES", "RDT", "CDP_ENABLED")
hv_cfg_lib.cat_max_mask_check(self.cat_max_mask, "FEATURES", "RDT", "CLOS_MASK")
hv_cfg_lib.scheduler_check(self.scheduler, "FEATURES", "SCHEDULER")
hv_cfg_lib.ny_support_check(self.reloc, "FEATURES", "RELOC")
hv_cfg_lib.ny_support_check(self.hyperv_enabled, "FEATURES", "HYPERV_ENABLED")

View File

@ -462,3 +462,33 @@ def parser_pci():
PCI_DEV_BAR_DESC.pci_bar_dic[cur_bdf] = tmp_bar_dic
return sub_name_count
def is_rdt_supported():
"""
Returns True if platform supports RDT else False
"""
(rdt_resources, rdt_res_clos_max, _) = clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_resources) == 0 or len(rdt_res_clos_max) == 0:
return False
else:
return True
def get_rdt_select_opt():
support_sel = ['n']
if is_rdt_supported():
support_sel.append('y')
return support_sel
def get_clos_mask_num():
clos_mask_num = 0
(rdt_resources, rdt_res_clos_max, _) = clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_resources) == 0 or len(rdt_res_clos_max) == 0:
clos_mask_num = 0
else:
clos_mask_num = min(rdt_res_clos_max)
return clos_mask_num

View File

@ -406,7 +406,7 @@ def get_vuart_info_id(config_file, idx):
return tmp_tag
def get_hv_item_tag(config_file, branch_tag, tag_str=''):
def get_hv_item_tag(config_file, branch_tag, tag_str='', leaf_str=''):
tmp = ''
root = get_config_root(config_file)
@ -423,9 +423,25 @@ def get_hv_item_tag(config_file, branch_tag, tag_str=''):
# for each 3rd level item
for leaf in sub:
if leaf.tag == tag_str and leaf.text and leaf.text != None:
tmp = leaf.text
continue
if leaf.tag == tag_str:
if not leaf_str:
if leaf.tag == tag_str and leaf.text and leaf.text != None:
tmp = leaf.text
else:
# for each 4rd level item
tmp_list = []
for leaf_s in leaf:
if leaf_s.tag == leaf_str and leaf_s.text and leaf_s.text != None:
if leaf_str == "CLOS_MASK":
tmp_list.append(leaf_s.text)
else:
tmp = leaf_s.text
continue
if leaf_str == "CLOS_MASK":
tmp = tmp_list
break
return tmp

View File

@ -7,6 +7,7 @@ import os
import sys
import common
import getopt
import board_cfg_lib
ERR_LIST = {}
@ -25,10 +26,14 @@ RANGE_DB = {
}
def empty_check(val, prime_item, item):
def empty_check(val, prime_item, item, sub_item=''):
if not val or val == None:
key = 'hv,{},{}'.format(prime_item, item)
ERR_LIST[key] = "{} should not empty".format(item)
if sub_item:
key = 'hv,{},{},{}'.format(prime_item, item, sub_item)
ERR_LIST[key] = "{} should not empty".format(sub_item)
else:
key = 'hv,{},{}'.format(prime_item, item)
ERR_LIST[key] = "{} should not empty".format(item)
return True
return False
@ -100,8 +105,8 @@ def uefi_load_name_check(str_name, mis, mis_uefi_name):
ERR_LIST[key] = "{} length should be in range[1, 256]".format(mis_uefi_name)
def ny_support_check(sel_str, feat, feat_item):
if empty_check(sel_str, feat, feat_item):
def ny_support_check(sel_str, feat, feat_item, feat_sub_leaf=''):
if empty_check(sel_str, feat, feat_item, feat_sub_leaf):
return
if sel_str not in N_Y:
key = 'hv,{},{}'.format(feat, feat_item)
@ -128,3 +133,66 @@ def get_select_range(branch_tag, range_key):
range_list.append(str(range_i))
return range_list
def is_contiguous_bit_set(value):
bit_1_cnt = 0
tmp_val = value
is_contiguous = False
first_p = 0
last_p = 0
while tmp_val > 0:
tmp_val &= (tmp_val - 1)
bit_1_cnt += 1
for shift_i in range(32):
mask = (0x1 << shift_i)
if value & mask:
if first_p == 0 and last_p == 0:
first_p = shift_i + 1
elif first_p != 0:
last_p = shift_i + 1
else:
if first_p == 0 and last_p == 0:
continue
break
contiguous_cnt = last_p - first_p + 1
if bit_1_cnt == contiguous_cnt or bit_1_cnt in (0, 1):
is_contiguous = True
return is_contiguous
def cat_max_mask_check(cat_mask_list, feature, cat_str, max_mask_str):
if not board_cfg_lib.is_rdt_supported():
return
cpu_num = len(board_cfg_lib.get_processor_info())
cat_max_mask_settings_len = len(cat_mask_list)
if cpu_num != cat_max_mask_settings_len:
key = 'hv,{},{},{}'.format(feature, cat_str, max_mask_str)
ERR_LIST[key] = "Total {} CPU cores, should set the same number for CLOS_MASK.".format(cpu_num)
return
(_, rdt_res_clos_max, clos_max_mask_list) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
clos_max_mask_str = clos_max_mask_list[0].strip('"').strip("'")
clos_max_mask = common.num2int(clos_max_mask_str)
for val_str in cat_mask_list:
if empty_check(val_str, feature, cat_str, max_mask_str):
return
value = common.num2int(val_str)
if value < 0 or value > clos_max_mask:
key = 'hv,{},{},{}'.format(feature, cat_str, max_mask_str)
ERR_LIST[key] = "{} should be in range[0,{}]".format(max_mask_str, clos_max_mask_str)
return
if not is_contiguous_bit_set(value):
key = 'hv,{},{},{}'.format(feature, cat_str, max_mask_str)
ERR_LIST[key] = "CLOS_MASK {} should be contiguous bit set.".format(max_mask_str, clos_max_mask_str)
return

View File

@ -585,3 +585,35 @@ def check_vuart(v0_vuart, v1_vuart):
if t_vm_id.isnumeric() and int(t_vm_id) not in common.VM_TYPES.keys():
key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
ERR_LIST[key] = "target_vm_id which specified does not exist"
def vcpu_clos_check(cpus_per_vm, clos_per_vm, prime_item, item):
common_clos_max = 0
cdp_enabled = cdp_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "RDT", "CDP_ENABLED")
(rdt_resources, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_resources) != 0 and len(rdt_res_clos_max) != 0:
common_clos_max = min(rdt_res_clos_max)
if cdp_enabled == 'y':
common_clos_max //= 2
for vm_i,vcpus in cpus_per_vm.items():
clos_per_vm_len = 0
if vm_i in clos_per_vm:
clos_per_vm_len = len(clos_per_vm[vm_i])
if clos_per_vm_len != len(vcpus):
key = "vm:id={},{},{}".format(vm_i, prime_item, item)
ERR_LIST[key] = "'vcpu_clos' number should be equal 'pcpu_id' number for VM{}".format(vm_i)
return
if cdp_enabled == 'y' and common_clos_max != 0:
for clos_val in clos_per_vm[vm_i]:
if not clos_val or clos_val == None:
key = "vm:id={},{},{}".format(vm_i, prime_item, item)
ERR_LIST[key] = "'vcpu_clos' should be not None"
return
if int(clos_val) >= common_clos_max:
key = "vm:id={},{},{}".format(vm_i, prime_item, item)
ERR_LIST[key] = "CDP_ENABLED=y, the clos value should not be greater than {} for VM{}".format(common_clos_max - 1, vm_i)
return

View File

@ -46,7 +46,7 @@ def get_scenario_item_values(board_info, scenario_info):
scenario_item_values['vm,vm_type'] = scenario_cfg_lib.LOAD_VM_TYPE
scenario_item_values["vm,cpu_affinity"] = hw_info.get_processor_val()
scenario_item_values["vm,guest_flags"] = guest_flags
scenario_item_values["vm,clos"] = hw_info.get_clos_val()
scenario_item_values["vm,clos,vcpu_clos"] = hw_info.get_clos_val()
scenario_item_values["vm,pci_devs"] = scenario_cfg_lib.avl_pci_devs()
scenario_item_values["vm,os_config,kern_type"] = scenario_cfg_lib.KERN_TYPE_LIST
scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
@ -64,6 +64,9 @@ def get_scenario_item_values(board_info, scenario_info):
scenario_item_values["hv,CAPACITIES,MAX_IOAPIC_NUM"] = hv_cfg_lib.get_select_range("CAPACITIES", "IOAPIC_NUM")
scenario_item_values["hv,FEATURES,MULTIBOOT2"] = hv_cfg_lib.N_Y
scenario_item_values["hv,FEATURES,RDT,RDT_ENABLED"] = board_cfg_lib.get_rdt_select_opt()
scenario_item_values["hv,FEATURES,RDT,CDP_ENABLED"] = board_cfg_lib.get_rdt_select_opt()
scenario_item_values["hv,FEATURES,RDT,CLOS_MASK"] = board_cfg_lib.get_clos_mask_num()
scenario_item_values["hv,FEATURES,SCHEDULER"] = hv_cfg_lib.SCHEDULER_TYPE
scenario_item_values["hv,FEATURES,RELOC"] = hv_cfg_lib.N_Y
scenario_item_values["hv,FEATURES,HYPERV_ENABLED"] = hv_cfg_lib.N_Y
@ -178,7 +181,7 @@ def main(args):
# generate vm_configuration.c
with open(vm_config_c, 'w') as config:
err_dic = vm_configurations_c.generate_file(scenario_items['vm'], config)
err_dic = vm_configurations_c.generate_file(scenario_items, config)
if err_dic:
return err_dic

View File

@ -48,9 +48,11 @@ class HwInfo:
:return: clos support list
"""
self.clos_val = []
(rdt_resources, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(self.board_info)
if len(rdt_resources) != 0 and len(rdt_res_clos_max) != 0:
common_clos_max = min(rdt_res_clos_max)
for i_cnt in range(common_clos_max):
self.clos_val.append(str(i_cnt))
@ -302,6 +304,7 @@ class VmInfo:
scenario_cfg_lib.load_vm_check(self.load_vm, "load_vm")
scenario_cfg_lib.guest_flag_check(self.guest_flags, "guest_flags", "guest_flag")
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.scenario_info, self.cpus_per_vm, "pcpu_id")
scenario_cfg_lib.vcpu_clos_check(self.cpus_per_vm, self.clos_per_vm, "clos", "vcpu_clos")
self.mem_info.check_item()
self.os_cfg.check_item()

View File

@ -197,20 +197,17 @@ def cpu_affinity_output(vm_info, i, config):
print("\t\t.cpu_affinity = VM{}_CONFIG_CPU_AFFINITY,".format(i), file=config)
def clos_output(vm_info, i, config):
def clos_output(scenario_items, i, config):
"""
This is generate clos setting
: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 i: vm id number
:param config: it is the pointer which file write to
:return: None
"""
(rdt_res, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_res_clos_max) != 0:
common_clos_max = min(rdt_res_clos_max)
else:
common_clos_max = 0
if len(rdt_res) != 0 and common_clos_max !=0 and i in vm_info.clos_per_vm:
hv_info = scenario_items['hv']
if board_cfg_lib.is_rdt_supported() and hv_info.features.rdt_enabled == 'y':
print("\t\t.clos = VM{}_VCPU_CLOS,".format(i), file=config)
def get_guest_flag(flags):
@ -254,8 +251,9 @@ def gen_source_header(config):
print("{0}".format(C_HEADER), file=config)
def gen_sos_vm(vm_type, vm_i, vm_info, config):
def gen_sos_vm(vm_type, vm_i, scenario_items, config):
vm_info = scenario_items['vm']
(err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i])
if err_dic:
return err_dic
@ -268,6 +266,7 @@ def gen_sos_vm(vm_type, vm_i, vm_info, config):
"there is supposed to be the highest severity guest */", file=config)
if sos_guest_flags:
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
clos_output(scenario_items, vm_i, config)
cpu_affinity_output(vm_info, vm_i, config)
print("\t\t.memory = {", file=config)
print("\t\t\t.start_hpa = {}UL,".format(vm_info.mem_info.mem_start_hpa[vm_i]), file=config)
@ -291,8 +290,9 @@ def gen_sos_vm(vm_type, vm_i, vm_info, config):
print("\t},", file=config)
def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
def gen_pre_launch_vm(vm_type, vm_i, scenario_items, config):
vm_info = scenario_items['vm']
# guest flags
(err_dic, guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i])
if err_dic:
@ -305,7 +305,7 @@ def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
cpu_affinity_output(vm_info, vm_i, config)
if guest_flags:
print("\t\t.guest_flags = {0},".format(guest_flags), file=config)
clos_output(vm_info, vm_i, config)
clos_output(scenario_items, 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)
@ -344,11 +344,13 @@ def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
print("\t},", file=config)
def gen_post_launch_vm(vm_type, vm_i, vm_info, config):
def gen_post_launch_vm(vm_type, vm_i, scenario_items, config):
vm_info = scenario_items['vm']
post_vm_type = get_post_vm_type(vm_type, vm_i)
print("\t{{\t/* VM{} */".format(vm_i), file=config)
print("\t\t{},".format(post_vm_type), file=config)
clos_output(scenario_items, vm_i, config)
cpu_affinity_output(vm_info, vm_i, config)
is_need_epc(vm_info.epc_section, vm_i, config)
# VUART
@ -368,12 +370,13 @@ def pre_launch_definiation(vm_info, config):
"vm{}_pci_devs[{}];".format(vm_i, vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
print("", file=config)
def generate_file(vm_info, config):
def generate_file(scenario_items, config):
"""
Start to generate vm_configurations.c
:param config: it is a file pointer of board information for writing to
"""
err_dic = {}
vm_info = scenario_items['vm']
gen_source_header(config)
for vm_i,pci_dev_num in vm_info.cfg_pci.pci_dev_num.items():
if pci_dev_num >= 2:
@ -384,11 +387,11 @@ def generate_file(vm_info, config):
for vm_i, vm_type in common.VM_TYPES.items():
if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_type]['load_type']:
gen_sos_vm(vm_type, vm_i, vm_info, config)
gen_sos_vm(vm_type, vm_i, scenario_items, config)
elif "PRE_LAUNCHED_VM" == scenario_cfg_lib.VM_DB[vm_type]['load_type']:
gen_pre_launch_vm(vm_type, vm_i, vm_info, config)
gen_pre_launch_vm(vm_type, vm_i, scenario_items, config)
elif "POST_LAUNCHED_VM" == scenario_cfg_lib.VM_DB[vm_type]['load_type']:
gen_post_launch_vm(vm_type, vm_i, vm_info, config)
gen_post_launch_vm(vm_type, vm_i, scenario_items, config)
print("};", file=config)
return err_dic

View File

@ -37,24 +37,19 @@ def cpu_affinity_output(vm_info, i, config):
print("#define VM{0}_CONFIG_CPU_AFFINITY\t\t{1}".format(
i, cpu_bits['cpu_map']), file=config)
def clos_config_output(vm_info, i, config):
def clos_config_output(scenario_items, i, config):
"""
Output the macro vcpu affinity
:param vm_info: the data structure have all the xml items values
:param scenario_items: the data structure have all the xml items values
:param i: the index of vm id
:param config: file pointor to store the information
"""
(rdt_res, rdt_res_clos_max, _) = board_cfg_lib.clos_info_parser(common.BOARD_INFO_FILE)
if len(rdt_res_clos_max) != 0:
common_clos_max = min(rdt_res_clos_max)
else:
common_clos_max = 0
vm_info = scenario_items['vm']
hv_info = scenario_items['hv']
if common_clos_max == 0:
return
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)
if board_cfg_lib.is_rdt_supported() and hv_info.features.rdt_enabled == 'y':
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(scenario_items, config):
@ -65,8 +60,9 @@ def scenario_vm_num(scenario_items, config):
print("#define CONFIG_MAX_KATA_VM_NUM\t\t{}U".format(scenario_cfg_lib.KATA_VM_COUNT), file=config)
def gen_pre_launch_vm(vm_info, config):
def gen_pre_launch_vm(scenario_items, config):
vm_info = scenario_items['vm']
vm_i = 0
for vm_type in common.VM_TYPES.values():
if "PRE_LAUNCHED_VM" != scenario_cfg_lib.VM_DB[vm_type]['load_type']:
@ -75,7 +71,7 @@ def gen_pre_launch_vm(vm_info, 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)
clos_config_output(scenario_items, vm_i, config)
print("#define VM{0}_CONFIG_MEM_START_HPA\t\t{1}UL".format(
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(
@ -90,17 +86,18 @@ def gen_pre_launch_vm(vm_info, config):
vm_i += 1
def gen_post_launch_header(vm_info, config):
def gen_post_launch_header(scenario_items, config):
vm_i = 0
vm_info = scenario_items['vm']
for vm_type in common.VM_TYPES.values():
if "POST_LAUNCHED_VM" != scenario_cfg_lib.VM_DB[vm_type]['load_type']:
vm_i += 1
continue
cpu_affinity_output(vm_info, vm_i, config)
clos_config_output(vm_info, vm_i, config)
clos_config_output(scenario_items, vm_i, config)
vm_i += 1
def gen_sos_header(vm_info, config):
def gen_sos_header(scenario_items, config):
if 'SOS_VM' not in common.VM_TYPES.values():
return
@ -109,12 +106,16 @@ def gen_sos_header(vm_info, config):
print("\t\t\t\t\tSOS_CONSOLE\t\\", file=config)
print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == 'SOS_VM':
clos_config_output(scenario_items, vm_i, 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 gen_header_file(scenario_items, config):
gen_pre_launch_vm(scenario_items, config)
gen_sos_header(scenario_items, config)
gen_post_launch_header(scenario_items, config)
def get_dm_owned_guest_flag_mask(vm_info, config):
@ -149,6 +150,6 @@ def generate_file(scenario_items, config):
scenario_vm_num(scenario_items, config)
print("", file=config)
gen_header_file(vm_info, config)
gen_header_file(scenario_items, config)
print("", file=config)
print("{0}".format(VM_END_DEFINE), file=config)