acrn-config: remove hard code UUID from config xmls

To keep align hv source code changes, config tool doese below changes:
1. Remove UUID from scenario config files.
2. Remove severity from scenario config files.
3. Use vm type to instead load order type.
4. Use the mapped UUID data base for launch vm script configurations.
5. Unify the ui_entry_api for '--out'

Tracked-On: #4641
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
Acked-by: Terry Zou <terry.zou@intel.com>
This commit is contained in:
Wei Liu 2020-04-16 16:50:11 +08:00 committed by wenlingz
parent eb341caa83
commit ccef1af1f0
10 changed files with 162 additions and 168 deletions

View File

@ -54,20 +54,22 @@ def main(args):
err_dic['board config: Not match'] = "The board xml and scenario xml should be matched" err_dic['board config: Not match'] = "The board xml and scenario xml should be matched"
return err_dic return err_dic
if common.ACRN_CONFIG_TARGET: if params['--out']:
board_dir = common.ACRN_CONFIG_TARGET + board + '/' if os.path.isabs(params['--out']):
board_dir = params['--out'] + board + '/'
config_board_kconfig = board_dir + GEN_FILE[4]
else:
board_dir = ACRN_PATH + params['--out'] + board + '/'
config_board_kconfig = board_dir + GEN_FILE[4]
else: else:
board_dir = ACRN_CONFIG_DEF + board + '/' board_dir = ACRN_CONFIG_DEF + board + '/'
config_board_kconfig = board_dir + GEN_FILE[4]
common.mkdir(board_dir) common.mkdir(board_dir)
config_pci = board_dir + GEN_FILE[0] config_pci = board_dir + GEN_FILE[0]
config_board = board_dir + GEN_FILE[1] config_board = board_dir + GEN_FILE[1]
config_acpi = board_dir + board + GEN_FILE[2] config_acpi = board_dir + board + GEN_FILE[2]
config_misc_cfg = board_dir + GEN_FILE[3] config_misc_cfg = board_dir + GEN_FILE[3]
if common.ACRN_CONFIG_TARGET:
config_board_kconfig = common.ACRN_CONFIG_TARGET + board + GEN_FILE[4]
else:
config_board_kconfig = ACRN_CONFIG_DEF + board + GEN_FILE[4]
# generate board.c # generate board.c
with open(config_board, 'w+') as config: with open(config_board, 'w+') as config:
@ -97,9 +99,9 @@ def main(args):
return err_dic return err_dic
def ui_entry_api(board_info, scenario_info): def ui_entry_api(board_info, scenario_info, out):
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info] arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--out', out]
err_dic = common.prepare() err_dic = common.prepare()
if err_dic: if err_dic:

View File

@ -515,15 +515,11 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config):
boot_image_type(dm, vmid, config) boot_image_type(dm, vmid, config)
# uuid get # uuid get
scenario_uuid = launch_cfg_lib.get_scenario_uuid() scenario_uuid = launch_cfg_lib.get_scenario_uuid(vmid)
sos_vmid = launch_cfg_lib.get_sos_vmid() sos_vmid = launch_cfg_lib.get_sos_vmid()
if not str(sos_vmid).isnumeric():
sos_vmid = 0
key = "launch config err:"
launch_cfg_lib.ERR_LIST[key] = "There is no SOS_VM in scenario config file!"
# clearlinux/android/alios # clearlinux/android/alios
dm_str = 'acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {}'.format(scenario_uuid[vmid + sos_vmid]) dm_str = 'acrn-dm -A -m $mem_size -s 0:0,hostbridge -U {}'.format(scenario_uuid)
if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"): if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
if uos_type == "CLEARLINUX": if uos_type == "CLEARLINUX":
print("{} \\".format(dm_str), file=config) print("{} \\".format(dm_str), file=config)

View File

@ -86,10 +86,10 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm) return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm)
def ui_entry_api(board_info, scenario_info, launch_info): def ui_entry_api(board_info, scenario_info, launch_info, out):
err_dic = {} err_dic = {}
arg_list = ['launch_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--launch', launch_info, '--uosid', '0'] arg_list = ['launch_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--launch', launch_info, '--uosid', '0', '--out', out]
err_dic = common.prepare() err_dic = common.prepare()
if err_dic: if err_dic:
@ -148,9 +148,6 @@ def main(args):
if err_dic: if err_dic:
return err_dic return err_dic
if output_folder:
common.ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/'
# check env # check env
err_dic = common.prepare() err_dic = common.prepare()
if err_dic: if err_dic:
@ -201,8 +198,11 @@ def main(args):
# create output directory # create output directory
board_name = names['board_name'] board_name = names['board_name']
if common.ACRN_CONFIG_TARGET: if output_folder:
output = common.ACRN_CONFIG_TARGET + '/' + board_name + '/output/' if os.path.isabs(output_folder):
output = output_folder + '/' + board_name + '/output/'
else:
output = ACRN_PATH + board_name + '/output/'
else: else:
output = ACRN_CONFIG_DEF + '/' + board_name + '/output/' output = ACRN_CONFIG_DEF + '/' + board_name + '/output/'
common.mkdir(output) common.mkdir(output)

View File

@ -428,7 +428,7 @@ def num2int(str_value):
def get_vm_types(): def get_vm_types():
global VM_TYPES global VM_TYPES
VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "load_order") VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "vm_type")
def get_avl_dev_info(bdf_desc_map, pci_sub_class): def get_avl_dev_info(bdf_desc_map, pci_sub_class):

View File

@ -7,6 +7,7 @@ import os
import getopt import getopt
import common import common
import board_cfg_lib import board_cfg_lib
import scenario_cfg_lib
ERR_LIST = {} ERR_LIST = {}
BOOT_TYPE = ['no', 'vsbl', 'ovmf'] BOOT_TYPE = ['no', 'vsbl', 'ovmf']
@ -168,7 +169,7 @@ def post_vm_cnt(config_file):
post_launch_cnt = 0 post_launch_cnt = 0
for vm_type in common.VM_TYPES.values(): for vm_type in common.VM_TYPES.values():
if vm_type == "POST_LAUNCHED_VM": if scenario_cfg_lib.VM_DB[vm_type]['load_type'] == "POST_LAUNCHED_VM":
post_launch_cnt += 1 post_launch_cnt += 1
return post_launch_cnt return post_launch_cnt
@ -203,21 +204,30 @@ def is_config_file_match():
return (err_dic, match) return (err_dic, match)
def get_scenario_uuid(): def get_scenario_uuid(uosid):
# {id_num:uuid} (id_num:0~max) # {id_num:uuid} (id_num:0~max)
scenario_uuid_dic = {} scenario_uuid = ''
scenario_uuid_dic = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, 'uuid') if common.VM_TYPES[uosid] == "KATA_VM" or common.VM_TYPES[uosid] == "POST_RT_VM":
return scenario_uuid_dic return scenario_cfg_lib.VM_DB[common.VM_TYPES[uosid]]['uuid']
i_cnt = 0
for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == "POST_STD_VM" and vm_i <= uosid:
i_cnt += 1
if i_cnt > 0:
i_cnt = 0
scenario_uuid = scenario_cfg_lib.VM_DB["POST_STD_VM"]['uuid'][i_cnt]
return scenario_uuid
def get_sos_vmid(): def get_sos_vmid():
load_dic = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "load_order")
sos_id = '' sos_id = ''
for idx,load_order in load_dic.items(): for vm_i,vm_type in common.VM_TYPES.items():
if load_order == "SOS_VM": if vm_type == "SOS_VM":
sos_id = idx sos_id = vm_i
break break
return sos_id return sos_id

View File

@ -8,13 +8,11 @@ import board_cfg_lib
HEADER_LICENSE = common.open_license() HEADER_LICENSE = common.open_license()
LOAD_ORDER_TYPE = ['PRE_LAUNCHED_VM', 'SOS_VM', 'POST_LAUNCHED_VM']
START_HPA_LIST = ['0', '0x100000000', '0x120000000'] START_HPA_LIST = ['0', '0x100000000', '0x120000000']
KERN_TYPE_LIST = ['KERNEL_BZIMAGE', 'KERNEL_ZEPHYR'] KERN_TYPE_LIST = ['KERNEL_BZIMAGE', 'KERNEL_ZEPHYR']
KERN_BOOT_ADDR_LIST = ['0x100000'] KERN_BOOT_ADDR_LIST = ['0x100000']
VM_SEVERITY = ['SEVERITY_SAFETY_VM', 'SEVERITY_RTVM', 'SEVERITY_SOS', 'SEVERITY_STANDARD_VM']
VUART_TYPE = ['VUART_LEGACY_PIO', 'VUART_PCI'] VUART_TYPE = ['VUART_LEGACY_PIO', 'VUART_PCI']
VUART_BASE = ['SOS_COM1_BASE', 'SOS_COM2_BASE', 'COM1_BASE', VUART_BASE = ['SOS_COM1_BASE', 'SOS_COM2_BASE', 'COM1_BASE',
'COM2_BASE', 'COM3_BASE', 'COM4_BASE', 'INVALID_COM_BASE'] 'COM2_BASE', 'COM3_BASE', 'COM4_BASE', 'INVALID_COM_BASE']
@ -39,7 +37,24 @@ PT_SUB_PCI['ethernet'] = ['Ethernet controller', 'Network controller', '802.1a c
'802.1b controller', 'Wireless controller'] '802.1b controller', 'Wireless controller']
PT_SUB_PCI['sata'] = ['SATA controller'] PT_SUB_PCI['sata'] = ['SATA controller']
PT_SUB_PCI['nvme'] = ['Non-Volatile memory controller'] PT_SUB_PCI['nvme'] = ['Non-Volatile memory controller']
UUID_DB = {
'SOS_VM':'dbbbd434-7a57-4216-a12c-2201f1ab0240',
'SAFETY_VM':'fc836901-8685-4bc0-8b71-6e31dc36fa47',
'PRE_STD_VM':['26c5e0d8-8f8a-47d8-8109-f201ebd61a5e', 'dd87ce08-66f9-473d-bc58-7605837f935e'],
'POST_STD_VM':['d2795438-25d6-11e8-864e-cb7a18b34643', '615db82a-e189-4b4f-8dbb-d321343e4ab3', '38158821-5208-4005-b72a-8a609e4190d0'],
'POST_RT_VM':'495ae2e5-2603-4d64-af76-d4bc5a8ec0e5',
'KATA_VM':'a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f',
}
VM_DB = {
'SOS_VM':{'load_type':'SOS_VM', 'severity':'SEVERITY_SOS', 'uuid':UUID_DB['SOS_VM']},
'SAFETY_VM':{'load_type':'PRE_LAUNCHED_VM', 'severity':'SEVERITY_SAFETY_VM', 'uuid':UUID_DB['SAFETY_VM']},
'PRE_STD_VM':{'load_type':'PRE_LAUNCHED_VM', 'severity':'SEVERITY_STANDARD_VM', 'uuid':UUID_DB['PRE_STD_VM']},
'POST_STD_VM':{'load_type':'POST_LAUNCHED_VM', 'severity':'SEVERITY_STANDARD_VM', 'uuid':UUID_DB['POST_STD_VM']},
'POST_RT_VM':{'load_type':'POST_LAUNCHED_VM', 'severity':'SEVERITY_RTVM', 'uuid':UUID_DB['POST_RT_VM']},
'KATA_VM':{'load_type':'POST_LAUNCHED_VM', 'severity':'SEVERITY_STANDARD_VM', 'uuid':UUID_DB['KATA_VM']},
}
LOAD_VM_TYPE = list(VM_DB.keys())
def get_pci_devs(pci_items): def get_pci_devs(pci_items):
@ -103,60 +118,73 @@ def vm_name_check(vm_names, item):
ERR_LIST[key] = "VM name length should be in range [1,32] bytes" ERR_LIST[key] = "VM name length should be in range [1,32] bytes"
def load_order_check(load_orders, item): def load_vm_check(load_vms, item):
""" """
Check load order type Check load order type
:param load_orders: dictionary of vm load_order :param load_vms: dictionary of vm vm mode
:param item: vm name item in xml :param item: vm name item in xml
:return: None :return: None
""" """
sos_vm_ids = [] sos_vm_ids = []
pre_vm_ids = [] pre_vm_ids = []
post_vm_ids = [] post_vm_ids = []
for order_i, load_str in load_orders.items(): kata_vm_ids = []
if load_str == "SOS_VM": rt_vm_ids = []
sos_vm_ids.append(order_i) for order_i, load_str in load_vms.items():
if load_str == "PRE_LAUNCHED_VM":
pre_vm_ids.append(order_i)
if load_str == "POST_LAUNCHED_VM":
post_vm_ids.append(order_i)
if not load_str: if not load_str:
key = "vm:id={},{}".format(order_i, item) key = "vm:id={},{}".format(order_i, item)
ERR_LIST[key] = "VM load should not empty" ERR_LIST[key] = "VM load should not empty"
return return
if load_str not in LOAD_ORDER_TYPE: if load_str not in LOAD_VM_TYPE:
key = "vm:id={},{}".format(order_i, item) key = "vm:id={},{}".format(order_i, item)
ERR_LIST[key] = "VM load order unknown" ERR_LIST[key] = "VM load order unknown"
if "SOS_VM" == VM_DB[load_str]['load_type']:
sos_vm_ids.append(order_i)
if "PRE_LAUNCHED_VM" == VM_DB[load_str]['load_type']:
pre_vm_ids.append(order_i)
if "POST_LAUNCHED_VM" == VM_DB[load_str]['load_type']:
post_vm_ids.append(order_i)
if "KATA_VM" == load_str:
kata_vm_ids.append(order_i)
if "POST_RT_VM" == load_str:
rt_vm_ids.append(order_i)
if len(kata_vm_ids) >=2:
key = "vm:id={},{}".format(kata_vm_ids[0], item)
ERR_LIST[key] = "KATA VM number should not be greater than 1"
return
if len(rt_vm_ids) >= 2:
key = "vm:id={},{}".format(rt_vm_ids[0], item)
ERR_LIST[key] = "POST RT VM number should not be greater than 1"
return
if len(sos_vm_ids) >= 2: if len(sos_vm_ids) >= 2:
key = "vm:id={},{}".format(sos_vm_ids[0], item) key = "vm:id={},{}".format(sos_vm_ids[0], item)
ERR_LIST[key] = "SOS_VM number should not be greater than 1" ERR_LIST[key] = "SOS vm number should not be greater than 1"
return
if post_vm_ids and sos_vm_ids: if post_vm_ids and sos_vm_ids:
if post_vm_ids[0] < sos_vm_ids[-1]: if post_vm_ids[0] < sos_vm_ids[-1]:
key = "vm:id={},{}".format(post_vm_ids[0], item) key = "vm:id={},{}".format(post_vm_ids[0], item)
ERR_LIST[key] = "POST_LAUNCHED_VM should be configured after SOS_VM" ERR_LIST[key] = "Post vm should be configured after SOS_VM"
if pre_vm_ids and sos_vm_ids: if pre_vm_ids and sos_vm_ids:
if sos_vm_ids[-1] < pre_vm_ids[-1]: if sos_vm_ids[-1] < pre_vm_ids[-1]:
key = "vm:id={},{}".format(sos_vm_ids[0], item) key = "vm:id={},{}".format(sos_vm_ids[0], item)
ERR_LIST[key] = "PRE_LAUNCHED_VM should be configured before SOS_VM" ERR_LIST[key] = "Pre vm should be configured before SOS_VM"
def get_load_order_cnt(load_orders, type_name): def get_load_vm_cnt(load_vms, type_name):
"""
Get load order type count
:param load_orders: dictionary of vm load_order
:param type_name: load order type for vm
:return: number for this load order type name
"""
type_cnt = 0 type_cnt = 0
for load_str in load_orders.values(): for load_str in load_vms.values():
if type_name == load_str: if type_name == VM_DB[load_str]['load_type']:
type_cnt += 1 type_cnt += 1
return type_cnt return type_cnt
@ -171,32 +199,6 @@ def guest_flag_check(guest_flags, branch_tag, leaf_tag):
ERR_LIST[key] = "Unknow guest flag" ERR_LIST[key] = "Unknow guest flag"
def uuid_format_check(uuid_dic, item):
"""
Check uuid
:param uuid_dic: dictionary of vm uuid
:param item: vm uuid item in xml
:return: None
"""
uuid_len = 36
for uuid_i, uuid_str in uuid_dic.items():
if not uuid_str:
key = "vm:id={},{}".format(uuid_i, item)
ERR_LIST[key] = "VM uuid should not empty"
return
uuid_str_list = list(uuid_str)
key = "vm:id={},{}".format(uuid_i, item)
if len(uuid_str) != uuid_len:
ERR_LIST[key] = "VM uuid length should be 36 bytes"
if uuid_str_list[8] != '-':
ERR_LIST[key] = "VM uuid format unknown"
def cpus_per_vm_check(id_cpus_per_vm_dic, item): def cpus_per_vm_check(id_cpus_per_vm_dic, item):
""" """
Check cpu number of per vm Check cpu number of per vm
@ -204,9 +206,9 @@ def cpus_per_vm_check(id_cpus_per_vm_dic, item):
:return: None :return: None
""" """
for vm_i, vm_type in common.VM_TYPES.items(): 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": if vm_i not in id_cpus_per_vm_dic.keys() and "SOS_VM" == VM_DB[vm_type]['load_type']:
continue continue
elif vm_i not in id_cpus_per_vm_dic.keys() and vm_type in ("PRE_LAUNCHED_VM", "POST_LAUNCHED"): elif vm_i not in id_cpus_per_vm_dic.keys() and VM_DB[vm_type]['load_type'] in ("PRE_LAUNCHED_VM", "POST_LAUNCHED_VM"):
key = "vm:id={},{}".format(vm_i, item) key = "vm:id={},{}".format(vm_i, item)
ERR_LIST[key] = "Pre launched_vm and Post launched vm should have cpus assignment" ERR_LIST[key] = "Pre launched_vm and Post launched vm should have cpus assignment"
return return
@ -325,7 +327,7 @@ def os_kern_args_check(id_kern_args_dic, prime_item, item):
if vm_i not in id_kern_args_dic.keys(): if vm_i not in id_kern_args_dic.keys():
continue continue
kern_args = id_kern_args_dic[vm_i] kern_args = id_kern_args_dic[vm_i]
if vm_type == "SOS_VM" and kern_args != "SOS_VM_BOOTARGS": if "SOS_" in vm_type and kern_args != "SOS_VM_BOOTARGS":
key = "vm:id={},{},{}".format(vm_i, 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" ERR_LIST[key] = "VM os config kernel service os should be SOS_VM_BOOTARGS"
@ -490,7 +492,7 @@ def avl_vuart_ui_select(scenario_info):
tmp_vuart = {} tmp_vuart = {}
for vm_i,vm_type in common.VM_TYPES.items(): for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == "SOS_VM": if "SOS_VM" == VM_DB[vm_type]['load_type']:
key = "vm={},vuart=0,base".format(vm_i) key = "vm={},vuart=0,base".format(vm_i)
tmp_vuart[key] = ['SOS_COM1_BASE', 'INVALID_COM_BASE'] tmp_vuart[key] = ['SOS_COM1_BASE', 'INVALID_COM_BASE']
key = "vm={},vuart=1,base".format(vm_i) key = "vm={},vuart=1,base".format(vm_i)
@ -508,7 +510,7 @@ def get_first_post_vm():
i = 0 i = 0
for vm_i,vm_type in common.VM_TYPES.items(): for vm_i,vm_type in common.VM_TYPES.items():
if vm_type == "POST_LAUNCHED_VM": if "POST_LAUNCHED_VM" == VM_DB[vm_type]['load_type']:
i = vm_i i = vm_i
break break

View File

@ -43,10 +43,10 @@ def get_scenario_item_values(board_info, scenario_info):
# pre scenario # pre scenario
guest_flags = copy.deepcopy(common.GUEST_FLAG) guest_flags = copy.deepcopy(common.GUEST_FLAG)
guest_flags.remove('0UL') guest_flags.remove('0UL')
scenario_item_values['vm,vm_type'] = scenario_cfg_lib.LOAD_VM_TYPE
scenario_item_values["vm,vcpu_affinity"] = hw_info.get_processor_val() scenario_item_values["vm,vcpu_affinity"] = hw_info.get_processor_val()
scenario_item_values["vm,guest_flags"] = guest_flags scenario_item_values["vm,guest_flags"] = guest_flags
scenario_item_values["vm,clos"] = hw_info.get_clos_val() scenario_item_values["vm,clos"] = hw_info.get_clos_val()
scenario_item_values["vm,severity"] = scenario_cfg_lib.VM_SEVERITY
scenario_item_values["vm,pci_devs,pci_dev"] = scenario_cfg_lib.avl_pci_devs() scenario_item_values["vm,pci_devs,pci_dev"] = scenario_cfg_lib.avl_pci_devs()
scenario_item_values["vm,os_config,kern_type"] = scenario_cfg_lib.KERN_TYPE_LIST 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)) scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
@ -125,7 +125,6 @@ def main(args):
common.BOARD_INFO_FILE = params['--board'] common.BOARD_INFO_FILE = params['--board']
common.SCENARIO_INFO_FILE = params['--scenario'] common.SCENARIO_INFO_FILE = params['--scenario']
common.ACRN_CONFIG_TARGET= os.path.abspath(params['--out']) + '/'
common.get_vm_num(params['--scenario']) common.get_vm_num(params['--scenario'])
common.get_vm_types() common.get_vm_types()
@ -144,8 +143,12 @@ def main(args):
return err_dic return err_dic
if params['--out']: if params['--out']:
scenario_dir = common.ACRN_CONFIG_TARGET + scenario + '/' if os.path.isabs(params['--out']):
config_hv = common.ACRN_CONFIG_TARGET + board_name + GEN_FILE[3] scenario_dir = params['--out'] + scenario + '/'
config_hv = params['--out'] + board_name + GEN_FILE[3]
else:
scenario_dir = ACRN_PATH + scenario + '/'
config_hv = ACRN_PATH + board_name + GEN_FILE[3]
else: else:
scenario_dir = ACRN_CONFIG_DEF + scenario + '/' scenario_dir = ACRN_CONFIG_DEF + scenario + '/'
config_hv = ACRN_CONFIGS + board_name + GEN_FILE[3] config_hv = ACRN_CONFIGS + board_name + GEN_FILE[3]
@ -200,9 +203,9 @@ def main(args):
return err_dic return err_dic
def ui_entry_api(board_info, scenario_info): def ui_entry_api(board_info, scenario_info, out):
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info] arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--out', out]
err_dic = common.prepare() err_dic = common.prepare()
if err_dic: if err_dic:

View File

@ -244,20 +244,18 @@ class LoadOrderNum:
self.sos_vm = 0 self.sos_vm = 0
self.post_vm = 0 self.post_vm = 0
def get_info(self, load_order): def get_info(self, load_vm):
self.pre_vm = scenario_cfg_lib.get_load_order_cnt(load_order, "PRE_LAUNCHED_VM") self.pre_vm = scenario_cfg_lib.get_load_vm_cnt(load_vm, "PRE_LAUNCHED_VM")
self.sos_vm = scenario_cfg_lib.get_load_order_cnt(load_order, "SOS_VM") self.sos_vm = scenario_cfg_lib.get_load_vm_cnt(load_vm, "SOS_VM")
self.post_vm = scenario_cfg_lib.get_load_order_cnt(load_order, "POST_LAUNCHED_VM") self.post_vm = scenario_cfg_lib.get_load_vm_cnt(load_vm, "POST_LAUNCHED_VM")
class VmInfo: class VmInfo:
""" This is Abstract of class of VM setting """ """ This is Abstract of class of VM setting """
name = {} name = {}
load_order = {} load_vm = {}
uuid = {}
clos_per_vm = {} clos_per_vm = {}
guest_flags = {} guest_flags = {}
cpus_per_vm = {} cpus_per_vm = {}
severity = {}
def __init__(self, board_file, scenario_file): def __init__(self, board_file, scenario_file):
self.board_info = board_file self.board_info = board_file
@ -277,8 +275,7 @@ class VmInfo:
:return: None :return: None
""" """
self.name = common.get_leaf_tag_map(self.scenario_info, "name") 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.load_vm= common.get_leaf_tag_map(self.scenario_info, "vm_type")
self.uuid = common.get_leaf_tag_map(self.scenario_info, "uuid")
self.guest_flags = common.get_leaf_tag_map( self.guest_flags = common.get_leaf_tag_map(
self.scenario_info, "guest_flags", "guest_flag") self.scenario_info, "guest_flags", "guest_flag")
self.cpus_per_vm = common.get_leaf_tag_map( self.cpus_per_vm = common.get_leaf_tag_map(
@ -286,13 +283,12 @@ class VmInfo:
self.clos_per_vm = common.get_leaf_tag_map( self.clos_per_vm = common.get_leaf_tag_map(
self.scenario_info, "clos", "vcpu_clos") self.scenario_info, "clos", "vcpu_clos")
self.severity = common.get_leaf_tag_map(self.scenario_info, "severity")
self.epc_section.get_info() self.epc_section.get_info()
self.mem_info.get_info() self.mem_info.get_info()
self.os_cfg.get_info() self.os_cfg.get_info()
self.vuart.get_info() self.vuart.get_info()
self.cfg_pci.get_info() self.cfg_pci.get_info()
self.load_order_cnt.get_info(self.load_order) self.load_order_cnt.get_info(self.load_vm)
def get_cpu_bitmap(self, index): def get_cpu_bitmap(self, index):
""" """
@ -314,8 +310,7 @@ class VmInfo:
:return: None :return: None
""" """
scenario_cfg_lib.vm_name_check(self.name, "name") scenario_cfg_lib.vm_name_check(self.name, "name")
scenario_cfg_lib.load_order_check(self.load_order, "load_order") scenario_cfg_lib.load_vm_check(self.load_vm, "load_vm")
scenario_cfg_lib.uuid_format_check(self.uuid, "uuid")
scenario_cfg_lib.guest_flag_check(self.guest_flags, "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") scenario_cfg_lib.cpus_per_vm_check(self.cpus_per_vm, "pcpu_id")

View File

@ -14,35 +14,31 @@ C_HEADER = scenario_cfg_lib.HEADER_LICENSE + r"""
#include <pci_dev.h> #include <pci_dev.h>
""" """
def get_pre_vm_type(vm_type, vm_i):
def uuid2str(uuid): if vm_type == "SAFETY_VM":
""" return "CONFIG_SAFETY_VM(1)"
This is convert uuid format string to string format
:param uuid: uuid number generate by uuid i_cnt = 0
:return: string uuid for i,v_type in common.VM_TYPES.items():
""" if v_type == "PRE_STD_VM" and i <= vm_i:
str1 = "" i_cnt += 1
tmp_uuid = uuid.split('-') return "CONFIG_PRE_STD_VM({})".format(i_cnt)
tmp_uuid = str1.join(tmp_uuid)
return tmp_uuid
def uuid_output(uuid, uuid_string, config): def get_post_vm_type(vm_type, vm_i):
"""
This is generate uuid information if vm_type == "KATA_VM":
:param uuid: return "CONFIG_KATA_VM(1)"
:param uuid_string:
:param config: if vm_type == "POST_RT_VM":
:return: return "CONFIG_POST_RT_VM(1)"
"""
# UUID i_cnt = 0
print("\t\t.uuid = {{0x{0}U, 0x{1}U, 0x{2}U, 0x{3}U, 0x{4}U, 0x{5}U, 0x{6}U, 0x{7}U,\t\\". for i,v_type in common.VM_TYPES.items():
format(uuid[0:2], uuid[2:4], uuid[4:6], uuid[6:8], if v_type == "POST_STD_VM" and i <= vm_i:
uuid[8:10], uuid[10:12], uuid[12:14], uuid[14:16]), file=config) i_cnt += 1
print("\t\t\t 0x{0}U, 0x{1}U, 0x{2}U, 0x{3}U, 0x{4}U, 0x{5}U, 0x{6}U, 0x{7}U}},". return "CONFIG_POST_STD_VM({})".format(i_cnt)
format(uuid[16:18], uuid[18:20], uuid[20:22], uuid[22:24],
uuid[24:26], uuid[26:28], uuid[28:30], uuid[30:32]), file=config)
print("\t\t/* {0} */".format(uuid_string), file=config)
def vuart0_output(i, vm_type, vm_info, config): def vuart0_output(i, vm_type, vm_info, config):
@ -57,13 +53,13 @@ def vuart0_output(i, vm_type, vm_info, config):
# SOS_VM vuart[0] # SOS_VM vuart[0]
print("\t\t.vuart[0] = {", file=config) print("\t\t.vuart[0] = {", file=config)
print("\t\t\t.type = {0},".format(vm_info.vuart.v0_vuart[i]['type']), file=config) print("\t\t\t.type = {0},".format(vm_info.vuart.v0_vuart[i]['type']), file=config)
if vm_type == "SOS_VM": if "SOS_" in vm_type:
print("\t\t\t.addr.port_base = SOS_COM1_BASE,", file=config) print("\t\t\t.addr.port_base = SOS_COM1_BASE,", file=config)
print("\t\t\t.irq = SOS_COM1_IRQ,", file=config) print("\t\t\t.irq = SOS_COM1_IRQ,", file=config)
elif vm_type == "PRE_LAUNCHED_VM": elif "PRE_LAUNCHED_VM" == scenario_cfg_lib.VM_DB[vm_type]['load_type']:
print("\t\t\t.addr.port_base = COM1_BASE,", file=config) print("\t\t\t.addr.port_base = COM1_BASE,", file=config)
print("\t\t\t.irq = COM1_IRQ,", file=config) print("\t\t\t.irq = COM1_IRQ,", file=config)
elif vm_type == "POST_LAUNCHED_VM": elif "POST_LAUNCHED_VM" in scenario_cfg_lib.VM_DB[vm_type]['load_type']:
print("\t\t\t.addr.port_base = {0},".format( print("\t\t\t.addr.port_base = {0},".format(
vm_info.vuart.v0_vuart[i]['base']), file=config) vm_info.vuart.v0_vuart[i]['base']), file=config)
if vm_info.vuart.v0_vuart[i]['base'] != "INVALID_COM_BASE": if vm_info.vuart.v0_vuart[i]['base'] != "INVALID_COM_BASE":
@ -111,7 +107,7 @@ def vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config):
print("\t\t\t.addr.port_base = INVALID_COM_BASE,", file=config) print("\t\t\t.addr.port_base = INVALID_COM_BASE,", file=config)
if vuart1_vmid_dic and i in vuart1_vmid_dic.keys(): if vuart1_vmid_dic and i in vuart1_vmid_dic.keys():
if vm_type == "SOS_VM": if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_type]['load_type']:
if vm_info.vuart.v1_vuart[i]['base'] != "INVALID_COM_BASE" and vuart_enable[i]: if vm_info.vuart.v1_vuart[i]['base'] != "INVALID_COM_BASE" and vuart_enable[i]:
print("\t\t\t.irq = SOS_COM2_IRQ,", file=config) print("\t\t\t.irq = SOS_COM2_IRQ,", file=config)
else: else:
@ -151,8 +147,8 @@ def is_need_epc(epc_section, i, config):
# SOS_VM have not set epc section # SOS_VM have not set epc section
if i not in common.VM_TYPES.keys(): if i not in common.VM_TYPES.keys():
return return
vm_type = list(common.VM_TYPES.keys())[i] vm_type = list(common.VM_TYPES.values())[i]
if vm_type == "SOS_VM": if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_type]['load_type']:
return return
if epc_section.base[i] == '0' and epc_section.size[i] == '0': if epc_section.base[i] == '0' and epc_section.size[i] == '0':
@ -171,7 +167,7 @@ def vcpu_affinity_output(vm_info, i, config):
:param i: the index of vm id :param i: the index of vm id
:param config: file pointor to store the information :param config: file pointor to store the information
""" """
if vm_info.load_order[i] == "SOS_VM": if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_info.load_vm[i]]['load_type']:
return return
cpu_bits = vm_info.get_cpu_bitmap(i) cpu_bits = vm_info.get_cpu_bitmap(i)
@ -241,21 +237,16 @@ def gen_sos_vm(vm_type, vm_i, vm_info, config):
(err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i]) (err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i])
if err_dic: if err_dic:
return 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/* VM{} */".format(vm_i), file=config)
print("\t\t.load_order = {0},".format( print("\t\tCONFIG_SOS_VM,", file=config)
vm_info.load_order[vm_i]), file=config)
print('\t\t.name = "{0}",'.format(vm_info.name[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)
print("", file=config) print("", file=config)
print("\t\t/* Allow SOS to reboot the host since " + print("\t\t/* Allow SOS to reboot the host since " +
"there is supposed to be the highest severity guest */", file=config) "there is supposed to be the highest severity guest */", file=config)
if sos_guest_flags: if sos_guest_flags:
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config) print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
vcpu_affinity_output(vm_info, 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)
print("\t\t.memory = {", file=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) 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\t.size = {0},".format("CONFIG_SOS_RAM_SIZE"), file=config)
@ -284,16 +275,12 @@ def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
(err_dic, guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i]) (err_dic, guest_flags) = get_guest_flag(vm_info.guest_flags[vm_i])
if err_dic: if err_dic:
return err_dic return err_dic
uuid_str = uuid2str(vm_info.uuid[vm_i])
pre_vm_type = get_pre_vm_type(vm_type, vm_i)
print("\t{{\t/* VM{} */".format(vm_i), file=config) 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{},".format(pre_vm_type), file=config)
print('\t\t.name = "{0}",'.format(vm_info.name[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) 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: if guest_flags:
print("\t\t.guest_flags = {0},".format(guest_flags), file=config) print("\t\t.guest_flags = {0},".format(guest_flags), file=config)
clos_output(vm_info, vm_i, config) clos_output(vm_info, vm_i, config)
@ -339,13 +326,10 @@ def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
def gen_post_launch_vm(vm_type, vm_i, vm_info, config): def gen_post_launch_vm(vm_type, vm_i, vm_info, config):
uuid_str = uuid2str(vm_info.uuid[vm_i]) post_vm_type = get_post_vm_type(vm_type, vm_i)
print("\t{{\t/* VM{} */".format(vm_i), file=config) 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{},".format(post_vm_type), file=config)
# UUID
uuid_output(uuid_str, vm_info.uuid[vm_i], config)
vcpu_affinity_output(vm_info, 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) is_need_epc(vm_info.epc_section, vm_i, config)
# VUART # VUART
err_dic = vuart_output(vm_type, vm_i, vm_info, config) err_dic = vuart_output(vm_type, vm_i, vm_info, config)
@ -381,7 +365,7 @@ def split_cmdline(cmd_str, config):
def pre_launch_definiation(vm_info, config): def pre_launch_definiation(vm_info, config):
for vm_i,vm_type in common.VM_TYPES.items(): for vm_i,vm_type in common.VM_TYPES.items():
if vm_type != "PRE_LAUNCHED_VM": if "PRE_LAUNCHED_VM" != scenario_cfg_lib.VM_DB[vm_type]['load_type']:
continue continue
print("extern struct acrn_vm_pci_dev_config " + print("extern struct acrn_vm_pci_dev_config " +
"vm{}_pci_devs[{}];".format(vm_i, vm_info.cfg_pci.pci_dev_num[vm_i]), file=config) "vm{}_pci_devs[{}];".format(vm_i, vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
@ -402,11 +386,11 @@ def generate_file(vm_info, config):
print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config) print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
for vm_i, vm_type in common.VM_TYPES.items(): for vm_i, vm_type in common.VM_TYPES.items():
if vm_type == "SOS_VM": 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, vm_info, config)
elif vm_type == "PRE_LAUNCHED_VM": 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, vm_info, config)
elif vm_type == "POST_LAUNCHED_VM": 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, vm_info, config)
print("};", file=config) print("};", file=config)

View File

@ -30,7 +30,7 @@ def cpu_affinity_output(vm_info, i, config):
:param i: the index of vm id :param i: the index of vm id
:param config: file pointor to store the information :param config: file pointor to store the information
""" """
if vm_info.load_order[i] == "SOS_VM": if "SOS_VM" == scenario_cfg_lib.VM_DB[vm_info.load_vm[i]]['load_type']:
return return
cpu_bits = vm_info.get_cpu_bitmap(i) cpu_bits = vm_info.get_cpu_bitmap(i)
@ -70,7 +70,7 @@ def gen_pre_launch_vm(vm_info, config):
vm_i = 0 vm_i = 0
for vm_type in common.VM_TYPES.values(): for vm_type in common.VM_TYPES.values():
if vm_type != "PRE_LAUNCHED_VM": if "PRE_LAUNCHED_VM" != scenario_cfg_lib.VM_DB[vm_type]['load_type']:
vm_i += 1 vm_i += 1
continue continue
@ -100,7 +100,7 @@ def gen_pre_launch_vm(vm_info, config):
def gen_post_launch_header(vm_info, config): def gen_post_launch_header(vm_info, config):
vm_i = 0 vm_i = 0
for vm_type in common.VM_TYPES.values(): for vm_type in common.VM_TYPES.values():
if vm_type != "POST_LAUNCHED_VM": if "POST_LAUNCHED_VM" != scenario_cfg_lib.VM_DB[vm_type]['load_type']:
vm_i += 1 vm_i += 1
continue continue
cpu_affinity_output(vm_info, vm_i, config) cpu_affinity_output(vm_info, vm_i, config)
@ -148,8 +148,10 @@ def generate_file(scenario_items, config):
gen_common_header(config) gen_common_header(config)
print("#include <misc_cfg.h>\n", file=config) print("#include <misc_cfg.h>\n", file=config)
if 'PRE_LAUNCHED_VM' in common.VM_TYPES.values(): for vm_i,pci_dev_num in vm_info.cfg_pci.pci_dev_num.items():
if pci_dev_num >= 2:
print("#include <pci_devices.h>", file=config) print("#include <pci_devices.h>", file=config)
break
get_dm_owned_guest_flag_mask(vm_info, config) get_dm_owned_guest_flag_mask(vm_info, config)
scenario_vm_num(scenario_items, config) scenario_vm_num(scenario_items, config)
print("", file=config) print("", file=config)