Bug 923053

Summary: change-media can not insert media on block type cdrom
Product: Red Hat Enterprise Linux 6 Reporter: weizhang <weizhan>
Component: libvirtAssignee: Gunannan Ren <gren>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: acathrow, cwei, dallan, dyuan, jdenemar, jyang, lnovich, mzhan, pkrempa, xuzhang, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.10.2-22.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 08:52:08 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 weizhang 2013-03-19 05:44:14 UTC
Description of problem:
virsh command change-media can not insert media on block type cdrom

Version-Release number of selected component (if applicable):
rhel6u4 release

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/>
    </disk>
2. Change media
# virsh change-media guest hdc /dev/sdb --insert
succeeded to complete action insert on media
3. Check the domain xml
# virsh dumpxml guest |grep cdrom -A 5
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>


  
Actual results:
disk can not be inserted.

Expected results:
disk can be inserted.

Additional info:

Comment 1 Jiri Denemark 2013-03-19 09:16:39 UTC
This apparently never worked since virsh is generating incorrect XML for block disk types. It uses "<source block='/dev/sdb'/>" while the correct name of the attribute for block disks is "dev".

Comment 2 Osier Yang 2013-03-21 04:36:41 UTC
(In reply to comment #1)
> This apparently never worked since virsh is generating incorrect XML for
> block disk types. It uses "<source block='/dev/sdb'/>" while the correct
> name of the attribute for block disks is "dev".

So this implies 2 bugs: One is of virsh XML generator, one is the qemu API should fail if the XML is not right.

Comment 3 Jiri Denemark 2013-03-21 08:52:44 UTC
The second bug is already covered by bug 888748 requesting RNG validation.

Comment 4 Osier Yang 2013-03-21 11:30:31 UTC
(In reply to comment #3)
> The second bug is already covered by bug 888748 requesting RNG validation.

Hum, it's something I tried to do long time ago, but then forgot.

http://www.redhat.com/archives/libvir-list/2012-January/msg00274.html

I'm going to pick it again.

Comment 5 Gunannan Ren 2013-05-27 13:33:35 UTC
proposed patch sent to upstream
https://www.redhat.com/archives/libvir-list/2013-May/msg01851.html

Comment 13 Xuesong Zhang 2013-08-15 05:46:33 UTC
This bug is verified on latest libvirt build: libvirt-0.10.2-22.el6.x86_64

steps:
1. start one guest with the following xml.
<disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>

2. prepare one block disk for inserting, make sure that there is one file on the block disk.
# mount /dev/sdb /mnt
# ls /mnt/
lost+found  newfile
# umount /mnt

3. insert the blcok disk to the guest cdrom, the source dev can be seen.
# virsh change-media a hdc /dev/sdb --insert
succeeded to complete action insert on media
# virsh dumpxml a|grep cdrom -A 5
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

4. login the guest, make sure the files can be seen in the guest.
# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
# ls /mnt/
lost+found  newfile


So, change the bug status to "verify".

Comment 15 errata-xmlrpc 2013-11-21 08:52:08 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.

http://rhn.redhat.com/errata/RHBA-2013-1581.html