Bug 1271069

Summary: Change media fail with virtio scsi cdrom when tray is open
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: libvirtAssignee: Jaroslav Suchanek <jsuchane>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: rbalakri, xuzhang, yanyang, yisun
Target Milestone: rcKeywords: TestOnly
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:26:05 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 Han Han 2015-10-13 06:26:13 UTC
Description of problem:
When change media lively with scsi cdrom and the argument tray='open', it
will fail.

Version-Release number of selected component (if applicable):
libvirt-1.2.17-13.el7.x86_64
qemu-kvm-rhev-2.3.0-30.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Add a scsi empty cdrom with argument tray='open' to a guest:
...
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='sda' bus='scsi' tray='open'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
...

2. Start guest and insert media :
# virsh start t100 
Domain t100 started

# virsh change-media t100 sda  /tmp/a.iso --insert 
error: Failed to complete action insert on media
error: internal error: unable to execute QEMU command 'eject': Device 'drive-scsi0-0-0-0' is locked

# virsh change-media t100 sda  /tmp/a.iso --insert
Successfully inserted media.

3. Restart guest and update media:
# virsh destroy t100&&virsh start t100
Domain t100 destroyed
Domain t100 started

# virsh change-media t100 sda  /tmp/a.iso --update 
error: Failed to complete action update on media
error: internal error: unable to execute QEMU command 'eject': Device 'drive-scsi0-0-0-0' is locked

# virsh change-media t100 sda  /tmp/a.iso --update
Successfully updated media.

Actual results:
As step2&3

Expected results:
change media not failed.

Additional info:
Bug reproduced only when scsi cdrom, guest started, tray opened. Shutdowned guest or sata/ide bus or without
tray open doesn't produce the bug.

Comment 1 Han Han 2015-10-24 02:33:22 UTC
The Bug seems fixed on upstream.
On libvirt-1.2.20-2.fc24.x86_64 not reproduced:
# virsh change-media centos sda /tmp/boot.iso --insert 
Successfully inserted media.

Pls confirm it.

Comment 3 Jaroslav Suchanek 2016-06-28 13:06:31 UTC
Fixed upstream by:
commit c59b9e1483ca50290f865737877358978d88dfc7
Author:     Jaroslav Suchanek <jsuchane>
AuthorDate: Tue Jun 28 13:05:30 2016 +0200
Commit:     Erik Skultety <eskultet>
CommitDate: Tue Jun 28 13:52:34 2016 +0200

    logging: fixing log level initialization from cmdline

    Reorder code for setting default log level from cmdline prior
    initialization of log outputs. Thus the --verbose option is reflected.

    This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325072

Comment 4 Jaroslav Suchanek 2016-06-28 13:27:42 UTC
Please ignore the comment 3. That is unrelated.

Anyway, I was not able to reproduce this with qemu-kvm-rhev-2.6.0-9.el7.x86_64 and libvirt-1.3.5-1.el7.x86_64. There were numerous fixes related to blockdev operations. Please re-test this. Thanks.

Comment 5 yisun 2016-09-09 11:38:06 UTC
Verified on libvirt-2.0.0-8.el7.x86_64

# virsh dumpxml virtlab_test_copy| grep cdrom -a10
...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='sdb' bus='scsi' tray='open'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
...

# virsh start virtlab_test_copy
Domain virtlab_test_copy started


# virsh change-media virtlab_test_copy sdb  /tmp/a.iso --insert 
Successfully inserted media.

# virsh dumpxml virtlab_test_copy| grep cdrom -a10
...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/a.iso'/>
      <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 change-media virtlab_test_copy sdb --eject
Successfully ejected media.

# virsh dumpxml virtlab_test_copy| grep cdrom -a10
...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <backingStore/>
      <target dev='sdb' bus='scsi' tray='open'/>
      <readonly/>
      <alias name='scsi0-0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
...


# virsh change-media virtlab_test_copy sdb  /tmp/a.iso --insert 
Successfully inserted media.


# virsh dumpxml virtlab_test_copy| grep cdrom -a10
...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/a.iso'/>
      <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 change-media virtlab_test_copy sdb  /tmp/a.iso --insert 
error: The disk device 'sdb' already has media


# virsh dumpxml virtlab_test_copy| grep cdrom -a10
...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/a.iso'/>
      <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>
...

Comment 7 errata-xmlrpc 2016-11-03 18:26:05 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