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 2166411 - virt-xml: Updating cdrom device file: Error attempting device update: internal error: unable to execute QEMU command 'blockdev-remove-medium': Tray of device 'scsi0-0-0' is not open
Summary: virt-xml: Updating cdrom device file: Error attempting device update: interna...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.2
Hardware: All
OS: Unspecified
high
urgent
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard: CockpitTest
: 2166503 (view as bug list)
Depends On: 2163117
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-01 18:32 UTC by Martin Pitt
Modified: 2023-05-09 08:11 UTC (History)
18 users (show)

Fixed In Version: libvirt-9.0.0-4.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2163117
Environment:
Last Closed: 2023-05-09 07:27:45 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-147341 0 None None None 2023-02-01 18:33:40 UTC
Red Hat Product Errata RHBA-2023:2171 0 None None None 2023-05-09 07:28:15 UTC

Description Martin Pitt 2023-02-01 18:32:15 UTC
This bug now went into C9S, thus very soon in RHEL 9.2 as well:
https://artifacts.dev.testing-farm.io/10d58214-9b49-42af-97a5-58d21280555a/

+++ This bug was initially created as a clone of Bug #2163117 +++

Description of problem: In recent Fedora (and also Arch Linux [1]) there is a regression with trying to insert/change a virtual CD-ROM medium.


Version-Release number of selected component (if applicable):

virt-install-4.1.0-1.fc37.noarch
libvirt-daemon-9.0.0-1.fc38.x86_64
qemu-system-x86-core-7.2.0-4.fc38.x86_64
kernel-core-6.2.0-0.rc4.20230118gitc1649ec55708.33.fc38.x86_64

How reproducible: Always


Steps to Reproduce:

systemctl start virtqemud virtnetworkd
virsh net-start default || true  # may already be running
touch /var/lib/libvirt/bogus.iso
virt-install --memory 50 --pxe --virt-type qemu --graphics none --os-variant alpinelinux3.8 --disk device=cdrom,bus=scsi --wait 0 --name test1
virt-xml test1 --edit target.dev=sda --disk source.file=/var/lib/libvirt/bogus.iso,type=file --update

Actual results: Last command fails with

ERROR    Error attempting device update: internal error: unable to execute QEMU command 'blockdev-remove-medium': Tray of device 'scsi0-0-0' is not open


Expected results: command succeeds, and turns the previous

    <disk type='file' device='cdrom'>
      <driver name='qemu'/>
      <target dev='sda' bus='scsi'/>
      <readonly/>
      <alias name='scsi0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

into

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/bogus.iso' index='2'/>
      <backingStore/>
      <target dev='sda' bus='scsi'/>
      <readonly/>
      <alias name='scsi0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Additional info: This could very well be a regression in QEMU. If so, please reassign. Thanks!

Comment 1 Jonathon Jongsma 2023-02-01 20:45:28 UTC
This appears to be a bug in libvirt. 

According to git bisect, 5ef2582646eb98af208ce37355f82bdef39931fa is the first bad commit, which makes sense becuase the the commit is related to disk tray events. So the regression was first included in libvirt 9.0.

Comment 2 Peter Krempa 2023-02-02 08:00:57 UTC
*** Bug 2166503 has been marked as a duplicate of this bug. ***

Comment 5 smitterl 2023-02-09 08:36:00 UTC
I'd like to highlight that because of this issue we can't exchange cdroms in a VM while it's running, this looks like a critical functionality and I'm not aware of any workaround, I might be wrong of course.

Comment 6 Peter Krempa 2023-02-09 08:47:13 UTC
The aforementioned commit causes this regression by 'continue'-ing the for loop extracting disk information if the disk tray state didn't change. That unfortunately skipped over the assignment of whether the device is removable and has a tray into disk private data, which is the primary task the function does.

I'll post a patch soon.

Comment 7 Peter Krempa 2023-02-09 09:29:25 UTC
Fixed upstream:

commit 86cfe93ef7fdc2d665a2fc88b79af89e7978ba78
Author: Peter Krempa <pkrempa>
Date:   Thu Feb 9 09:40:32 2023 +0100

    qemuProcessRefreshDisks: Don't skip filling of disk information if tray state didn't change
    
    Commit 5ef2582646eb98 added emitting of even when refreshign disk state,
    where it wanted to avoid sending the event if disk state didn't change.
    This was achieved by using 'continue' in the loop filling the
    information. Unfortunately this skips extraction of whether the device
    has a tray which is propagated into internal structures, which in turn
    broke cdrom media change as the code thought there's no tray for the
    device.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166411
    Fixes: 5ef2582646eb98af208ce37355f82bdef39931fa
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Kristina Hanicova <khanicov>

Comment 8 smitterl 2023-02-09 09:31:15 UTC
Thanks for bringing the good news Peter!

Comment 11 Han Han 2023-02-14 12:18:27 UTC
Tested on libvirt-9.0.0-5.el9.x86_64 qemu-kvm-7.2.0-8.el9.x86_64. PASS

Comment 14 Han Han 2023-02-16 06:29:41 UTC
Test pass on libvirt-9.0.0-5.el9.x86_64 qemu-kvm-7.2.0-8.el9.x86_64
Covered by the tests of libvirt-RHEL-9.2-runtest-x86_64-function-attach_detach_media

Comment 16 errata-xmlrpc 2023-05-09 07:27:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (libvirt bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2171


Note You need to log in before you can comment on or make changes to this bug.