Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

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: rcFlags: pm-rhel: mirror+
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 ***