def vuart_output(i, vm_info, config): """ This is generate vuart setting :param i: vm id number :param vm_info: it is the class which contain all user setting information :param config: it is the pointer which file write to :return: None """ vuart1_vmid_dic = {} vuart1_vmid_dic = scenario_cfg_lib.get_vuart1_vmid(vm_info.vuart.v1_vuart) vm_type = scenario_cfg_lib.get_order_type_by_vmid(i) vuart0_output(i, vm_type, vm_info, config) vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config) print("\t\t},", file=config) # pci_dev_num/pci_devs only for SOS_VM or logical_partition pre_launched_vm if vm_type == "SOS_VM": print("\t\t.pci_dev_num = {},".format(vm_info.cfg_pci.pci_dev_num[0]), file=config) print("\t\t.pci_devs = {},".format(vm_info.cfg_pci.pci_devs[0]), file=config) (err_dic, scenario_name) = scenario_cfg_lib.get_scenario_name() if err_dic: return err_dic if scenario_name == "logical_partition": print("\t\t.pci_dev_num = VM{}_CONFIG_PCI_DEV_NUM,".format(i), file=config) print("\t\t.pci_devs = vm{}_pci_devs,".format(i), file=config) print("\t},", file=config) 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 """ global ACRN_CONFIG_TARGET err_dic = {} (err_dic, board_info_file, scenario_info_file, output_folder) = scenario_cfg_lib.get_param(args) if err_dic: return err_dic if output_folder: ACRN_CONFIG_TARGET = os.path.abspath(output_folder) + '/' # check env err_dic = scenario_cfg_lib.prepare() 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 scenario_dir = ACRN_CONFIG_TARGET + scenario + '/' scenario_cfg_lib.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: 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) # 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