Skip to content

Commit d07f63d

Browse files
authored
Merge pull request #4209 from mcasquer/3007_booting_hotplugging_disk_non_default_options
block_disk_not_default_options: creates new test case
2 parents 884206e + 86c6852 commit d07f63d

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
from virttest import error_context, qemu_qtree
2+
3+
from provider import disk_utils
4+
from provider.block_devices_plug import BlockDevicesPlug
5+
6+
7+
@error_context.context_aware
8+
def run(test, params, env):
9+
"""
10+
Test the disk non-default options.
11+
12+
Steps:
13+
1. Boot a VM with packed=true and page-per-vq=true
14+
2. Verify the packed and page-per-vq values
15+
3. Do some basic I/O operation in the VM
16+
4. Unplug and hotplug the disk
17+
5. Do again a basic I/O operation
18+
19+
:param test: QEMU test object.
20+
:param params: Dictionary with the test parameters.
21+
:param env: Dictionary with test environment.
22+
"""
23+
24+
def verify_non_default_options(option_key, expected_value):
25+
"""Verify the non-default values.
26+
:param option_key: the QEMU option to be checked.
27+
:param expected_value: the QEMU option expected value.
28+
"""
29+
error_context.context(f"Verify {option_key} from monitor.", test.log.info)
30+
qtree = qemu_qtree.QtreeContainer()
31+
qtree_option_value = False
32+
try:
33+
qtree.parse_info_qtree(vm.monitor.info("qtree"))
34+
except AttributeError:
35+
test.cancel("Monitor doesn't support qtree skip this test")
36+
error_msg = (
37+
f"'{option_key}' value mismatch: expected %s but report from monitor is: %s"
38+
)
39+
40+
for node in qtree.get_nodes():
41+
if (
42+
isinstance(node, qemu_qtree.QtreeDev)
43+
and node.qtree.get(option_key) == expected_value
44+
):
45+
qtree_option_value = node.qtree.get(option_key)
46+
error_context.context(
47+
f"The qtree_option_value: {qtree_option_value}", test.log.debug
48+
)
49+
50+
if qtree_option_value != expected_value:
51+
error_msg = error_msg % (str(expected_value), qtree_option_value)
52+
test.fail(error_msg)
53+
54+
vm = env.get_vm(params["main_vm"])
55+
vm.verify_alive()
56+
57+
qtree_check_images = params.get_list("qtree_check_images", "stg0")
58+
59+
serial = params.object_params(qtree_check_images[0])["image_serial"]
60+
61+
fstype = params.get("fstype", None)
62+
io_cmd = params.get("io_cmd", "")
63+
clean_env = params.get_boolean("clean_env", True)
64+
65+
# To be configured by the user in the cfg
66+
dst_dir = params.get("dst_dir", None)
67+
disk_utils.execute_io_test(
68+
params,
69+
vm,
70+
qtree_check_images[0],
71+
serial,
72+
fstype,
73+
dst_dir=dst_dir,
74+
io_command=io_cmd,
75+
clean=clean_env,
76+
ignore_all_errors=False,
77+
)
78+
79+
for image in qtree_check_images:
80+
qtree_check_image = params.get_dict(f"qtree_check_{image}", "{}")
81+
if qtree_check_image:
82+
for option_key in qtree_check_image:
83+
error_context.base_context(
84+
f"Options to verify: {option_key} {qtree_check_image[option_key]}",
85+
test.log.debug,
86+
)
87+
verify_non_default_options(option_key, qtree_check_image[option_key])
88+
else:
89+
test.log.warning("There are no options to be checked in the qtree")
90+
91+
plug = BlockDevicesPlug(vm)
92+
plug.unplug_devs_serial(qtree_check_images[0])
93+
plug.hotplug_devs_serial(qtree_check_images[0])
94+
disk_utils.execute_io_test(
95+
params,
96+
vm,
97+
qtree_check_images[0],
98+
serial,
99+
fstype,
100+
dst_dir=dst_dir,
101+
io_command=io_cmd,
102+
clean=clean_env,
103+
ignore_all_errors=False,
104+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
- block_disk_not_default_options:
2+
type = block_disk_not_default_options
3+
only x86_64
4+
start_vm = yes
5+
images += " stg0"
6+
boot_drive_stg0 = yes
7+
image_name_stg0 = images/stg0
8+
image_size_stg0 = 8G
9+
remove_image_stg0 = yes
10+
force_create_image_stg0 = yes
11+
image_serial_stg0 = "stg0"
12+
blk_extra_params_stg0 = "serial=${image_serial_stg0}"
13+
fstype = "xfs"
14+
io_cmd = "dd if=/dev/zero of=%s/test.img bs=1M count=10 oflag=direct"
15+
clean_env = yes
16+
Windows:
17+
fstype = "ntfs"
18+
io_cmd = "dd if=/dev/urandom of=%s\test.dat bs=1M count=10"
19+
variants:
20+
- with_packed_and_ppv:
21+
qtree_check_images = "stg0"
22+
qtree_check_stg0 = packed=true page-per-vq=true
23+
virtio_blk:
24+
blk_extra_params_stg0 += ",packed=true,page-per-vq=true"
25+
virtio_scsi:
26+
bus_extra_params_stg0 = "packed=true,page-per-vq=true"
27+
drive_bus_stg0 = 1

0 commit comments

Comments
 (0)