Bug 1120053 - Option shareable does not take effect after injecting a cdrom to guest by attach-disk
Summary: Option shareable does not take effect after injecting a cdrom to guest by att...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-16 07:41 UTC by yangyang
Modified: 2016-11-03 18:09 UTC (History)
7 users (show)

Fixed In Version: libvirt-1.3.1-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:09:47 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description yangyang 2014-07-16 07:41:33 UTC
Description of problem:
Tried to injecting a cdrom to guest by attach-disk passing option shareable. However, libvirt didnot write the element <shareable/> into guest xml

Version-Release number of selected component (if applicable):
libvirt-1.1.1-29.el7.x86_64

How reproducible:
100%

Steps:
1. Prepare a running guest with the following xml
.................
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/libvirt/images/test2.img'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
    </disk>
.................
2. Connect a device to cdrom
# virsh attach-disk test /var/lib/libvirt/images/test.iso hda --type cdrom --shareable
Disk attached successfully

3. check the dumpxml

Expected Results:
In step 3, the element <shareable/> should exist in xml.

<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <shareable/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Actual Results:
In step 3, the element <shareable/> was not found

<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test.iso'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>


Additional info:

The issue was also hit when injecting a cdrom to guest by attach-disk passing option --mode shareable.
# virsh attach-disk test /var/lib/libvirt/images/test.iso hda --type cdrom --mode shareable

Comment 2 Peter Krempa 2014-08-01 08:36:10 UTC
quick glance at the code reveals that "attach-disk" on an existing cdrom device just updates the media in the drive and cdrom device hotplug isn't supported at all. The problem lies in just changing the media and ignoring the rest of the XML.

Additionally the media change function is flawed as it doesn't handle remote storage.

Comment 6 Peter Krempa 2016-02-11 07:05:43 UTC
This was fixed by:

commit 1f39218e4fdca901f7adca442e6ed6957b6eadef
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Tue Aug 5 13:43:57 2014 +0200

    qemu: hotplug: Change arguments for qemuDomainChangeEjectableMedia
    
    Pass the source of the changed media instead of a complete disk
    definition.
    
    Note that the @disk argument now contains what @olddisk would contain.
    The new source is passed as a virStorageSource struct.

... and possibly few following patches.

v1.2.7-170-g1f39218

Comment 8 yisun 2016-09-02 13:15:21 UTC
Verified on libvirt-2.0.0-6.el7.x86_64 and passed

1. #virsh edit vm
...
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
    </disk>
...

2. #virsh start vm
3. #touch /var/lib/libvirt/images/test.iso
4. #virsh attach-disk vm /var/lib/libvirt/images/test.iso hda --type cdrom --shareable

5. # virsh dumpxml vm  | grep disk -A10
...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <shareable/>   <====== exists
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

6. #virsh destroy vm; virsh start vm
7. # virsh attach-disk vm /var/lib/libvirt/images/test.iso hda --type cdrom --mode shareable

8. # virsh dumpxml vm | grep disk -A10
 ...
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/test.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <shareable/>  <====== exists
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Comment 10 errata-xmlrpc 2016-11-03 18:09:47 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


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