forked from autotest/tp-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request autotest#5576 from Yingshun/vdpablk_multi
virtual_disks: Add a vhostvdpa-blk test
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...disks/vhostvdpa_block_backend_type/define_start_vm_with_multi_vhostvdpa_backend_disks.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- virtual_disks.vhostvdpa.define_start_multi_disks: | ||
type = define_start_vm_with_multi_vhostvdpa_backend_disks | ||
start_vm = no | ||
simulator = "yes" | ||
func_supported_since_libvirt_ver = (9, 10, 0) | ||
only x86_64 | ||
|
||
disk_vdpa_attrs = {"source": {"attrs": {"dev": "/dev/vhost-vdpa-0"}}, "type_name": "vhostvdpa"} | ||
disk2_vdpa_attrs = {"source": {"attrs": {"dev": "/dev/vhost-vdpa-1"}}, "type_name": "vhostvdpa"} | ||
disk_driver = {"driver": {"name": "qemu", "type": "raw", "cache": "none", "io": "threads", "copy_on_read": "on", "discard": "unmap", "detect_zeroes": "on"}} | ||
disk_attrs = {"device": "disk", "target": {"dev": "vdb", "bus": "virtio"}, **${disk_vdpa_attrs}, **${disk_driver}} | ||
disk2_attrs = {"device": "disk", "target": {"dev": "vdc", "bus": "virtio"}, **${disk2_vdpa_attrs}, **${disk_driver}} |
45 changes: 45 additions & 0 deletions
45
..._disks/vhostvdpa_block_backend_type/define_start_vm_with_multi_vhostvdpa_backend_disks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from virttest import libvirt_version | ||
from virttest import utils_vdpa | ||
from virttest.libvirt_xml import vm_xml | ||
from virttest.utils_libvirt import libvirt_disk | ||
from virttest.utils_libvirt import libvirt_vmxml | ||
|
||
VIRSH_ARGS = {'debug': True, 'ignore_status': False} | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Verify that a vm can have more than one vhost-vdpa backend disks, | ||
and both the two disks can be successfully written to/read from. | ||
""" | ||
libvirt_version.is_libvirt_feature_supported(params) | ||
disk_attrs = eval(params.get("disk_attrs", "{}")) | ||
disk2_attrs = eval(params.get("disk2_attrs", "{}")) | ||
|
||
vm_name = params.get("main_vm") | ||
vm = env.get_vm(vm_name) | ||
|
||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) | ||
bkxml = vmxml.copy() | ||
|
||
try: | ||
test.log.info("TEST_STEP: Define a VM with vhost-vdpa disk.") | ||
test_env_obj = utils_vdpa.VDPASimulatorTest(sim_dev_module="vdpa_sim_blk", mgmtdev="vdpasim_blk") | ||
test_env_obj.setup(dev_num=2) | ||
vm_xml.VMXML.set_memoryBacking_tag(vm_name, access_mode="shared", hpgs=False) | ||
libvirt_vmxml.modify_vm_device(vm_xml.VMXML.new_from_dumpxml(vm_name), "disk", disk_attrs, 1) | ||
libvirt_vmxml.modify_vm_device(vm_xml.VMXML.new_from_dumpxml(vm_name), "disk", disk2_attrs, 2) | ||
|
||
vm.start() | ||
vm_session = vm.wait_for_login() | ||
|
||
test.log.info("TEST_STEP: Check r/w operations on vhost-vdpa disk.") | ||
new_disks = libvirt_disk.get_non_root_disk_names(vm_session) | ||
vm_session.close() | ||
for disk in new_disks: | ||
if not libvirt_disk.check_virtual_disk_io(vm, disk[0]): | ||
test.fail("Failed to check disk io for %s!" % disk[0]) | ||
|
||
finally: | ||
bkxml.sync() | ||
test_env_obj.cleanup() |