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 2013523 - Save and restore the vm with cdrom cause the vm's cdrom tray locked
Summary: Save and restore the vm with cdrom cause the vm's cdrom tray locked
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.1
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: ---
Assignee: khanicov
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-13 05:33 UTC by yalzhang@redhat.com
Modified: 2023-06-07 03:58 UTC (History)
13 users (show)

Fixed In Version: libvirt-8.9.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:26:10 UTC
Type: Bug
Target Upstream Version: 8.9.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-99588 0 None None None 2021-10-13 05:34:39 UTC
Red Hat Product Errata RHBA-2023:2171 0 None None None 2023-05-09 07:26:53 UTC

Description yalzhang@redhat.com 2021-10-13 05:33:12 UTC
Description of problem:
Save and restore the vm with cdrom cause the vm's cdrom tray locked

Version-Release number of selected component (if applicable):
libvirt-7.6.0-4.module+el8.5.0+12786+c4633d9a.x86_64
qemu-kvm-6.0.0-31.module+el8.5.0+12787+aaa8bdfa.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start a vm with a cdrom device:
# virsh start test
Domain 'test' started

# virsh dumpxml test | grep /disk -B12
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/RHEL-8.5-x86_64-latest.qcow2' index='2'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/new.iso' index='1'/>
      <backingStore/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
      <alias name='scsi0-0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

# virsh qemu-monitor-command test --hmp info block
libvirt-2-format: /var/lib/libvirt/images/RHEL-8.5-x86_64-latest.qcow2 (qcow2)
    Attached to:      sata0-0-0
    Cache mode:       writeback

libvirt-1-format: /var/lib/libvirt/images/new.iso (raw, read-only)
    Attached to:      scsi0-0-0-1
    Removable device: **not locked**, tray closed
    Cache mode:       writeback

2.  Save and restore the vm
# virsh save test test_save
Domain 'test' saved to test_save

# virsh restore test_save
Domain restored from test_save

3. Check the cdrom device, it is locked:
# virsh qemu-monitor-command test --hmp info block
libvirt-2-format: /var/lib/libvirt/images/RHEL-8.5-x86_64-latest.qcow2 (qcow2)
    Attached to:      sata0-0-0
    Cache mode:       writeback

libvirt-1-format: /var/lib/libvirt/images/new.iso (raw, read-only)
    Attached to:      scsi0-0-0-1
    Removable device: **locked**, tray closed
    Cache mode:       writeback

4. Try to eject the cdrom by update-device, it failed:
# cat  disknew.xml 
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <backingStore/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
      <alias name='scsi0-0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

# virsh update-device test disknew.xml
error: Failed to update device from disknew.xml
error: internal error: unable to execute QEMU command 'blockdev-remove-medium': Tray of device 'scsi0-0-0-1' is not open

# cat /var/log/libvirt/libvirtd.log   | grep -i error
2021-10-13 05:24:31.386+0000: 223914: info : qemuMonitorJSONIOProcessLine:240 : QEMU_MONITOR_RECV_REPLY: mon=0x7f676004b190 reply={"id": "libvirt-385", "error": {"class": "GenericError", "desc": "Tray of device 'scsi0-0-0-1' is not open"}}
2021-10-13 05:24:31.386+0000: 223295: error : qemuMonitorJSONCheckErrorFull:415 : internal error: unable to execute QEMU command 'blockdev-remove-medium': Tray of device 'scsi0-0-0-1' is not open

Actual results:
Save and restore the vm with cdrom cause the vm's cdrom tray locked

Expected results:
The tray should not be locked after save and restore, and the update should succeed

Additional info:

Comment 2 Jaroslav Suchanek 2021-11-04 15:42:43 UTC
Also described here: https://bugzilla.redhat.com/show_bug.cgi?id=1824722#c1

Comment 3 Peter Krempa 2022-04-25 16:06:16 UTC
Upstream issue: https://gitlab.com/libvirt/libvirt/-/issues/301

Comment 5 khanicov 2022-10-21 16:35:47 UTC
Merged upstream as:

7356dce2b3 qemu: Refresh state after restore from a save image

v8.8.0-160-g7356dce2b3


This bug was solved by mprivozn.

Comment 6 Han Han 2022-10-24 02:32:33 UTC
Tested on libvirtv8.8.0-172-gf1d63048b7 qemu-7.1.0-3.fc38.x86_64:
1. Start an VM with cdrom
2. Check the cdrom status by QMP `info block`
➜  ~ virsh qemu-monitor-command rhel9 --hmp info block
libvirt-2-format: /var/lib/libvirt/images/1 (raw)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

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

Save and restore the CDROM
➜  ~ virsh save rhel9 /tmp/rhel9.save                 

Domain 'rhel9' saved to /tmp/rhel9.save

➜  ~ virsh restore /tmp/rhel9.save   
Domain restored from /tmp/rhel9.save


Check the Removable device status of the cdrom. Expect the same with what is before the save&restore
➜  ~ virsh qemu-monitor-command rhel9 --hmp info block
libvirt-2-format: /var/lib/libvirt/images/1 (raw)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

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

3. Execute `eject -i off /dev/sr0` to change the locked status. And redo step2
libvirt-2-format: /var/lib/libvirt/images/1 (raw)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

libvirt-1-format: /var/lib/libvirt/images/boot.iso (raw, read-only)
    Attached to:      scsi0-0-0-1
    Removable device: not locked, tray closed
    Cache mode:       writeback

Save and restore the CDROM
➜  ~ virsh save rhel9 /tmp/rhel9.save                 

Domain 'rhel9' saved to /tmp/rhel9.save

➜  ~ virsh restore /tmp/rhel9.save   
Domain restored from /tmp/rhel9.save


Check the Removable device status of the cdrom. Expect the same with what is before the save&restore
➜  ~ virsh qemu-monitor-command rhel9 --hmp info block
libvirt-2-format: /var/lib/libvirt/images/1 (raw)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

libvirt-1-format: /var/lib/libvirt/images/boot.iso (raw, read-only)
    Attached to:      scsi0-0-0-1
    Removable device: not locked, tray closed
    Cache mode:       writeback

Comment 9 Han Han 2022-11-08 10:01:52 UTC
Test as comment0 on libvirt-8.9.0-2.el9.x86_64 qemu-kvm-7.1.0-4.el9.x86_64. PASS
➜  ~ virsh qemu-monitor-command rhel-9.2 --hmp info block
libvirt-3-format: /var/lib/libvirt/images/rhel-9.2.qcow2 (qcow2)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

libvirt-2-format: /tmp/usb (raw)
    Attached to:      /machine/peripheral/usb-disk1/usb-disk1.0/legacy[0]
    Removable device: not locked, tray closed
    Cache mode:       writeback

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


➜  ~ virsh save rhel-9.2 /tmp/rhel                       

Domain 'rhel-9.2' saved to /tmp/rhel

➜  ~ rpm -q libvirt
libvirt-8.9.0-2.el9.x86_64
➜  ~ virsh restore /tmp/rhel                                                                                                                  
Domain restored from /tmp/rhel

➜  ~ virsh qemu-monitor-command rhel-9.2 --hmp info block
libvirt-3-format: /var/lib/libvirt/images/rhel-9.2.qcow2 (qcow2)
    Attached to:      /machine/peripheral/virtio-disk0/virtio-backend
    Cache mode:       writeback

libvirt-2-format: /tmp/usb (raw)
    Attached to:      /machine/peripheral/usb-disk1/usb-disk1.0/legacy[0]
    Removable device: not locked, tray closed
    Cache mode:       writeback

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

➜  ~ cat empty.xml 
<disk type="file" device="cdrom">
  <driver name="qemu" type="raw"/>
  <backingStore/>
  <target dev="sdc" bus="scsi"/>
  <readonly/>
  <alias name="scsi0-0-0-2"/>
  <address type="drive" controller="0" bus="0" target="0" unit="2"/>
</disk>


➜  ~ virsh update-device rhel-9.2 empty.xml              
Device updated successfully

Comment 11 errata-xmlrpc 2023-05-09 07:26:10 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.