diff --git a/virttest/qemu_storage.py b/virttest/qemu_storage.py index f53a388b2b8..2abbe6ec5cd 100755 --- a/virttest/qemu_storage.py +++ b/virttest/qemu_storage.py @@ -16,7 +16,7 @@ from avocado.core import exceptions from avocado.utils import process -from virttest import utils_misc +from virttest import utils_misc, utils_vdpa from virttest import virt_vm from virttest import storage from virttest import nvme @@ -187,8 +187,10 @@ def filename_to_file_opts(filename): if matches['user'] is not None: file_opts['username'] = matches['user'] + elif filename.startswith("/dev/vhost-vdpa"): + file_opts = {'driver': 'virtio-blk-vhost-vdpa', 'path': filename} # FIXME: Judge the host device by the string starts with "/dev/". - elif filename.startswith('/dev/'): + elif filename.startswith('/dev/') and not filename.startswith("/dev/vhost-vdpa"): file_opts = {'driver': 'host_device', 'filename': filename} else: file_opts = {'driver': 'file', 'filename': filename} @@ -771,6 +773,8 @@ def create(self, params, ignore_errors=False): :return: tuple (path to the image created, process.CmdResult object containing the result of the creation command). """ + if self.params.get("drive_format") == "vdpa": + return utils_vdpa.get_vdpa_dev_file_by_name(self.params.get("image_name")), None if params.get( "create_with_dd") == "yes" and self.image_format == "raw": # maps K,M,G,T => (count, bs) @@ -922,6 +926,8 @@ def convert(self, params, root_dir, cache_mode=None, "target_image_opts": "" } + if "vdpa" == self.params.get("drive_format"): + LOG.error("The Vdpa is NOT supported for convert operation!") options = convert_image._parse_options(convert_params) if options: cmd_dict["options"] = ",".join(options) @@ -1096,6 +1102,8 @@ def snapshot_create(self): snapshot_image_name -- the name of snapshot image file """ + if self.params.get("drive_format") == "vdpa": + return None cmd = self.image_cmd if self.snapshot_tag: cmd += " snapshot -c %s" % self.snapshot_image_filename @@ -1118,6 +1126,8 @@ def snapshot_del(self, blkdebug_cfg=""): snapshot_image_name -- the name of snapshot image file """ + if self.params.get("drive_format") == "vdpa": + return None cmd = self.image_cmd if self.snapshot_tag: cmd += " snapshot -d %s" % self.snapshot_image_filename @@ -1291,6 +1301,9 @@ def remove(self): """ Remove an image file. """ + if self.params.get("drive_format") == "vdpa": + LOG.debug("Vdpa device does NOT have image file...skipping") + return None LOG.debug("Removing image file %s", self.image_filename) storage.file_remove(self.params, self.image_filename)