Skip to content

Commit

Permalink
qemu_storage: support the vdpa device
Browse files Browse the repository at this point in the history
add vdpa device support to the related functions

Signed-off-by: Houqi (Nick) Zuo <hzuo@redhat.com>
  • Loading branch information
nickzhq committed Aug 9, 2023
1 parent 06b5027 commit 127be9e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions virttest/qemu_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 127be9e

Please sign in to comment.