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_vm_types() # 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'] = "The vm count in config xml should be less or equal {}!".format( common.MAX_VM_NUM) return err_dic # 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'] = "The board xml and scenario xml should be matched!" return err_dic if params['--out']: if os.path.isabs(params['--out']): scenario_dir = os.path.join(params['--out'], scenario + '/') config_hv = os.path.join(params['--out'], board_name + GEN_FILE[3]) else: scenario_dir = os.path.join(ACRN_PATH + params['--out'], scenario + '/') config_hv = os.path.join(ACRN_PATH + params['--out'], board_name + GEN_FILE[3]) else: scenario_dir = os.path.join(ACRN_CONFIG_DEF, scenario + '/') config_hv = os.path.join(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] vm_config_c = scenario_dir + GEN_FILE[1] pci_config_c = scenario_dir + GEN_FILE[2] # 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("Validate the scenario item failure", 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 vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario_items, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario_items['vm'], config) if err_dic: return err_dic # generate pci_dev.c for vm_i, pci_dev_num in scenario_items['vm'].cfg_pci.pci_dev_num.items(): if pci_dev_num >= 2: with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(scenario_items['vm'], config) break if not err_dic: print( "Scenario configurations for {} is generated successfully.".format( scenario)) else: print("Scenario configurations for {} is generated failed.".format( scenario)) return err_dic
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_vm_types() # 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 {}!".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 + board_name + "/" 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 vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario_items, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario_items, config) if err_dic: return err_dic # generate ivshmem_cfg.h with open(ivshmem_config_h, 'w') as config: ivshmem_cfg_h.generate_file(scenario_items, config) # generate pci_dev.c with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(scenario_items['vm'], config) # generate pt_intx.c with open(pt_intx_config_c, 'w') as config: pt_intx_c.generate_file(scenario_items['vm'], config) # generate ASL code of ACPI tables for Pre-launched VMs 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 = {} config_srcs = [] (err_dic, board_info_file, scenario_info_file) = scenario_cfg_lib.get_param(args) if err_dic: return err_dic scenario_cfg_lib.BOARD_INFO_FILE = board_info_file scenario_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file # get scenario name (err_dic, scenario) = scenario_cfg_lib.get_scenario_name() if err_dic: return err_dic # check if this is the scenario config which matched board info (err_dic, status) = scenario_cfg_lib.is_config_file_match() if not status: err_dic[ 'scenario config: Not match'] = "The board xml and scenario xml should be matched!" return err_dic vm_config_h = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[0] vm_config_c = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[1] pci_config_c = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[2] config_srcs.append(vm_config_h) config_srcs.append(vm_config_c) if scenario == "logical_partition": config_srcs.append(pci_config_c) # 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) if err_dic: scenario_cfg_lib.print_red("Validate the scenario item failue", err=True) return err_dic # generate vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario, vm_info, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario, vm_info, config) if err_dic: return err_dic # generate pci_dev.c if scenario is logical_partition if scenario == 'logical_partition': with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(config) # move changes to patch, and apply to the source code err_dic = scenario_cfg_lib.gen_patch(config_srcs, scenario) if not err_dic: print( "Config patch for {} is committed successfully!".format(scenario)) else: print("Config patch for {} is failed".format(scenario)) 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, board_info_file, scenario_info_file, output_folder) = 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 # get scenario name (err_dic, scenario) = common.get_scenario_name() if err_dic: return err_dic # 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!" return err_dic if common.ACRN_CONFIG_TARGET: scenario_dir = common.ACRN_CONFIG_TARGET + scenario + '/' else: scenario_dir = ACRN_CONFIG_DEF + scenario + '/' common.mkdir(scenario_dir) vm_config_h = scenario_dir + GEN_FILE[0] vm_config_c = scenario_dir + GEN_FILE[1] 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) if err_dic: common.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 = 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!" return err_dic # generate vm_configuration.h with open(vm_config_h, 'w') as config: vm_configurations_h.generate_file(scenario, vm_info, config) # generate vm_configuration.c with open(vm_config_c, 'w') as config: err_dic = vm_configurations_c.generate_file(scenario, vm_info, config) if err_dic: return err_dic # generate pci_dev.c if scenario is logical_partition if scenario == 'logical_partition': with open(pci_config_c, 'w') as config: pci_dev_c.generate_file(config) if not err_dic: print( "Scenario configurations for {} is generated successfully.".format( scenario)) else: print("Scenario configurations for {} is generated failed.".format( scenario)) return err_dic