acrn-config: refine vcpu affinity/number for SDC scenario

For SDC scenario, support kata vm would be triggered from webUI, and
will store the kata vm information to the scenario config file.
Then, vcpu affinity/number should be refined for vm1 and kata vm.

Note: with this patch, user should add/remove the kata vm in SDC
scenario webUI and its number should match MAX_KATA_VM_NUM in
hypervisor/arch/x86/Kconfig.

Tracked-On: #4145
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 2019-11-13 12:02:33 +08:00 committed by wenlingz
parent d44440f734
commit d581473c82
4 changed files with 61 additions and 33 deletions

View File

@ -10,7 +10,6 @@ HEADER_LICENSE = common.open_license()
BOARD_INFO_FILE = "board_info.txt"
SCENARIO_INFO_FILE = ""
VM_COUNT = 0
LOAD_ORDER_TYPE = ['PRE_LAUNCHED_VM', 'SOS_VM', 'POST_LAUNCHED_VM']
START_HPA_LIST = ['0', '0x100000000', '0x120000000']
@ -35,6 +34,16 @@ COMMUNICATE_VM_ID = []
ERR_LIST = {}
VM_COUNT = 0
DEFAULT_VM_COUNT = {
'sdc':2,
'sdc2':4,
'industry':3,
'hybrid':3,
'logical_partition':2,
}
KATA_VM_COUNT = 0
def prepare(check_git):
""" Check environment """
return common.check_env(check_git)

View File

@ -117,6 +117,13 @@ def main(args):
scenario_cfg_lib.print_red("Validate the scenario item failue", err=True)
return err_dic
# get kata vm count
if scenario != "logical_partition":
scenario_cfg_lib.KATA_VM_COUNT = scenario_cfg_lib.VM_COUNT - scenario_cfg_lib.DEFAULT_VM_COUNT[scenario]
if scenario_cfg_lib.KATA_VM_COUNT > 1:
err_dic['scenario config: kata vm count err'] = "Only one kata vm is supported!"
return err_dic
# generate vm_configuration.h
with open(vm_config_h, 'w') as config:
vm_configurations_h.generate_file(scenario, vm_info, config)

View File

@ -219,7 +219,6 @@ def gen_sdc_source(vm_info, config):
"""
uuid_0 = uuid2str(vm_info.uuid[0])
uuid_1 = uuid2str(vm_info.uuid[1])
uuid_2 = uuid2str(vm_info.uuid[2])
(err_dic, sos_guest_flags) = get_guest_flag(vm_info.guest_flag_idx[0])
if err_dic:
@ -264,31 +263,38 @@ def gen_sdc_source(vm_info, config):
# UUID
uuid_output(uuid_1, vm_info.uuid[1], config)
is_need_epc(vm_info.epc_section, 1, config)
print("\t\t.vcpu_num = CONFIG_MAX_PCPU_NUM - CONFIG_MAX_KATA_VM_NUM - 1U,", file=config)
print("\t\t.vcpu_affinity = VM{}_CONFIG_VCPU_AFFINITY,".format(1), file=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)
# VUART
err_dic = vuart_output(1, vm_info, config)
if err_dic:
return err_dic
# VM2
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)
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)
# 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)
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

View File

@ -44,8 +44,8 @@ def gen_sdc_header(vm_info, config):
"""
gen_common_header(config)
print("#include <misc_cfg.h>\n", file=config)
print("#define CONFIG_MAX_VM_NUM\t\t({0}U + CONFIG_MAX_KATA_VM_NUM)".format(
scenario_cfg_lib.VM_COUNT - 1), file=config)
print("#define CONFIG_MAX_VM_NUM\t\t(2U + CONFIG_MAX_KATA_VM_NUM)", 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)
@ -66,17 +66,23 @@ def gen_sdc_header(vm_info, config):
print('\t\t\t\t\t"i915.domain_plane_owners=0x011111110000 " \\', file=config)
print('\t\t\t\t\t"i915.enable_gvt=1 "\t\\', file=config)
print("\t\t\t\t\tSOS_BOOTARGS_DIFF", file=config)
print("", file=config)
print("#if CONFIG_MAX_KATA_VM_NUM > 0", file=config)
# POST LAUNCHED VM
print(" #define VM1_CONFIG_VCPU_AFFINITY\t{AFFINITY_CPU(1U), AFFINITY_CPU(2U)}", file=config)
# KATA VM
cpu_affinity_output(vm_info, 2, config)
print("#else", file=config)
for i in range(scenario_cfg_lib.VM_COUNT - 1):
cpu_affinity_output(vm_info, i, config)
print("#endif", file=config)
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)
# KATA VM
cpu_affinity_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)
print("#endif", file=config)
else:
cpu_affinity_output(vm_info, 1, config)
print("", file=config)
print("{0}".format(VM_END_DEFINE), file=config)