Skip to content

Commit

Permalink
Merge pull request autotest#5820 from meinaLi/neg_discard
Browse files Browse the repository at this point in the history
Virtual_disk: add new negative case of discard_no_unref
  • Loading branch information
chunfuwen authored Aug 15, 2024
2 parents d7ce2b1 + 5ccce75 commit 0a91877
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
- start_vm:
check_qemu_pattern = '"discard":"${discard}","driver":"qcow2","discard-no-unref":${qemu_output}'
expect_xml_line = 'discard_no_unref="${discard_no_unref}"'
- hotplug_disk:
only enable..with_discard_unmap.file_disk
hotplug = "yes"
check_libvirtd_log = '"driver":"qcow2","discard-no-unref":true'
- define_invalid:
only enable..with_discard_unmap.file_disk
status_error = "yes"
Expand All @@ -35,8 +39,9 @@
expect_error = "unsupported configuration: 'discard_no_unref' only works with qcow2 disk format"
- readonly_mode:
expect_error = "unsupported configuration: 'discard_no_unref' is not compatible with read-only disk"
- hotplug_disk:
- update_negative:
only enable..with_discard_unmap.file_disk
hotplug = "yes"
check_libvirtd_log = '"driver":"qcow2","discard-no-unref":true'
func_supported_since_libvirt_ver = (10, 5, 0)
status_error = "yes"
expect_error = "cannot modify field 'discard_no_unref' of the disk"
disk_dict = {'type_name': '${disk_type}', 'driver': {'name': 'qemu', 'type': 'qcow2', 'discard': '${discard}', 'discard_no_unref': '${discard_no_unref}'}, 'target': {'dev': '${target_dev}'}}
25 changes: 25 additions & 0 deletions libvirt/tests/src/virtual_disks/virtual_disks_discard_no_unref.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,31 @@ def run_test_hotplug_disk(vm, params, test):
test.fail("The target disk % can't be detached in guest." % target_dev)


def run_test_update_negative(vm, params, test):
"""
Scenario: update device for guest with discard_no_unref attribute
:param vm: vm instance
:param params: dict, test parameters
:param test: test object
"""
vm_name = params.get("main_vm")
expect_error = params.get("expect_error")

test.log.debug("STEP1: start a guest.")
if not vm.is_alive():
vm.start()
test.log.debug("STEP2: prepare the disk xml.")
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
disk = vmxml.get_devices(device_type="disk")[0]
disk_driver = disk['driver']
disk_driver.update({'discard_no_unref': 'on'})
disk['driver'] = disk_driver
test.log.debug("STEP3: update the disk device.")
result = virsh.update_device(vm_name, disk.xml, debug=True)
libvirt.check_result(result, expect_error)


def teardown_test(vm, vmxml, params, test):
"""
:param vm: vm instance
Expand Down

0 comments on commit 0a91877

Please sign in to comment.