diff --git a/qemu/tests/block_disk_not_default_options.py b/qemu/tests/block_disk_not_default_options.py new file mode 100644 index 0000000000..74675c2c92 --- /dev/null +++ b/qemu/tests/block_disk_not_default_options.py @@ -0,0 +1,60 @@ +from virttest import error_context, qemu_qtree + +from provider.block_devices_plug import BlockDevicesPlug + + +@error_context.context_aware +def run(test, params, env): + """ + Test the disk non-default options. + + Steps: + 1. Boot a VM with packed=true and page-per-vq=true + 2. Verify the packed and page-per-vq values + 3. Do some basic I/O operation in the VM + 4. Unplug and hotplug the disk + 5. Do again a basic I/O operation + + :param test: QEMU test object. + :param params: Dictionary with the test parameters. + :param env: Dictionary with test environment. + """ + + def verify_non_default_options(option, possible_types): + """Verify the non-default values.""" + error_context.context(f"Verify {option} from monitor.", test.log.info) + qtree = qemu_qtree.QtreeContainer() + qtree_option_value = False + try: + qtree.parse_info_qtree(vm.monitor.info("qtree")) + except AttributeError: + test.cancel("Monitor doesn't support qtree skip this test") + error_msg = ( + f"'{option}' value mismatch: expected 'true' but report from monitor is: %s" + ) + + for node in qtree.get_nodes(): + node_type = node.qtree["type"] + if isinstance(node, qemu_qtree.QtreeDev) and node_type in possible_types: + qtree_option_value = node.qtree[option] + + if not qtree_option_value: + error_msg = error_msg % qtree_option_value + test.fail(error_msg) + + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + session = vm.wait_for_login(timeout=360) + session.cmd(params.get("dd_cmd")) + + qtree_check = eval(params.get("qtree_check", "{}")) + if qtree_check: + for key in qtree_check: + verify_non_default_options(key, qtree_check[key]) + else: + test.log.error("There are no options to be checked in the qtree") + + plug = BlockDevicesPlug(vm) + plug.unplug_devs_serial() + plug.hotplug_devs_serial() + session.cmd(params.get("dd_cmd")) diff --git a/qemu/tests/cfg/block_disk_not_default_options.cfg b/qemu/tests/cfg/block_disk_not_default_options.cfg new file mode 100644 index 0000000000..d1d5b9b96b --- /dev/null +++ b/qemu/tests/cfg/block_disk_not_default_options.cfg @@ -0,0 +1,20 @@ +- block_disk_not_default_options: + only virtio_blk, virtio_scsi + type = block_disk_not_default_options + only x86_64 + start_vm = yes + images += " stg0" + boot_drive_stg0 = yes + image_name_stg0 = images/storage0 + image_size_stg0 = 40G + remove_image_stg0 = yes + force_create_image_stg0 = yes + dd_cmd = "dd if=/dev/urandom of=test.txt bs=1M count=10" + variants: + - with_packed_and_ppv: + qtree_check = '{"packed" : ["virtio-blk-device", "virtio-scsi-device"], "page-per-vq" : ["virtio-blk-pci", "virtio-scsi-pci"]}' + virtio_blk: + blk_extra_params_stg0 = "packed=true,page-per-vq=true" + virtio_scsi: + bus_extra_params_stg0 = "packed=true,page-per-vq=true" + drive_bus_stg0 = 1