Skip to content

Commit

Permalink
Add hotplug empty source cdrom device
Browse files Browse the repository at this point in the history
VIRT-xx: Succeed to attach a CDROM without source

Signed-off-by: chunfuwen <[email protected]>
  • Loading branch information
chunfuwen committed Jan 23, 2024
1 parent cdbe7f9 commit f2548d7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@
backend_device = "scsi_cdrom_hot_eject_backend"
tray_state = "locked, tray closed"
only hotplug..positive_test
- empty_source_cdrom_backend:
func_supported_since_libvirt_ver = (9, 10, 0)
type_name = "file"
target_format = "raw"
target_dev = "sdd"
backend_device = "empty_source_cdrom_backend"
only hotplug..positive_test
variants:
- hotplug:
virt_device_hotplug = "yes"
Expand Down
22 changes: 22 additions & 0 deletions libvirt/tests/src/virtual_disks/virtual_disks_cdrom_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,23 @@ def _get_qemu_state():
test.fail("cdrom disk can not be detached successfully")


def check_empty_source_cdrom(vm, params, test):
"""
Check hotplug empty source cdrom
:param vm: one object representing VM
:param params: wrapped parameters in dictionary format
:param test: test assert object
"""
vm.wait_for_login().close()
# hotplug cdrom device
device_obj = params.get("cdrom_xml")
virsh.attach_device(vm.name, device_obj.xml, flagstr="--live", ignore_status=False, debug=True)

# Check cdrom is present in disk xml
check_source_in_cdrom_device(vm, None, test)


def run(test, params, env):
"""
Test attach cdrom device with option.
Expand Down Expand Up @@ -557,6 +574,9 @@ def run(test, params, env):
ignore_status=False, debug=True)
if backend_device == "block_lun_source":
device_obj = create_block_lun_source_disk(params)
if backend_device == "empty_source_cdrom_backend":
device_obj = create_customized_disk(params)
params.update({'cdrom_xml': device_obj})
if not hotplug:
# Sync VM xml.
vmxml.add_device(device_obj)
Expand Down Expand Up @@ -614,6 +634,8 @@ def run(test, params, env):
check_cdrom_reboot_reset(vm, params, test)
elif backend_device == "scsi_cdrom_hot_eject_backend":
check_scsi_cdrom_hot_eject(vm, params, test)
elif backend_device == "empty_source_cdrom_backend":
check_empty_source_cdrom(vm, params, test)
finally:
# Recover VM.
if vm.is_alive():
Expand Down

0 comments on commit f2548d7

Please sign in to comment.