mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
acrn-config: add support to parse board defconfig from configurations
Board defconfig depends on hypervisor configurations and vm configurations, add this to support to parse board defconfig from vm configuration. Tracked-On: #4634 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:
parent
d4f789f47e
commit
b30d304d69
@ -12,7 +12,6 @@ import board_c
|
||||
import pci_devices_h
|
||||
import acpi_platform_h
|
||||
import misc_cfg_h
|
||||
import new_board_kconfig
|
||||
import common
|
||||
|
||||
ACRN_PATH = common.SOURCE_ROOT_DIR
|
||||
@ -29,21 +28,18 @@ def main(args):
|
||||
"""
|
||||
err_dic = {}
|
||||
|
||||
(err_dic, board_info_file, scenario_info_file, output_folder) = common.get_param(args)
|
||||
(err_dic, params) = common.get_param(args)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
if output_folder:
|
||||
common.ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/'
|
||||
|
||||
# check env
|
||||
err_dic = common.prepare()
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
common.BOARD_INFO_FILE = board_info_file
|
||||
common.SCENARIO_INFO_FILE = scenario_info_file
|
||||
common.get_vm_num(scenario_info_file)
|
||||
common.BOARD_INFO_FILE = params['--board']
|
||||
common.SCENARIO_INFO_FILE = params['--scenario']
|
||||
common.get_vm_num(params['--scenario'])
|
||||
|
||||
# get board name
|
||||
(err_dic, board) = common.get_board_name()
|
||||
@ -92,12 +88,6 @@ def main(args):
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
# generate ($board).config
|
||||
with open(config_board_kconfig, 'w+') as config:
|
||||
err_dic = new_board_kconfig.generate_file(config)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
if not err_dic:
|
||||
print("Board configurations for {} is generated successfully.".format(board))
|
||||
else:
|
||||
|
@ -6,6 +6,7 @@
|
||||
import sys
|
||||
import subprocess
|
||||
import board_cfg_lib
|
||||
import hv_cfg_lib
|
||||
import common
|
||||
|
||||
|
||||
@ -91,7 +92,7 @@ def get_serial_type():
|
||||
# Get ttySx from scenario config file which selected by user
|
||||
(err_dic, ttyn) = board_cfg_lib.parser_vuart_console()
|
||||
if err_dic:
|
||||
board_cfg_lib.ERR_LIST.update(err_dic)
|
||||
hv_cfg_lib.ERR_LIST.update(err_dic)
|
||||
|
||||
# query the serial type from board config file
|
||||
for line in ttys_lines:
|
||||
@ -120,11 +121,8 @@ def is_rdt_supported():
|
||||
return True
|
||||
|
||||
|
||||
def generate_file(config):
|
||||
"""Start to generate board.c
|
||||
:param config: it is a file pointer of board information for writing to
|
||||
"""
|
||||
err_dic = {}
|
||||
def get_memory(hv_info, config):
|
||||
|
||||
# this dictonary mapped with 'address start':'mem range'
|
||||
ram_range = {}
|
||||
|
||||
@ -147,15 +145,18 @@ def generate_file(config):
|
||||
hv_start_addr = int(avl_start_addr, 16) + int(hex(reserved_ram), 16)
|
||||
hv_start_addr = common.round_up(hv_start_addr, MEM_ALIGN)
|
||||
|
||||
# add config scenario name
|
||||
(err_dic, scenario_name) = common.get_scenario_name()
|
||||
print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
|
||||
print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config)
|
||||
print("CONFIG_PLATFORM_RAM_SIZE={}".format(hv_info.mem.platform_ram_size), file=config)
|
||||
print("CONFIG_LOW_RAM_SIZE={}".format(hv_info.mem.low_ram_size), file=config)
|
||||
print("CONFIG_SOS_RAM_SIZE={}".format(hv_info.mem.sos_ram_size), file=config)
|
||||
print("CONFIG_UOS_RAM_SIZE={}".format(hv_info.mem.uos_ram_size), file=config)
|
||||
print("CONFIG_STACK_SIZE={}".format(hv_info.mem.stack_size), file=config)
|
||||
|
||||
print("{}".format(DESC), file=config)
|
||||
print("CONFIG_{}=y".format(scenario_name.upper()), file=config)
|
||||
print('CONFIG_BOARD="{}"'.format(board_cfg_lib.BOARD_NAME), file=config)
|
||||
|
||||
def get_serial_console(config):
|
||||
|
||||
(serial_type, serial_value) = get_serial_type()
|
||||
|
||||
if serial_type == "portio":
|
||||
print("CONFIG_SERIAL_LEGACY=y", file=config)
|
||||
print("CONFIG_SERIAL_PIO_BASE={}".format(serial_value), file=config)
|
||||
@ -163,17 +164,69 @@ def generate_file(config):
|
||||
print("CONFIG_SERIAL_PCI=y", file=config)
|
||||
print('CONFIG_SERIAL_PCI_BDF="{}"'.format(serial_value), file=config)
|
||||
|
||||
print("CONFIG_HV_RAM_START={}".format(hex(hv_start_addr)), file=config)
|
||||
print("CONFIG_HV_RAM_SIZE={}".format(hex(hv_ram_size)), file=config)
|
||||
|
||||
cpu_core_num = len(board_cfg_lib.get_processor_info())
|
||||
if scenario_name == "sdc" and cpu_core_num > 2:
|
||||
print("CONFIG_MAX_KATA_VM_NUM=1", file=config)
|
||||
else:
|
||||
if cpu_core_num == 2:
|
||||
print("# KATA VM is not supported on dual-core systems", file=config)
|
||||
def get_miscfg(hv_info, config):
|
||||
|
||||
print("CONFIG_MAX_KATA_VM_NUM=0", file=config)
|
||||
print("CONFIG_GPU_SBDF={}".format(hv_info.mis.gpu_sbdf), file=config)
|
||||
print('CONFIG_UEFI_OS_LOADER_NAME="{}"'.format(hv_info.mis.uefi_os_loader_name), file=config)
|
||||
|
||||
|
||||
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_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)
|
||||
print("CONFIG_L1D_FLUSH_VMENTRY_ENABLED={}".format(hv_info.features.l1d_flush_vmentry_enabled), file=config)
|
||||
print("CONFIG_MCE_ON_PSC_WORKAROUND_DISABLED={}".format(hv_info.features.mce_on_psc_workaround_disabled), file=config)
|
||||
|
||||
|
||||
def get_capacities(hv_info, config):
|
||||
|
||||
print("CONFIG_IOMMU_BUS_NUM={}".format(hv_info.cap.iommu_bus_num), file=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)
|
||||
print("CONFIG_MAX_EMULATED_MMIO_REGIONS={}".format(hv_info.cap.max_emu_mmio_regions), file=config)
|
||||
|
||||
|
||||
def get_log_opt(hv_info, config):
|
||||
|
||||
print("CONFIG_LOG_BUF_SIZE={}".format(hv_info.log.buf_size), file=config)
|
||||
print("CONFIG_NPK_LOGLEVEL={}".format(hv_info.log.level.npk), file=config)
|
||||
print("CONFIG_MEM_LOGLEVEL={}".format(hv_info.log.level.mem), file=config)
|
||||
print("CONFIG_LOG_DESTINATION={}".format(hv_info.log.dest), file=config)
|
||||
print("CONFIG_CONSOLE_LOGLEVEL={}".format(hv_info.log.level.console), file=config)
|
||||
|
||||
|
||||
def generate_file(hv_info, config):
|
||||
"""Start to generate board.c
|
||||
:param config: it is a file pointer of board information for writing to
|
||||
"""
|
||||
err_dic = {}
|
||||
|
||||
# add config scenario name
|
||||
(err_dic, scenario_name) = common.get_scenario_name()
|
||||
(err_dic, board_name) = common.get_board_name()
|
||||
|
||||
print("{}".format(DESC), file=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)
|
||||
get_features(hv_info, config)
|
||||
get_capacities(hv_info, config)
|
||||
get_serial_console(config)
|
||||
get_log_opt(hv_info, config)
|
||||
|
||||
if is_rdt_supported():
|
||||
print("CONFIG_RDT_ENABLED=y", file=config)
|
189
misc/acrn-config/hv_config/hv_item.py
Normal file
189
misc/acrn-config/hv_config/hv_item.py
Normal file
@ -0,0 +1,189 @@
|
||||
# Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import common
|
||||
import hv_cfg_lib
|
||||
|
||||
class LogLevel:
|
||||
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.npk = 0
|
||||
self.mem = 0
|
||||
self.console = 0
|
||||
|
||||
def get_info(self):
|
||||
self.npk = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "NPK_LOGLEVEL")
|
||||
self.mem = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "MEM_LOGLEVEL")
|
||||
self.console = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "CONSOLE_LOGLEVEL")
|
||||
|
||||
def check_item(self):
|
||||
hv_cfg_lib.hv_range_check(self.npk, "DEBUG_OPTIONS", "NPK_LOGLEVEL", hv_cfg_lib.RANGE_DB['LOG_LEVEL'])
|
||||
hv_cfg_lib.hv_range_check(self.mem, "DEBUG_OPTIONS", "MEM_LOGLEVEL", hv_cfg_lib.RANGE_DB['LOG_LEVEL'])
|
||||
hv_cfg_lib.hv_range_check(self.console, "DEBUG_OPTIONS", "CONSOLE_LOGLEVEL", hv_cfg_lib.RANGE_DB['LOG_LEVEL'])
|
||||
|
||||
|
||||
class LogOpt:
|
||||
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.dest = 0
|
||||
self.release = ''
|
||||
self.buf_size = 0
|
||||
self.level = LogLevel(self.hv_file)
|
||||
|
||||
def get_info(self):
|
||||
self.release = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "RELEASE")
|
||||
self.dest = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "LOG_DESTINATION")
|
||||
self.buf_size = common.get_hv_item_tag(self.hv_file, "DEBUG_OPTIONS", "LOG_BUF_SIZE")
|
||||
self.level.get_info()
|
||||
|
||||
def check_item(self):
|
||||
hv_cfg_lib.release_check(self.release, "DEBUG_OPTIONS", "RELEASE")
|
||||
hv_cfg_lib.hv_range_check(self.dest, "DEBUG_OPTIONS", "LOG_DESTINATION", hv_cfg_lib.RANGE_DB['LOG_DESTINATION_BITMAP'])
|
||||
hv_cfg_lib.hv_size_check(self.buf_size, "DEBUG_OPTIONS", "LOG_BUF_SIZE")
|
||||
self.level.check_item()
|
||||
|
||||
|
||||
class CapHv:
|
||||
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.max_kata_vm_num = 0
|
||||
self.max_emu_mmio_regions = 0
|
||||
self.max_pt_irq_entries = 0
|
||||
self.max_ioapic_num = 0
|
||||
self.max_ioapic_lines = 0
|
||||
self.max_ir_entries = 0
|
||||
self.iommu_bus_num = 0
|
||||
self.max_pci_dev_num = 0
|
||||
self.max_msix_table_num = 0
|
||||
|
||||
def get_info(self):
|
||||
self.max_kata_vm_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_KATA_VM_NUM")
|
||||
self.max_emu_mmio_regions = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_EMULATED_MMIO")
|
||||
self.max_pt_irq_entries = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_PT_IRQ_ENTRIES")
|
||||
self.max_ioapic_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IOAPIC_NUM")
|
||||
self.max_ioapic_lines = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IOAPIC_LINES")
|
||||
self.max_ir_entries = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_IR_ENTRIES")
|
||||
self.iommu_bus_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "IOMMU_BUS_NUM")
|
||||
self.max_pci_dev_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_PCI_DEV_NUM")
|
||||
self.max_msix_table_num = common.get_hv_item_tag(self.hv_file, "CAPACITIES", "MAX_MSIX_TABLE_NUM")
|
||||
|
||||
def check_item(self):
|
||||
hv_cfg_lib.hv_range_check(self.max_kata_vm_num, "CAPACITIES", "MAX_KATA_VM_NUM", hv_cfg_lib.RANGE_DB['KATA_VM_NUM'])
|
||||
hv_cfg_lib.hv_range_check(self.max_emu_mmio_regions, "CAPACITIES", "MAX_EMULATED_MMIO", hv_cfg_lib.RANGE_DB['EMULATED_MMIO_REGIONS'])
|
||||
hv_cfg_lib.hv_range_check(self.max_pt_irq_entries, "CAPACITIES", "MAX_PT_IRQ_ENTRIES", hv_cfg_lib.RANGE_DB['PT_IRQ_ENTRIES'])
|
||||
hv_cfg_lib.hv_range_check(self.max_ioapic_num, "CAPACITIES", "MAX_IOAPIC_NUM", hv_cfg_lib.RANGE_DB['IOAPIC_NUM'])
|
||||
hv_cfg_lib.hv_range_check(self.max_ioapic_lines, "CAPACITIES", "MAX_IOAPIC_LINES", hv_cfg_lib.RANGE_DB['IOAPIC_LINES'])
|
||||
hv_cfg_lib.ir_entries_check(self.max_ir_entries, "CAPACITIES", "MAX_IR_ENTRIES")
|
||||
hv_cfg_lib.hv_size_check(self.iommu_bus_num, "CAPACITIES", "IOMMU_BUS_NUM")
|
||||
hv_cfg_lib.hv_range_check(self.max_pci_dev_num, "CAPACITIES", "MAX_PCI_DEV_NUM", hv_cfg_lib.RANGE_DB['PCI_DEV_NUM'])
|
||||
hv_cfg_lib.hv_range_check(self.max_msix_table_num, "CAPACITIES", "MAX_MSIX_TABLE_NUM", hv_cfg_lib.RANGE_DB['MSIX_TABLE_NUM'])
|
||||
|
||||
|
||||
class MisCfg:
|
||||
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.gpu_sbdf = 0
|
||||
self.uefi_os_loader_name = ''
|
||||
|
||||
def get_info(self):
|
||||
self.gpu_sbdf = common.get_hv_item_tag(self.hv_file, "MISC_CFG", "GPU_SBDF")
|
||||
self.uefi_os_loader_name = common.get_hv_item_tag(self.hv_file, "MISC_CFG", "UEFI_OS_LOADER_NAME")
|
||||
|
||||
def check_item(self):
|
||||
hv_cfg_lib.hv_size_check(self.gpu_sbdf, "MISC_CFG", "GPU_SBDF")
|
||||
hv_cfg_lib.uefi_load_name_check(self.uefi_os_loader_name, "MISC_CFG", "UEFI_OS_LOADER_NAME")
|
||||
|
||||
|
||||
class Features:
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.reloc = ''
|
||||
self.multiboot2 = ''
|
||||
self.scheduler = ''
|
||||
self.hyperv_enabled = ''
|
||||
self.iommu_enforce_snp = ''
|
||||
self.acpi_parse_enabled = ''
|
||||
self.l1d_flush_vmentry_enabled = ''
|
||||
self.mce_on_psc_workaround_disabled = ''
|
||||
|
||||
def get_info(self):
|
||||
self.multiboot2 = common.get_hv_item_tag(self.hv_file, "FEATURES", "MULTIBOOT2")
|
||||
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")
|
||||
self.acpi_parse_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "ACPI_PARSE_ENABLED")
|
||||
self.l1d_flush_vmentry_enabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "L1D_VMENTRY_ENABLED")
|
||||
self.mce_on_psc_workaround_disabled = common.get_hv_item_tag(self.hv_file, "FEATURES", "MCE_ON_PSC_DISABLED")
|
||||
self.iommu_enforce_snp = common.get_hv_item_tag(self.hv_file, "FEATURES", "IOMMU_ENFORCE_SNP")
|
||||
|
||||
def check_item(self):
|
||||
hv_cfg_lib.ny_support_check(self.multiboot2, "FEATURES", "MULTIBOOT2")
|
||||
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")
|
||||
hv_cfg_lib.ny_support_check(self.acpi_parse_enabled, "FEATURES", "ACPI_PARSE_ENABLED")
|
||||
hv_cfg_lib.ny_support_check(self.l1d_flush_vmentry_enabled, "FEATURES", "L1D_VMENTRY_ENABLED")
|
||||
hv_cfg_lib.ny_support_check(self.mce_on_psc_workaround_disabled, "FEATURES", "MCE_ON_PSC_DISABLED")
|
||||
hv_cfg_lib.ny_support_check(self.iommu_enforce_snp, "FEATURES", "IOMMU_ENFORCE_SNP")
|
||||
|
||||
|
||||
class Memory:
|
||||
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.stack_size = 0
|
||||
self.low_ram_size = 0
|
||||
self.hv_ram_start = 0
|
||||
self.hv_ram_size = 0
|
||||
self.platform_ram_size = 0
|
||||
self.sos_ram_size = 0
|
||||
self.uos_ram_size = 0
|
||||
|
||||
def get_info(self):
|
||||
self.stack_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "STACK_SIZE")
|
||||
self.low_ram_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "LOW_RAM_SIZE")
|
||||
self.hv_ram_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "HV_RAM_SIZE")
|
||||
self.hv_ram_start = common.get_hv_item_tag(self.hv_file, "MEMORY", "HV_RAM_START")
|
||||
self.platform_ram_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "PLATFORM_RAM_SIZE")
|
||||
self.sos_ram_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "SOS_RAM_SIZE")
|
||||
self.uos_ram_size = common.get_hv_item_tag(self.hv_file, "MEMORY", "UOS_RAM_SIZE")
|
||||
|
||||
def check_item(self):
|
||||
hv_cfg_lib.hv_size_check(self.stack_size, "MEMORY", "STACK_SIZE")
|
||||
hv_cfg_lib.hv_size_check(self.low_ram_size, "MEMORY", "LOW_RAM_SIZE")
|
||||
hv_cfg_lib.hv_size_check(self.hv_ram_size, "MEMORY", "HV_RAM_SIZE")
|
||||
hv_cfg_lib.hv_size_check(self.hv_ram_start, "MEMORY", "HV_RAM_START")
|
||||
hv_cfg_lib.hv_size_check(self.platform_ram_size, "MEMORY", "PLATFORM_RAM_SIZE")
|
||||
hv_cfg_lib.hv_size_check(self.sos_ram_size, "MEMORY", "SOS_RAM_SIZE")
|
||||
hv_cfg_lib.hv_size_check(self.uos_ram_size, "MEMORY", "UOS_RAM_SIZE")
|
||||
|
||||
|
||||
class HvInfo:
|
||||
|
||||
def __init__(self, hv_file):
|
||||
self.hv_file = hv_file
|
||||
self.mem = Memory(self.hv_file)
|
||||
self.cap = CapHv(self.hv_file)
|
||||
self.log = LogOpt(self.hv_file)
|
||||
self.mis = MisCfg(self.hv_file)
|
||||
self.features = Features(self.hv_file)
|
||||
|
||||
def get_info(self):
|
||||
self.mem.get_info()
|
||||
self.log.get_info()
|
||||
self.cap.get_info()
|
||||
self.mis.get_info()
|
||||
self.features.get_info()
|
||||
|
||||
def check_item(self):
|
||||
self.mem.check_item()
|
||||
self.log.check_item()
|
||||
self.cap.check_item()
|
||||
self.mis.check_item()
|
||||
self.features.check_item()
|
@ -28,7 +28,7 @@ class AcrnDmArgs:
|
||||
self.args["xhci"] = common.get_leaf_tag_map(self.launch_info, "usb_xhci")
|
||||
|
||||
def check_item(self):
|
||||
rootfs = board_cfg_lib.get_rootfs(self.board_info)
|
||||
(rootfs, num) = board_cfg_lib.get_rootfs(self.board_info)
|
||||
launch_cfg_lib.args_aval_check(self.args["uos_type"], "uos_type", launch_cfg_lib.UOS_TYPES)
|
||||
launch_cfg_lib.args_aval_check(self.args["rtos_type"], "rtos_type", launch_cfg_lib.RTOS_TYPE)
|
||||
launch_cfg_lib.mem_size_check(self.args["mem_size"], "mem_size")
|
||||
|
@ -256,19 +256,15 @@ def parser_vuart_console():
|
||||
ttys_n = ''
|
||||
(err_dic, scenario_name) = common.get_scenario_name()
|
||||
|
||||
if scenario_name != "logical_partition":
|
||||
ttys = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "board_private", "console")
|
||||
else:
|
||||
ttys = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "os_config", "console")
|
||||
ttys = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "DEBUG_OPTIONS", "SERIAL_CONSOLE")
|
||||
|
||||
if not ttys or ttys[0] == None:
|
||||
if not ttys or ttys == None:
|
||||
return (err_dic, ttys_n)
|
||||
|
||||
if ttys and 'BDF' in ttys[0] or '/dev' in ttys[0]:
|
||||
ttys_n = ttys[0].split('/')[2]
|
||||
if ttys and 'BDF' in ttys or '/dev' in ttys:
|
||||
ttys_n = ttys.split('/')[2]
|
||||
else:
|
||||
# sdc/sdc2 is different from logical_partition
|
||||
ttys_n = ttys[0]
|
||||
ttys_n = ttys
|
||||
|
||||
return (err_dic, ttys_n)
|
||||
|
||||
|
@ -95,39 +95,36 @@ def get_param(args):
|
||||
:param args: this the command line of string for the script without script name
|
||||
"""
|
||||
err_dic = {}
|
||||
board_info_file = False
|
||||
scenario_info_file = False
|
||||
output_folder = False
|
||||
|
||||
if '--board' not in args or '--scenario' not in args:
|
||||
usage(args[0])
|
||||
err_dic['common error: get wrong parameter'] = "wrong usage"
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
params = {'--board':'', '--scenario':'', '--out':''}
|
||||
args_list = args[1:]
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'out='])
|
||||
|
||||
try:
|
||||
(optlist, args_list) = getopt.getopt(args_list, '', ['hv=', 'board=', 'scenario=', 'out='])
|
||||
except getopt.GetoptError as err:
|
||||
usage(args[0])
|
||||
sys.exit(2)
|
||||
for arg_k, arg_v in optlist:
|
||||
if arg_k == '--board':
|
||||
board_info_file = arg_v
|
||||
params['--board'] = arg_v
|
||||
if arg_k == '--scenario':
|
||||
scenario_info_file = arg_v
|
||||
params['--scenario'] = arg_v
|
||||
if arg_k == '--out':
|
||||
output_folder = arg_v
|
||||
params['--out'] = arg_v
|
||||
|
||||
if not board_info_file or not scenario_info_file:
|
||||
usage(args[0])
|
||||
err_dic['common error: get wrong parameter'] = "wrong usage"
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
for par_k, par_v in params.items():
|
||||
if par_k == '--out':
|
||||
continue
|
||||
|
||||
if not os.path.exists(board_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
if not par_v:
|
||||
usage(args[0])
|
||||
err_dic['wrong usage'] = "Parameter for {} should not empty".format(par_k)
|
||||
return (err_dic, params)
|
||||
|
||||
if not os.path.exists(scenario_info_file):
|
||||
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file)
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
if not os.path.exists(par_v):
|
||||
err_dic['wrong usage'] = "{} is not exist!".format(par_v)
|
||||
return (err_dic, params)
|
||||
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
return (err_dic, params)
|
||||
|
||||
|
||||
def prepare():
|
||||
@ -167,7 +164,7 @@ def get_xml_attrib(config_file, attrib):
|
||||
if 'board=' in line or 'scenario=' in line:
|
||||
|
||||
if attrib not in line:
|
||||
err_dic['common error: Not match'] = "The root item is not in xml file"
|
||||
err_dic['common error'] = "The {} attribute is not in xml file".format(attrib)
|
||||
return (err_dic, value)
|
||||
|
||||
attrib_list = line.split()
|
||||
@ -392,6 +389,8 @@ def get_leaf_tag_map(config_file, branch_tag, tag_str=''):
|
||||
tmp = TmpItem()
|
||||
root = get_config_root(config_file)
|
||||
for item in root:
|
||||
if not 'id' in item.attrib.keys():
|
||||
continue
|
||||
vm_id = int(item.attrib['id'])
|
||||
# for each 2th level item
|
||||
for sub in item:
|
||||
@ -420,6 +419,29 @@ def get_leaf_tag_map(config_file, branch_tag, tag_str=''):
|
||||
return tmp.tag
|
||||
|
||||
|
||||
def get_hv_item_tag(config_file, branch_tag, tag_str=''):
|
||||
|
||||
tmp = ''
|
||||
root = get_config_root(config_file)
|
||||
for item in root:
|
||||
# for each 2th level item
|
||||
for sub in item:
|
||||
if sub.tag == branch_tag:
|
||||
if not tag_str:
|
||||
if sub.text == None or not sub.text:
|
||||
tmp = ''
|
||||
else:
|
||||
tmp = sub.text
|
||||
continue
|
||||
|
||||
# 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
|
||||
return tmp
|
||||
|
||||
|
||||
def order_type_map_vmid(config_file, vm_count):
|
||||
"""
|
||||
This is mapping table for {id:order type}
|
||||
@ -482,3 +504,18 @@ def mkdir(path):
|
||||
subprocess.check_call('mkdir -p {}'.format(path), shell=True, stdout=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError:
|
||||
print_red("{} file create failed!".format(path), err=True)
|
||||
|
||||
|
||||
def num2int(str_value):
|
||||
|
||||
val = 0
|
||||
if isinstance(str_value, int):
|
||||
val = str_value
|
||||
return val
|
||||
if str_value.isnumeric():
|
||||
val = int(str_value)
|
||||
else:
|
||||
# hex value
|
||||
val = int(str_value, 16)
|
||||
|
||||
return val
|
||||
|
131
misc/acrn-config/library/hv_cfg_lib.py
Normal file
131
misc/acrn-config/library/hv_cfg_lib.py
Normal file
@ -0,0 +1,131 @@
|
||||
# Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import common
|
||||
import getopt
|
||||
|
||||
|
||||
ERR_LIST = {}
|
||||
N_Y = ['n', 'y']
|
||||
SCHEDULER_TYPE = ['SCHED_NOOP', 'SCHED_IORR', 'SCHED_BVT']
|
||||
|
||||
RANGE_DB = {
|
||||
'LOG_LEVEL':{'min':0,'max':6},
|
||||
'LOG_DESTINATION_BITMAP':{'min':0,'max':7},
|
||||
'KATA_VM_NUM':{'min':0,'max':1},
|
||||
'EMULATED_MMIO_REGIONS':{'min':0,'max':128},
|
||||
'PT_IRQ_ENTRIES':{'min':0,'max':256},
|
||||
'IOAPIC_NUM':{'min':1,'max':10},
|
||||
'IOAPIC_LINES':{'min':1,'max':120},
|
||||
'PCI_DEV_NUM':{'min':1,'max':1024},
|
||||
'MSIX_TABLE_NUM':{'min':1,'max':2048},
|
||||
}
|
||||
|
||||
|
||||
def empty_check(val, prime_item, item):
|
||||
if not val or val == None:
|
||||
key = 'hv,{},{}'.format(prime_item, item)
|
||||
ERR_LIST[key] = "{} should not empty".format(item)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def is_numeric_check(str_value, prime_item, item):
|
||||
|
||||
# to skip for strip 0x/0X
|
||||
if str_value == '0':
|
||||
return True
|
||||
str_hex_0x = str_value.lstrip('0x')
|
||||
str_hex_0X = str_value.lstrip('0X')
|
||||
|
||||
if not str_hex_0x.isnumeric() and not str_hex_0X.isnumeric():
|
||||
if not isinstance(int(str_hex_0x, 16), int) and not isinstance(int(str_hex_0X, 16), int):
|
||||
key = 'hv,{},{}'.format(prime_item, item)
|
||||
ERR_LIST[key] = "{} should be a numeric".format(item)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def range_check(str_value, prime_item, item, range_val):
|
||||
|
||||
value = common.num2int(str_value)
|
||||
if value < range_val['min'] or value > range_val['max']:
|
||||
key = 'hv,{},{}'.format(prime_item, item)
|
||||
ERR_LIST[key] = "{} should be in range[{},{}]".format(item, range_val['min'], range_val['max'])
|
||||
|
||||
|
||||
def release_check(sel_str, dbg_opt, rel_str):
|
||||
if empty_check(sel_str, dbg_opt, rel_str):
|
||||
return
|
||||
if sel_str not in N_Y:
|
||||
key = 'hv,{},{}'.format(dbg_opt, rel_str)
|
||||
ERR_LIST[key] = "{} should be in {}".format(rel_str, N_Y)
|
||||
|
||||
|
||||
def hv_range_check(str_val, branch_tag, item, range_db):
|
||||
|
||||
if empty_check(str_val, branch_tag, item):
|
||||
return
|
||||
if not is_numeric_check(str_val, branch_tag, item):
|
||||
return
|
||||
range_check(str_val, branch_tag, item, range_db)
|
||||
|
||||
|
||||
def hv_size_check(str_val, branch_tag, item):
|
||||
|
||||
if empty_check(str_val, branch_tag, item):
|
||||
return
|
||||
if not is_numeric_check(str_val, branch_tag, item):
|
||||
return
|
||||
|
||||
|
||||
def ir_entries_check(str_num, cap, cap_ir_entries):
|
||||
hv_size_check(str_num, cap, cap_ir_entries)
|
||||
val = common.num2int(str_num)
|
||||
if val % 2 != 0:
|
||||
key = 'hv,{},{}'.format(cap, cap_ir_entries)
|
||||
ERR_LIST[key] = "{} should be a value of 2^n".format(cap_ir_entries)
|
||||
|
||||
|
||||
def uefi_load_name_check(str_name, mis, mis_uefi_name):
|
||||
if empty_check(str_name, mis, mis_uefi_name):
|
||||
return
|
||||
name_len = len(str_name)
|
||||
if name_len > 256 or name_len < 1:
|
||||
key = 'hv,{},{}'.format(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):
|
||||
return
|
||||
if sel_str not in N_Y:
|
||||
key = 'hv,{},{}'.format(feat, feat_item)
|
||||
ERR_LIST[key] = "{} should be in {}".format(feat_item, N_Y)
|
||||
|
||||
|
||||
def scheduler_check(sel_str, feat, feat_scheduler):
|
||||
if empty_check(sel_str, feat, feat_scheduler):
|
||||
return
|
||||
if sel_str not in SCHEDULER_TYPE:
|
||||
key = 'hv,{},{}'.format(feat, feat_scheduler)
|
||||
ERR_LIST[key] = "{} should be in {}".format(feat_scheduler, SCHEDULER_TYPE)
|
||||
|
||||
|
||||
def get_select_range(branch_tag, range_key):
|
||||
|
||||
range_list = []
|
||||
if range_key not in RANGE_DB.keys():
|
||||
key = "hv,{},{}".format(branch_tag, range_key)
|
||||
ERR_LIST[key] = "It is invalid for {}.".format(range_key)
|
||||
return range_list
|
||||
|
||||
for range_i in range(RANGE_DB[range_key]['min'], RANGE_DB[range_key]['max'] + 1):
|
||||
range_list.append(str(range_i))
|
||||
|
||||
return range_list
|
@ -467,7 +467,7 @@ def pt_devs_check_audio(audio_map, audio_codec_map):
|
||||
|
||||
|
||||
def check_block_mount(virtio_blk_dic):
|
||||
blk_dev_list = board_cfg_lib.get_rootfs(common.BOARD_INFO_FILE)
|
||||
(blk_dev_list, num) = board_cfg_lib.get_rootfs(common.BOARD_INFO_FILE)
|
||||
for vmid in list(virtio_blk_dic.keys()):
|
||||
mount_flags = []
|
||||
for blk in virtio_blk_dic[vmid]:
|
||||
|
@ -335,7 +335,7 @@ def os_kern_args_check(id_kern_args_dic, prime_item, item):
|
||||
ERR_LIST[key] = "VM os config kernel service os should be SOS_VM_BOOTARGS"
|
||||
|
||||
|
||||
def os_kern_console_check(id_kern_console_dic, prime_item, item):
|
||||
def os_kern_console_check(tty_console, prime_item, item):
|
||||
"""
|
||||
Check os kernel console
|
||||
:param prime_item: the prime item in xml file
|
||||
@ -343,10 +343,9 @@ def os_kern_console_check(id_kern_console_dic, prime_item, item):
|
||||
:return: None
|
||||
"""
|
||||
|
||||
for id_key, kern_console in id_kern_console_dic.items():
|
||||
if kern_console and "ttyS" not in kern_console:
|
||||
key = "vm:id={},{},{}".format(id_key, prime_item, item)
|
||||
ERR_LIST[key] = "VM os config kernel console should be ttyS[0..3]"
|
||||
if tty_console and "ttyS" not in tty_console:
|
||||
key = "hv:{},{}".format(prime_item, item)
|
||||
ERR_LIST[key] = "VM os config kernel console should be ttyS[0..3]"
|
||||
|
||||
|
||||
def os_kern_load_addr_check(id_kern_load_addr_dic, prime_item, item):
|
||||
|
@ -7,6 +7,7 @@ import os
|
||||
import sys
|
||||
import copy
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'hv_config'))
|
||||
from scenario_item import HwInfo, VmInfo
|
||||
import board_cfg_lib
|
||||
import scenario_cfg_lib
|
||||
@ -14,10 +15,14 @@ import vm_configurations_c
|
||||
import vm_configurations_h
|
||||
import pci_dev_c
|
||||
import common
|
||||
import hv_cfg_lib
|
||||
import board_defconfig
|
||||
from hv_item import HvInfo
|
||||
|
||||
ACRN_PATH = common.SOURCE_ROOT_DIR
|
||||
ACRN_CONFIG_DEF = ACRN_PATH + 'hypervisor/scenarios/'
|
||||
GEN_FILE = ["vm_configurations.h", "vm_configurations.c", "pci_dev.c"]
|
||||
ACRN_CONFIGS = ACRN_PATH + "hypervisor/arch/x86/configs/"
|
||||
GEN_FILE = ["vm_configurations.h", "vm_configurations.c", "pci_dev.c", ".config"]
|
||||
|
||||
|
||||
def get_scenario_item_values(board_info, scenario_info):
|
||||
@ -27,6 +32,7 @@ def get_scenario_item_values(board_info, scenario_info):
|
||||
"""
|
||||
scenario_item_values = {}
|
||||
hw_info = HwInfo(board_info)
|
||||
hv_info = HvInfo(scenario_info)
|
||||
|
||||
# get vm count
|
||||
common.BOARD_INFO_FILE = board_info
|
||||
@ -44,12 +50,31 @@ def get_scenario_item_values(board_info, scenario_info):
|
||||
scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
|
||||
|
||||
# pre board_private
|
||||
scenario_item_values["vm,board_private,rootfs"] = board_cfg_lib.get_rootfs(board_info)
|
||||
scenario_item_values["vm,board_private,console"] = board_cfg_lib.get_ttys_info(board_info)
|
||||
(scenario_item_values["vm,board_private,rootfs"], num) = board_cfg_lib.get_rootfs(board_info)
|
||||
|
||||
# os config
|
||||
scenario_item_values["vm,os_config,rootfs"] = board_cfg_lib.get_rootfs(board_info)
|
||||
(scenario_item_values["vm,os_config,rootfs"], num) = board_cfg_lib.get_rootfs(board_info)
|
||||
|
||||
scenario_item_values["hv,DEBUG_OPTIONS,RELEASE"] = hv_cfg_lib.N_Y
|
||||
scenario_item_values["hv,DEBUG_OPTIONS,NPK_LOGLEVEL"] = hv_cfg_lib.get_select_range("DEBUG_OPTIONS", "LOG_LEVEL")
|
||||
scenario_item_values["hv,DEBUG_OPTIONS,MEM_LOGLEVEL"] = hv_cfg_lib.get_select_range("DEBUG_OPTIONS", "LOG_LEVEL")
|
||||
scenario_item_values["hv,DEBUG_OPTIONS,CONSOLE_LOGLEVEL"] = hv_cfg_lib.get_select_range("DEBUG_OPTIONS", "LOG_LEVEL")
|
||||
scenario_item_values["hv,DEBUG_OPTIONS,SERIAL_CONSOLE"] = board_cfg_lib.get_ttys_info(board_info)
|
||||
scenario_item_values["hv,DEBUG_OPTIONS,LOG_DESTINATION"] = hv_cfg_lib.get_select_range("DEBUG_OPTIONS", "LOG_DESTINATION_BITMAP")
|
||||
|
||||
scenario_item_values["hv,CAPACITIES,MAX_KATA_VM_NUM"] = hv_cfg_lib.get_select_range("CAPACITIES", "KATA_VM_NUM")
|
||||
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,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
|
||||
scenario_item_values["hv,FEATURES,ACPI_PARSE_ENABLED"] = hv_cfg_lib.N_Y
|
||||
scenario_item_values["hv,FEATURES,L1D_VMENTRY_ENABLED"] = hv_cfg_lib.N_Y
|
||||
scenario_item_values["hv,FEATURES,MCE_ON_PSC_DISABLED"] = hv_cfg_lib.N_Y
|
||||
scenario_item_values["hv,FEATURES,IOMMU_ENFORCE_SNP"] = hv_cfg_lib.N_Y
|
||||
|
||||
scenario_cfg_lib.ERR_LIST.update(hv_cfg_lib.ERR_LIST)
|
||||
return scenario_item_values
|
||||
|
||||
|
||||
@ -64,13 +89,20 @@ def validate_scenario_setting(board_info, scenario_info):
|
||||
common.BOARD_INFO_FILE = board_info
|
||||
common.SCENARIO_INFO_FILE = scenario_info
|
||||
|
||||
scenario_info_items = {}
|
||||
vm_info = VmInfo(board_info, scenario_info)
|
||||
|
||||
vm_info.get_info()
|
||||
|
||||
vm_info.check_item()
|
||||
|
||||
return (scenario_cfg_lib.ERR_LIST, vm_info)
|
||||
hv_info = HvInfo(scenario_info)
|
||||
hv_info.get_info()
|
||||
hv_info.check_item()
|
||||
|
||||
scenario_info_items['vm'] = vm_info
|
||||
scenario_info_items['hv'] = hv_info
|
||||
|
||||
scenario_cfg_lib.ERR_LIST.update(hv_cfg_lib.ERR_LIST)
|
||||
return (scenario_cfg_lib.ERR_LIST, scenario_info_items)
|
||||
|
||||
|
||||
def main(args):
|
||||
@ -80,20 +112,22 @@ def main(args):
|
||||
"""
|
||||
err_dic = {}
|
||||
|
||||
(err_dic, board_info_file, scenario_info_file, output_folder) = common.get_param(args)
|
||||
(err_dic, params) = common.get_param(args)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
if output_folder:
|
||||
common.ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/'
|
||||
|
||||
# check env
|
||||
err_dic = common.prepare()
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
common.BOARD_INFO_FILE = board_info_file
|
||||
common.SCENARIO_INFO_FILE = scenario_info_file
|
||||
common.BOARD_INFO_FILE = params['--board']
|
||||
common.SCENARIO_INFO_FILE = params['--scenario']
|
||||
common.ACRN_CONFIG_TARGET= os.path.abspath(params['--out']) + '/'
|
||||
common.get_vm_num(params['--scenario'])
|
||||
|
||||
# get board name
|
||||
(err_dic, board_name) = common.get_board_name()
|
||||
|
||||
# get scenario name
|
||||
(err_dic, scenario) = common.get_scenario_name()
|
||||
@ -103,13 +137,16 @@ def main(args):
|
||||
# check if this is the scenario config which matched board info
|
||||
(err_dic, status) = common.is_config_file_match()
|
||||
if not status:
|
||||
err_dic['scenario config: Not match'] = "The board xml and scenario xml should be matched!"
|
||||
err_dic['scenario config'] = "The board xml and scenario xml should be matched!"
|
||||
return err_dic
|
||||
|
||||
if common.ACRN_CONFIG_TARGET:
|
||||
if params['--out']:
|
||||
scenario_dir = common.ACRN_CONFIG_TARGET + scenario + '/'
|
||||
config_hv = common.ACRN_CONFIG_TARGET + board_name + GEN_FILE[3]
|
||||
else:
|
||||
scenario_dir = ACRN_CONFIG_DEF + scenario + '/'
|
||||
config_hv = ACRN_CONFIGS + board_name + GEN_FILE[3]
|
||||
common.print_yel("{}".format("Override board defconfig...", warn=True))
|
||||
common.mkdir(scenario_dir)
|
||||
|
||||
vm_config_h = scenario_dir + GEN_FILE[0]
|
||||
@ -117,26 +154,31 @@ def main(args):
|
||||
pci_config_c = scenario_dir + GEN_FILE[2]
|
||||
|
||||
# parse the scenario.xml
|
||||
get_scenario_item_values(board_info_file, scenario_info_file)
|
||||
(err_dic, vm_info) = validate_scenario_setting(board_info_file, scenario_info_file)
|
||||
get_scenario_item_values(params['--board'], params['--scenario'])
|
||||
(err_dic, scenario_items) = validate_scenario_setting(params['--board'], params['--scenario'])
|
||||
if err_dic:
|
||||
common.print_red("Validate the scenario item failue", err=True)
|
||||
common.print_red("Validate the scenario item failure", err=True)
|
||||
return err_dic
|
||||
|
||||
# get kata vm count
|
||||
if scenario != "logical_partition":
|
||||
scenario_cfg_lib.KATA_VM_COUNT = common.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!"
|
||||
scenario_cfg_lib.KATA_VM_COUNT = int(scenario_items['hv'].cap.max_kata_vm_num)
|
||||
if scenario_cfg_lib.KATA_VM_COUNT > 1:
|
||||
err_dic['scenario config'] = "Only one kata vm is supported!"
|
||||
return err_dic
|
||||
|
||||
# generate board defconfig
|
||||
with open(config_hv, 'w+') as config:
|
||||
err_dic = board_defconfig.generate_file(scenario_items['hv'], config)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
# generate vm_configuration.h
|
||||
with open(vm_config_h, 'w') as config:
|
||||
vm_configurations_h.generate_file(scenario, vm_info, config)
|
||||
vm_configurations_h.generate_file(scenario, scenario_items['vm'], config)
|
||||
|
||||
# generate vm_configuration.c
|
||||
with open(vm_config_c, 'w') as config:
|
||||
err_dic = vm_configurations_c.generate_file(scenario, vm_info, config)
|
||||
err_dic = vm_configurations_c.generate_file(scenario, scenario_items['vm'], config)
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
|
@ -31,7 +31,7 @@ class HwInfo:
|
||||
Get root devices from board info
|
||||
:return: root devices list
|
||||
"""
|
||||
self.root_dev_val = common.get_rootfs(self.board_info)
|
||||
(self.root_dev_val, num) = common.get_rootfs(self.board_info)
|
||||
return self.root_dev_val
|
||||
|
||||
def get_ttys_val(self):
|
||||
@ -95,8 +95,8 @@ class CfgOsKern:
|
||||
self.scenario_info, "os_config", "kern_mod")
|
||||
self.kern_args = common.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "bootargs")
|
||||
self.kern_console = common.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "console")
|
||||
self.kern_console = common.get_hv_item_tag(
|
||||
self.scenario_info, "DEBUG_OPTIONS", "SERIAL_CONSOLE")
|
||||
self.kern_load_addr = common.get_leaf_tag_map(
|
||||
self.scenario_info, "os_config", "kern_load_addr")
|
||||
self.kern_entry_addr = common.get_leaf_tag_map(
|
||||
@ -117,48 +117,16 @@ class CfgOsKern:
|
||||
scenario_cfg_lib.os_kern_type_check(self.kern_type, "os_config", "kern_type")
|
||||
scenario_cfg_lib.os_kern_mod_check(self.kern_mod, "os_config", "kern_mod")
|
||||
scenario_cfg_lib.os_kern_args_check(self.kern_args, "os_config", "kern_args")
|
||||
scenario_cfg_lib.os_kern_console_check(self.kern_console, "os_config", "console")
|
||||
scenario_cfg_lib.os_kern_console_check(self.kern_console, "DEBUG_OPTIONS", "SERIAL_CONSOLE")
|
||||
scenario_cfg_lib.os_kern_load_addr_check(self.kern_load_addr, "os_config", "kern_load_addr")
|
||||
scenario_cfg_lib.os_kern_entry_addr_check(self.kern_entry_addr, "os_config", "kern_entry_addr")
|
||||
scenario_cfg_lib.os_kern_root_dev_check(self.kern_root_dev, "os_config", "rootdev")
|
||||
|
||||
|
||||
class VuartTarget:
|
||||
""" This is Abstract of class of vm target vuart """
|
||||
t_vm_id = []
|
||||
t_vuart_id = []
|
||||
|
||||
def __init__(self):
|
||||
self.t_vm_id = []
|
||||
|
||||
def style_check_1(self):
|
||||
""" This is public method for style check"""
|
||||
self.t_vm_id = []
|
||||
|
||||
def style_check_2(self):
|
||||
""" This is public method for style check"""
|
||||
self.t_vm_id = []
|
||||
|
||||
|
||||
class VuartCfg(VuartTarget):
|
||||
""" This is Abstract of class of vm vuart configuration """
|
||||
v_type = []
|
||||
v_base = []
|
||||
v_irq = []
|
||||
target = VuartTarget()
|
||||
|
||||
def __init__(self):
|
||||
self.v1_type = []
|
||||
|
||||
def style_check_1(self):
|
||||
""" This is public method for style check"""
|
||||
self.v1_type = []
|
||||
|
||||
|
||||
class VuartInfo:
|
||||
""" This is Abstract of class of vm vuart setting """
|
||||
v0_vuart = VuartCfg()
|
||||
v1_vuart = VuartCfg()
|
||||
v0_vuart = {}
|
||||
v1_vuart = {}
|
||||
|
||||
def __init__(self, scenario_file):
|
||||
self.scenario_info = scenario_file
|
||||
|
@ -194,7 +194,7 @@ def gen_logical_partition_header(vm_info, 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[i].strip('/dev/')), file=config)
|
||||
i, vm_info.os_cfg.kern_console.strip('/dev/')), file=config)
|
||||
print("", file=config)
|
||||
|
||||
print('/* VM pass-through devices assign policy:', file=config)
|
||||
|
Loading…
Reference in New Issue
Block a user