def get_scenario_item_values(board_info, scenario_info):
    """
    Glue code to provide user selectable options to config UI tool.
    Return a dictionary of key-value pairs containing features and corresponding lists of
    user selectable values to the config UI tool.
    :param board_info: file that contains board information
    """
    hv_cfg_lib.ERR_LIST = {}
    scenario_item_values = {}
    hw_info = HwInfo(board_info)
    hv_info = HvInfo(scenario_info)

    # get vm count
    common.BOARD_INFO_FILE = board_info
    common.SCENARIO_INFO_FILE = scenario_info
    common.get_vm_num(scenario_info)
    common.get_load_order()

    # per scenario
    guest_flags = copy.deepcopy(common.GUEST_FLAG)
    guest_flags.remove('0UL')
    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,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["vm,mmio_resources,p2sb"] = hv_cfg_lib.N_Y
    scenario_item_values["vm,mmio_resources,TPM2"] = hv_cfg_lib.N_Y
    scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
    scenario_item_values["vm,console_vuart,base"] = ['INVALID_PCI_BASE', 'PCI_VUART']
    scenario_item_values["vm,communication_vuart,base"] = ['INVALID_PCI_BASE', 'PCI_VUART']

    # board

    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_native_ttys_info(board_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,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_item_values["hv,FEATURES,IVSHMEM,IVSHMEM_ENABLED"] = hv_cfg_lib.N_Y
    scenario_item_values["hv,FEATURES,SSRAM,SSRAM_ENABLED"] = hv_cfg_lib.N_Y

    scenario_cfg_lib.ERR_LIST.update(hv_cfg_lib.ERR_LIST)
    return scenario_item_values
Beispiel #2
0
def main(args):
    # Initialize configuration libraries for backward compatibility
    common.BOARD_INFO_FILE = args.board
    common.SCENARIO_INFO_FILE = args.scenario
    common.get_vm_num(args.scenario)
    common.get_load_order()

    scripts_path = os.path.dirname(os.path.realpath(__file__))
    current = os.path.basename(__file__)

    board_etree = lxml.etree.parse(args.board)
    scenario_etree = lxml.etree.parse(args.scenario)
    allocation_etree = lxml.etree.ElementTree(element=lxml.etree.fromstring("<acrn-config></acrn-config>"))
    for script in [f for f in os.listdir(scripts_path) if f.endswith(".py") and f != current]:
        module_name = os.path.splitext(script)[0]
        module = import_module(f"{module_name}")
        module.fn(board_etree, scenario_etree, allocation_etree)
    allocation_etree.write(args.output, pretty_print=True)
def main(args):
    """
    Generate board related source code
    :param args: command line args
    """
    err_dic = {}

    (err_dic, params) = common.get_param(args)
    if err_dic:
        return err_dic

    # check env
    err_dic = common.prepare()
    if err_dic:
        return err_dic

    common.BOARD_INFO_FILE = params['--board']
    common.SCENARIO_INFO_FILE = params['--scenario']
    common.get_vm_num(params['--scenario'])
    common.get_load_order()

    # get board name
    (err_dic, board_name) = common.get_board_name()

    # get scenario name
    (err_dic, scenario) = common.get_scenario_name()
    if err_dic:
        return err_dic

    if common.VM_COUNT > common.MAX_VM_NUM:
        err_dic['vm count'] = "Number of VMs in scenario xml file should be no greater than hv/CAPACITIES/MAX_VM_NUM ! " \
                              "Now this value is {}.".format(common.MAX_VM_NUM)
        return err_dic

    # check if this is the scenario config which matches board info
    (err_dic, status) = common.is_config_file_match()
    if not status:
        err_dic['scenario config'] = "The board xml file does not match scenario xml file!"
        return err_dic

    if params['--out']:
        if os.path.isabs(params['--out']):
            scen_output = params['--out'] + "/scenarios/" + scenario + "/"
        else:
            scen_output = ACRN_PATH + params['--out'] + "/scenarios/" + scenario + "/"
    else:
        scen_output = ACRN_CONFIG_DEF + "/" + scenario + "/"

    scen_board = scen_output + "/"
    common.mkdir(scen_board)
    common.mkdir(scen_output)

    vm_config_h  = scen_output + GEN_FILE[0]
    vm_config_c  = scen_output + GEN_FILE[1]
    pci_config_c = scen_board + GEN_FILE[2]
    config_hv = scen_board + board_name + GEN_FILE[3]
    ivshmem_config_h = scen_board + GEN_FILE[4]
    pt_intx_config_c = scen_board + GEN_FILE[5]

    # parse the scenario.xml
    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("Scenario xml file validation failed:", err=True)
        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 ASL code of ACPI tables for Pre-launched VMs
    if not err_dic:
        err_dic = asl_gen.main(args)

    if not err_dic:
        print("Scenario configuration files were created successfully.")
    else:
        print("Failed to create scenario configuration files.")

    return err_dic
def main(args):
    """
    This is main function to start generate source code related with board
    :param args: it is a command line args for the script
    """
    err_dic = {}

    (err_dic, params) = common.get_param(args)
    if err_dic:
        return err_dic

    # check env
    err_dic = common.prepare()
    if err_dic:
        return err_dic

    common.BOARD_INFO_FILE = params['--board']
    common.SCENARIO_INFO_FILE = params['--scenario']
    common.get_vm_num(params['--scenario'])
    common.get_load_order()

    if common.VM_COUNT > common.MAX_VM_NUM:
        err_dic['vm count'] = "The number of VMs in the scenario XML file should be no greater than " \
                              "hv.CAPACITIES.MAX_VM_NUM. Its current value is {}.".format(common.MAX_VM_NUM)
        return err_dic

    # check if this is the scenario config which matched board info
    # get board name
    (err_dic, board) = common.get_board_name()
    if err_dic:
        return err_dic

    (err_dic, scenario) = common.get_scenario_name()
    if err_dic:
        return err_dic
    board_cfg_lib.BOARD_NAME = board

    # check if this is the scenario config which matched board info
    (err_dic, status) = common.is_config_file_match()
    if not status:
        err_dic['board config'] = "The board xml file does not match scenario xml file!"
        return err_dic

    output = ''
    if params['--out']:
        if os.path.isabs(params['--out']):
            output = params['--out']
        else:
            output = ACRN_PATH + params['--out']
    else:
        output = ACRN_CONFIG_DEF

    board_fix_dir = os.path.join(output, "boards/")
    scen_board_dir = os.path.join(output, "scenarios/" + scenario + "/")
    common.mkdir(board_fix_dir)
    common.mkdir(scen_board_dir)

    config_pci = board_fix_dir + GEN_FILE[0]
    config_board = board_fix_dir + GEN_FILE[1]
    config_acpi =  board_fix_dir + GEN_FILE[2]
    config_board_h =  board_fix_dir + GEN_FILE[4]

    # generate pci_devices.h
    with open(config_pci, 'w+') as config:
        pci_devices_h.generate_file(config)

    # generate board_info.h
    with open(config_board_h, 'w+') as config:
        err_dic = board_info_h.generate_file(config)
        if err_dic:
            return err_dic

    # generate board.c
    with open(config_board, 'w+') as config:
        err_dic = board_c.generate_file(config)
        if err_dic:
            return err_dic

    # generate platform_acpi_info.h
    with open(config_acpi, 'w+') as config:
        acpi_platform_h.generate_file(config, ACRN_DEFAULT_ACPI)

    if not err_dic:
        print("Board configurations for {} is generated successfully.".format(board))
    else:
        print("Board configurations for {} is generated failed.".format(board))

    return err_dic