diff --git a/misc/acrn-config/launch_config/com.py b/misc/acrn-config/launch_config/com.py index 291e56885..98957ae25 100644 --- a/misc/acrn-config/launch_config/com.py +++ b/misc/acrn-config/launch_config/com.py @@ -17,10 +17,18 @@ def is_nuc_whl_clr(names, vmid): return False -def is_mount_needed(names, vmid): - uos_type = names['uos_types'][vmid] - if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS") and not is_nuc_whl_clr(names, vmid): - return True +def is_mount_needed(virt_io, vmid): + rootfs_img = '' + blk_dev_list = launch_cfg_lib.get_rootdev_info(launch_cfg_lib.BOARD_INFO_FILE) + if virt_io['block'][vmid]: + if ':' in virt_io['block'][vmid]: + blk_dev = virt_io['block'][vmid].split(':')[0] + rootfs_img = virt_io['block'][vmid].split(':')[1] + else: + blk_dev = virt_io['block'][vmid] + + if blk_dev in blk_dev_list and rootfs_img: + return True return False @@ -264,7 +272,7 @@ def mem_size_set(args, vmid, config): print("mem_size={}M".format(mem_size), file=config) -def uos_launch(names, args, vmid, config): +def uos_launch(names, args, virt_io, vmid, config): gvt_args = args['gvt_args'][vmid] uos_type = names['uos_types'][vmid] @@ -294,14 +302,14 @@ def uos_launch(names, args, vmid, config): if uos_type in ("CLEARLINUX", "WINDOWS"): print('launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) - if is_mount_needed(names, vmid): + if is_mount_needed(virt_io, vmid): print("", file=config) print('launch_{} {} "{}" "{}" $debug'.format(launch_uos, vmid, gvt_args, vmid), file=config) print("", file=config) print("umount /data", file=config) -def launch_end(names, args, vmid, config): +def launch_end(names, args, virt_io, vmid, config): board_name = names['board_name'] uos_type = names['uos_types'][vmid] @@ -327,8 +335,8 @@ def launch_end(names, args, vmid, config): print("done", file=config) print("", file=config) - if is_mount_needed(names, vmid): - root_fs = args['rootfs_dev'][vmid] + if is_mount_needed(virt_io, vmid): + root_fs = virt_io['block'][vmid].split(':')[0] print('if [ ! -b "{}" ]; then'.format(root_fs), file=config) print(' echo "no {} data partition, exit"'.format(root_fs), file=config) @@ -341,7 +349,7 @@ def launch_end(names, args, vmid, config): off_line_cpus(args, vmid, uos_type, config) - uos_launch(names, args, vmid, config) + uos_launch(names, args, virt_io, vmid, config) def set_dm_pt(names, sel, vmid, config): @@ -413,7 +421,7 @@ def xhci_args_set(dm, vmid, config): launch_cfg_lib.virtual_dev_slot("xhci"), dm['xhci'][vmid]), file=config) -def vritio_args_set(virt_io, vmid, config): +def virtio_args_set(dm, virt_io, vmid, config): # virtio-input set, the value type is a list for input_val in virt_io['input'][vmid]: @@ -421,15 +429,18 @@ def vritio_args_set(virt_io, vmid, config): print(" -s {},virtio-input,{} \\".format( launch_cfg_lib.virtual_dev_slot("virtio-input{}".format(input_val)), input_val), file=config) + # virtio-blk set, the value type is a list + for blk in virt_io['block'][vmid]: + if blk: + print(" -s {},virtio-blk,{} \\".format(launch_cfg_lib.virtual_dev_slot("virtio-blk{}".format(blk)), blk.strip(':')), file=config) + def dm_arg_set(names, sel, virt_io, dm, vmid, config): uos_type = names['uos_types'][vmid] board_name = names['board_name'] - # vboot loader for vsbl boot_image_type(dm, vmid, config) - root_img = dm['rootfs_img'][vmid] # uuid get scenario_uuid = launch_cfg_lib.get_scenario_uuid() @@ -495,7 +506,7 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config): xhci_args_set(dm, vmid, config) # VIRTIO args set - vritio_args_set(virt_io, vmid, config) + virtio_args_set(dm, virt_io, vmid, config) # GVT args set gvt_arg_set(uos_type, config) @@ -529,12 +540,6 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config): if not is_nuc_whl_clr(names, vmid): print(" -s {},wdt-i6300esb \\".format(launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")), file=config) - #print(" -s {},xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \\".format(launch_cfg_lib.virtual_dev_slot("xhci")), file=config) - - if dm['vbootloader'][vmid] and dm['vbootloader'][vmid] == "vsbl": - print(" -s {},virtio-blk$boot_dev_flag,/data/{} \\".format(launch_cfg_lib.virtual_dev_slot("virtio-blk"), root_img), file=config) - elif dm['vbootloader'][vmid] and dm['vbootloader'][vmid] == "ovmf": - print(" -s {},virtio-blk,{} \\".format(launch_cfg_lib.virtual_dev_slot("virtio-blk"), root_img), file=config) if uos_type in ("ANDROID", "ALIOS"): print(" --enable_trusty \\", file=config) @@ -568,4 +573,4 @@ def gen(names, pt_sel, virt_io, dm, vmid, config): dm_arg_set(names, pt_sel, virt_io, dm, vmid, config) # gen launch end - launch_end(names, dm, vmid, config) + launch_end(names, dm, virt_io, vmid, config) diff --git a/misc/acrn-config/launch_config/launch_cfg_gen.py b/misc/acrn-config/launch_config/launch_cfg_gen.py index ef2ae43ec..d1ee1af64 100644 --- a/misc/acrn-config/launch_config/launch_cfg_gen.py +++ b/misc/acrn-config/launch_config/launch_cfg_gen.py @@ -43,7 +43,6 @@ def get_launch_item_values(board_info): # acrn dm available optargs launch_item_values['uos,uos_type'] = launch_cfg_lib.UOS_TYPES launch_item_values["uos,rtos_type"] = launch_cfg_lib.RTOS_TYPE - launch_item_values["uos,rootfs_dev"] = launch_cfg_lib.get_rootdev_info(board_info) launch_item_values["uos,vbootloader"] = launch_cfg_lib.BOOT_TYPE launch_item_values['uos,console_type'] = launch_cfg_lib.REDIRECT_CONSOLE diff --git a/misc/acrn-config/launch_config/launch_item.py b/misc/acrn-config/launch_config/launch_item.py index 202fac129..77cdb6f87 100644 --- a/misc/acrn-config/launch_config/launch_item.py +++ b/misc/acrn-config/launch_config/launch_item.py @@ -18,8 +18,6 @@ class AcrnDmArgs: self.args["rtos_type"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "rtos_type") self.args["mem_size"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "mem_size") self.args["gvt_args"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "gvt_args") - self.args["rootfs_dev"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "rootfs_dev") - self.args["rootfs_img"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "rootfs_img") self.args["vbootloader"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "vbootloader") self.args["console_type"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "console_type") self.args["off_pcpus"] = launch_cfg_lib.get_leaf_tag_map(self.scenario_info, "vcpu_affinity", "pcpu_id") @@ -33,7 +31,6 @@ class AcrnDmArgs: launch_cfg_lib.args_aval_check(self.args["gvt_args"], "gvt_args", launch_cfg_lib.GVT_ARGS) launch_cfg_lib.args_aval_check(self.args["vbootloader"], "vbootloader", launch_cfg_lib.BOOT_TYPE) launch_cfg_lib.args_aval_check(self.args["console_type"], "console_type", launch_cfg_lib.REDIRECT_CONSOLE) - launch_cfg_lib.args_aval_check(self.args["rootfs_dev"], "rootfs_dev", rootfs) class AvailablePthru(): @@ -153,3 +150,4 @@ class VirtioDeviceSelect(): def get_virtio(self): self.dev["input"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "input") + self.dev["block"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "block") diff --git a/misc/acrn-config/library/common.py b/misc/acrn-config/library/common.py index 07ee6efa5..83824b63b 100644 --- a/misc/acrn-config/library/common.py +++ b/misc/acrn-config/library/common.py @@ -23,7 +23,7 @@ GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTH START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE', 'VM0_MEM_SIZE'] -MULTI_ITEM = ["guest_flag", "pcpu_id", "input"] +MULTI_ITEM = ["guest_flag", "pcpu_id", "input", "block"] class MultiItem(): @@ -32,6 +32,7 @@ class MultiItem(): self.guest_flag = [] self.pcpu_id = [] self.vir_input = [] + self.vir_block = [] self.vir_console = [] self.vir_net = [] @@ -415,6 +416,10 @@ def get_leaf_value(tmp, tag_str, leaf): if leaf.tag == "input" and tag_str == "input": tmp.multi.vir_input.append(leaf.text) + # get virtio-blk for vm + if leaf.tag == "block" and tag_str == "block": + tmp.multi.vir_block.append(leaf.text) + def get_sub_value(tmp, tag_str, vm_id): @@ -427,10 +432,14 @@ def get_sub_value(tmp, tag_str, vm_id): if tmp.multi.pcpu_id and tag_str == "pcpu_id": tmp.tag[vm_id] = tmp.multi.pcpu_id - # append input for vm + # append virtio input for vm if tmp.multi.vir_input and tag_str == "input": tmp.tag[vm_id] = tmp.multi.vir_input + # append virtio block for vm + if tmp.multi.vir_block and tag_str == "block": + tmp.tag[vm_id] = tmp.multi.vir_block + def get_leaf_tag_map(config_file, branch_tag, tag_str): """ diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py index 959c40adb..73c9d184b 100644 --- a/misc/acrn-config/library/launch_cfg_lib.py +++ b/misc/acrn-config/library/launch_cfg_lib.py @@ -461,7 +461,7 @@ def args_aval_check(arg_list, item, avl_list): """ # args should be set into launch xml from webUI i_cnt = 1 - skip_check_list = ['gvt_args', 'rootfs_dev'] + skip_check_list = ['gvt_args'] if item in skip_check_list: return