Bug 952499 - change-media can not insert iso when start rhel7 guest with empty cdrom
Summary: change-media can not insert iso when start rhel7 guest with empty cdrom
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 951192
TreeView+ depends on / blocked
 
Reported: 2013-04-16 05:23 UTC by weizhang
Modified: 2015-11-19 05:42 UTC (History)
7 users (show)

Fixed In Version: libvirt-1.2.14-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:42:52 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description weizhang 2013-04-16 05:23:05 UTC
Description of problem:
change-media can not insert iso when start rhel7 guest with empty cdrom

Version-Release number of selected component (if applicable):
qemu-kvm-1.4.0-2.el7.x86_64
kernel-3.8.0-0.43.el7.x86_64
libvirt-1.0.4-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start a guest with
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

2. Do insert
virsh change-media r7 hdc /var/lib/libvirt/images/b.iso --insert

3. Dumpxml
virsh dumpxml r7| grep cdrom -A 5

  
Actual results:
iso can not be inserted

Expected results:
iso can be inserted

Additional info:
update-device can succeed

Comment 1 Michal Privoznik 2013-04-23 09:52:44 UTC
Why do you think this is a bug? You are trying to instert an ISO into block device. If you want to insert an ISO image, you should be using <disk type='file'>.

Comment 2 Michal Privoznik 2013-06-10 15:36:06 UTC
I think this is a misconfiguration problem not a libvirt bug. As I've said in comment 1 you should be using <disk type='file' device='cdrom'>. However, if you or somebody else think otherwise, please reopen this bug.

Comment 3 Peter Krempa 2015-03-13 12:30:47 UTC
(In reply to Michal Privoznik from comment #2)
> I think this is a misconfiguration problem not a libvirt bug. As I've said
> in comment 1 you should be using <disk type='file' device='cdrom'>. However,
> if you or somebody else think otherwise, please reopen this bug.

It actually is a bug in virsh that doesn't allow to specify the correct media type when using the change-media virsh command.

I already proposed a patch that fixes 'virsh change-media'. It's part of series posted for review:

http://www.redhat.com/archives/libvir-list/2015-March/msg00640.html

Comment 4 Peter Krempa 2015-03-17 16:17:02 UTC
This series should fix this problem:

commit 7a8f54bf4c59a27c4ae0dd5a2c2eadd093c107ad
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 17:33:09 2015 +0100

    conf: disk: Simplify checking if source definition was parsed
    
    Previously we had to check for 3 fields to see if the source was filled.
    Repurpose one of the variables as a boolean flag and use it instead of
    combining multiple sources.
    
    For the condition that checks that only CDROM/FLOPPY drives can be empty
    we can use the virStorageSourceIsEmpty() helper.

commit 158340e2fbab9a49013ee0de59af7236da014622
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 17:53:01 2015 +0100

    util: storage: Fix check for empty storage device
    
    If the storage device type is parsed as network our parser still allows
    it to omit the <source> element. The empty drive check would not trigger
    on such device as it expects that every network storage source is valid.
    
    Use VIR_STORAGE_NET_PROTOCOL_NONE as a marker that the storage source is
    empty.

commit d0dc6c036914da4905c3f483be3036014a38fe9b
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 17:12:12 2015 +0100

    qemu: driver: Fix cold-update of removable storage devices
    
    Only selected fields from the disk source were copied when cold updating
    source in a CDROM drive. When such drive was backed by a network file
    this resulted into corruption of the definition:
    
        <disk type='network' device='cdrom'>
          <driver name='qemu' type='raw' cache='none'/>
          <source protocol='gluster' name='gluster-vol1(null)'>
            <host name='localhost'/>
          </source>
          <target dev='vdc' bus='virtio'/>
          <readonly/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
        </disk>
    
    Update the whole source instead of cherry-picking elements.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1166024

commit e7974b4f80f320c9232ff31762fd1aa82a590f2e
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 16:57:56 2015 +0100

    qemu: hotplug: Use checker function to check if disk is empty

commit f4b5f53027da4fed2250628e11bac40191803a15
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 16:41:21 2015 +0100

    virsh: domain: Fix the change-media command
    
    The command did not modify the disk type and thus didn't allow to change
    media from a file image to a block backed image or vice versa. In
    addition when operating on a network backed removable devices the
    command would replace the while <source> subelement with an invalid one.
    
    This patch adds the --block option that allows to specify that the new
    image is block backed and assumes that without that option all images
    are file backed. Since network backends were always mangled it should
    not cause problems.

commit 4cbcaffb74c1f59734eb7379cd8165922345ec13
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 16:04:00 2015 +0100

    virsh: domain: Add --print-xml flag for command change-media
    
    Allow printing the XML that would be used mostly for debugging purposes.

commit 1cc820937ac64d75d1a4ce090af7a928e30a7728
Author: Peter Krempa <pkrempa@redhat.com>
Date:   Thu Mar 12 11:51:51 2015 +0100

    virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach disk
    
    Since cmdDetachDisk() calls into vshPrepareDiskXML() with
    type == VSH_PREPARE_DISK_XML_NONE && source == NULL this would result
    into skipping all the checks and effectively turn the function into a
    XML formatter.
    
    This patch changes the code to use the formatter directly so that the

Comment 7 Yang Yang 2015-06-10 03:36:35 UTC
Cannot reproduce it with libvirt-1.2.8-13.el7.x86_64

As the patches series are same with those in bz1166024, bz1166024 has been verified, so move it to verified status too.

Comment 9 errata-xmlrpc 2015-11-19 05:42:52 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/RHBA-2015-2202.html


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