Bug 1318569

Summary: Eject cdrom fails since tray is locked but next try succeeds
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pzhang>
Component: libvirtAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, lmen, mzhan, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.3.3-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:39:50 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 Pei Zhang 2016-03-17 09:20:30 UTC
Description of problem:
In rhel7.2 update-device and change-media can be done once. but now it needs to execute twice.

Version-Release number of selected component (if applicable):
libvirt-1.3.2-1.el7.x86_64
qemu-kvm-rhev-2.5.0-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. define and start a guest with cdrom device.
# virsh domblklist r72
Target     Source
------------------------------------------------
hdc        /mnt/at-dt/change-media/a.iso
vda        /tmp/zp/r72.qcow2

2. eject cdrom 

# virsh change-media r72 --eject hdc 
error: Failed to complete action eject on media
error: internal error: unable to execute QEMU command 'eject': Tray of device 'drive-ide0-1-0' is not open

# virsh change-media r72 --eject hdc 
Successfully ejected media.


Actual results:
As step2, change-media eject cdrom failed at first time, succeed at the second time.

Expected results:
As the expected result as before, it should be done once. 

Additional info:
In qemu-kvm-rhev-2.5.0-2, the error message after ejecting cdrom is changed.
It is not "is locked" any more. It's "Tray of device xx is not open".
but libvirt is still checking if cdrom "is locked".
......
  if (ret < 0 && c_strcasestr(virJSONValueToString(reply, false), "is locked"))
       ret = -2;
......

Comment 2 Pavel Hrdina 2016-03-22 12:30:01 UTC
Upstream commit:

commit 0f4d31720430b4e3735064cc0d8f88a1a438e154
Author: Pavel Hrdina <phrdina>
Date:   Thu Mar 17 16:38:28 2016 +0100

    qemu-hotplug: fix eject media

Comment 3 Mike McCune 2016-03-28 23:18:47 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 5 lijuan men 2016-04-07 10:01:12 UTC
verify the bug.

version:
libvirt-1.3.3-1.el7.x86_64
qemu-kvm-rhev-2.5.0-4.el7.x86_64

step:
1.define and start a guest with cdrom:
[root@localhost ~]# virsh domblklist r7
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/r7-1.qcow2
vdd        /dev/sdb4
hda        /root/RHEL-7.2-20151030.0-Server-x86_64-dvd1.iso

2.eject cdrom 
[root@localhost ~]# virsh change-media r7 --eject hda
Successfully ejected media.

[root@localhost ~]# virsh domblklist r7
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/r7-1.qcow2
vdd        /dev/sdb4
hda        -

Comment 7 errata-xmlrpc 2016-11-03 18:39:50 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, 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://rhn.redhat.com/errata/RHSA-2016-2577.html