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 <[email protected]>
  • Loading branch information
nickzhq committed Sep 12, 2023
1 parent c5225ad commit 52b814e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ def postprocess_image(test, params, image_name, vm_process_status=None):
restored, removed = (False, False)
clone_master = params.get("clone_master", None)
base_dir = params.get("images_base_dir", data_dir.get_data_dir())
if params.get("storage_type") == "vhost-vdpa":
return
image = qemu_storage.QemuImg(params, base_dir, image_name)

if params.get("img_check_failed") == "yes":
Expand Down Expand Up @@ -805,7 +807,8 @@ def _call_vm_func():
vm_func(test, vm_params, env, vm_name)

def _call_image_func():
if params.get("skip_image_processing") == "yes":
vdpa_dev = params.get("storage_type") == "vhost-vdpa"

This comment has been minimized.

Copy link
@zhencliu

zhencliu Sep 12, 2023

Contributor

storage_type is an image level param, while at line811, we did a global check there.

IMO, we can put the check in the function handling a single image, e.g. check_image, generate the QemuImg object after the check of 'check_image' param, then we can skip the check by setting check_image_image2 = no

if params.get("skip_image_processing") == "yes" or vdpa_dev:
return

if params.objects("vms"):
Expand Down Expand Up @@ -856,7 +859,8 @@ def _call_fs_source_func():
vm.resume()

def _call_check_image_func():
if params.get("skip_image_processing") == "yes":
vdpa_dev = params.get("storage_type") == "vhost-vdpa"
if params.get("skip_image_processing") == "yes" or vdpa_dev:
return

if params.objects("vms"):
Expand Down
10 changes: 10 additions & 0 deletions virttest/qemu_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ def filename_to_file_opts(filename):

if matches['user'] is not None:
file_opts['username'] = matches['user']
# FIXME: vdpa is a customized protocol instead of a standard protocol.
elif filename.startswith("vdpa:"):
# filename[7:] mean: remove the prefix "vdpa://"
file_opts = {'driver': 'virtio-blk-vhost-vdpa',
'path': filename[7:]}
# FIXME: Judge the host device by the string starts with "/dev/".
elif filename.startswith('/dev/'):
file_opts = {'driver': 'host_device', 'filename': filename}
Expand Down Expand Up @@ -517,7 +522,12 @@ def __init__(self, params, root_dir, tag):
:param params: Dictionary containing the test parameters.
:param root_dir: Base directory for relative filenames.
:param tag: Image tag defined in parameter images
:raise NotImplementedError: If the image type is not supported.
"""
if params.get("storage_type") == "vhost-vdpa":
raise NotImplementedError("Vdpa is NOT supported to handle "
"the image!")
storage.QemuImg.__init__(self, params, root_dir, tag)
self.image_cmd = utils_misc.get_qemu_img_binary(params)
q_result = process.run(self.image_cmd + ' -h', ignore_status=True,
Expand Down

0 comments on commit 52b814e

Please sign in to comment.