Bug 2166503

Summary: virsh update-device with cdrom type failed
Product: Red Hat Enterprise Linux 9 Reporter: chunfu wen <chwen>
Component: libvirtAssignee: Virtualization Maintenance <virt-maint>
libvirt sub component: CLI & API QA Contact: Han Han <hhan>
Status: CLOSED DUPLICATE Docs Contact:
Severity: medium    
Priority: medium CC: lmen, pkrempa, virt-maint, yafu
Version: 9.2Keywords: Automation, Regression
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-02-02 08:00:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description chunfu wen 2023-02-02 01:56:49 UTC

Comment 1 chunfu wen 2023-02-02 01:57:53 UTC
Description of problem: 
virsh update-device with cdrom type failed on rhel9.2
some related automation case failed also ,and manually can reproduce it.
Error message: error: Failed to update device from update.xml
error: internal error: unable to execute QEMU command 'blockdev-remove-medium': Tray of device 'scsi0-0-0-2' is not open

Version-Release number of selected component:
libvirt-9.0.0-2.el9.x86_64
qemu-kvm-7.2.0-5.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1.  create one iso file:
mkdir -p /var/tmp
mkisofs -o /var/tmp/orig.iso /root/*.*
2. attach iso file to  stopped Vm:
virsh attach-disk avocado-vt-vm1 /var/tmp/orig.iso sdc --type cdrom --sourcetype=file --config --mode readonly
3. Start Vm
4. Prepare update.xml as below:
<disk device="cdrom" type="file"><target bus="scsi" dev="sdc" /><alias name="scsi0-0-0-2" />
</disk>
5.  Execute virsh update-device with above created update.xml
 virsh update-device avocado-vt-vm1 /var/tmp/update.xml --live
6.  Observe below error message with above operation:
    [root@dell-per730-67 ~]# virsh update-device avocado-vt-vm1 update.xml --live
        error: Failed to update device from update.xml
         error: internal error: unable to execute QEMU command 'blockdev-          remove-medium': Tray of device 'scsi0-0-0-2' is not open
7.  Check block statu with virsh qemu-monitor-command as below
[root@dell-per730-67 ~]# virsh qemu-monitor-command --hmp avocado-vt-vm1 info block
libvirt-pflash0-format: /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd (raw, read-only)
    Attached to:      /machine/system.flash0
    Cache mode:       writeback

libvirt-pflash1-format: /var/lib/libvirt/qemu/nvram/avocado-vt-vm1_VARS.fd (raw)
    Attached to:      /machine/system.flash1
    Cache mode:       writeback

libvirt-2-format: /var/lib/avocado/data/avocado-vt/images/jeos-27-x86_64.qcow2 (qcow2)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

libvirt-1-format: /var/tmp/orig.iso (raw, read-only)
    Attached to:      scsi0-0-0-2
    Removable device: locked, tray closed
    Cache mode:       writeback

Actual results:
update cdrom device can not work as expected

Expected results:
the update cdrom device should work well

Comment 2 Peter Krempa 2023-02-02 08:00:57 UTC

*** This bug has been marked as a duplicate of bug 2166411 ***