Bug 847259

Summary: qemu host cdrom support not properly updating guests on media changes at physical CD/DVD drives
Product: Red Hat Enterprise Linux 5 Reporter: langfang <flang>
Component: kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.9CC: amit.shah, armbru, chayang, flang, juzhang, mkenneth, pbonzini, qzhang, rhod, sluo, virt-maint, wdai, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
A CD-ROM device can be assigned to a guest by configuring the guest to back a virtual CD-ROM device with a physical device's special file, for example, /dev/sr0. When a physical CD-ROM device is assigned to a guest, the guest assumes it has full control of the device. However, it is still possible to access the device from the host. In such a case, the guest can become confused about the CD-ROM state; for instance, running eject commands in the host to change media can cause the guest to attempt to read beyond the size of the new medium, resulting in I/O errors. To work around this problem, do not access a CD-ROM device from the host while it is assigned to a guest.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-06 14:44:27 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 langfang 2012-08-10 10:16:58 UTC
Description of problem:

qemu host cdrom support not properly updating guests on media changes at physical CD/DVD drives,this bug some like bug687900(rhel6 host).but this is reflect rhel5 host

Version-Release number of selected component (if applicable):
host:
# uname -r
2.6.18-333.el5
# rpm -q kvm
kvm-83-258.el5

gust:
# uname -r
2.6.18-333.el5

How reproducible:
100%

Steps to Reproduce:
1.boot guest with physical cdrom
CLI:/usr/libexec/qemu-kvm -m 2G -smp 2 -cpu qemu64,+sse2 -drive file=/home/111.raw,format=raw,media=disk,if=boot=on,werror=stop -net nic,model=virtio,macaddr=04:16:37:51:37:27,vlan=0 -net tap,sndbuf=0,vlan=0,script=/etc/qemu-ifup,downscript=no -uuid `uuidgen` -vnc :18 -boot c -usbdevice tablet -no-hpet -rtc-td-hack -no-kvm-pit-reinjection -monitor stdio -balloon virtio -drive file=/dev/cdrom,media=cdrom,if=ide

2.in guest
#df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       16G  2.6G   13G  18% /
/dev/vda1              99M   18M   77M  19% /boot
tmpfs                 941M     0  941M   0% /dev/shm
/dev/hda              624M  624M     0 100% /media/rhev-hypervisor

#mount /dev/hda /mnt
#cat /dev/block/hda/size
208468
3.in guest
#cp -r /mnt/boot.bat /home----->work well

4.in host:
#eject --->change anoter physical cdrom
5.in guest
#df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       16G  2.6G   13G  18% /
/dev/vda1              99M   18M   77M  19% /boot
tmpfs                 941M     0  941M   0% /dev/shm
/dev/hda              624M  624M     0 100% /media/CRMEXFPP_EN
#mount /dev/hda /mnt
#cp -r support/ /home
cp: reading `support/tools/dcdiag.exe': Input/output error
cp: reading `support/tools/deploy.cab': Input/output error
cp: reading `support/tools/fastwiz.exe': Input/output error
cp: reading `support/tools/gbunicnv.exe': Input/output error
cp: reading `support/tools/repadmin.exe': Input/output error
cp: reading `support/tools/support.cab': Input/output error
#cat /sys/block/hda/size
208468------>size not change for new cdrom,same as previous 


  
Actual results:
after change another physical cdrom--then cp file ,will show Input/output error,can the physical cdrom size not change .

Expected results:

when change cdrom,cdrom size will change ,and "cp" not error
Additional info:

Comment 1 Ronen Hod 2012-08-12 14:02:46 UTC
For RHEL6/7 we suggest using SCSI passthrough for host CD-ROM access.
For RHEL5 we do not have a solution, and we will not develop one, so I am closing this bug.

Amit, Markus,
Is there any workaround, or advice that we can put in a tech-note?

Thanks, Ronen.

Comment 2 Markus Armbruster 2012-08-13 07:39:05 UTC
Keep the host's paws off the physical CD-ROM.  Does running the eject command in the guest work?  RHEL-6 has trouble there: bug 729225.

Comment 3 Ronen Hod 2012-08-13 08:02:16 UTC
Markus,

Please write a tech note, and close this bug.

Thanks, Ronen.

Comment 4 langfang 2012-08-13 10:53:29 UTC
(In reply to comment #2)
> Keep the host's paws off the physical CD-ROM.  Does running the eject
> command in the guest work?  RHEL-6 has trouble there: bug 729225.



try this test more than five times,every time the guest can eject  host CDROM.

1.boot guest 
2.
(qemu) info block
virtio0: type=hd removable=0 file=/home/rhel5.9-x86_64.qcow2 ro=0 drv=qcow2 encrypted=0
ide0-hd0: type=hd removable=0 file=/dev/cdrom ro=0 drv=host_device encrypted=0
ide1-cd0: type=cdrom removable=1 locked=0 [not inserted]
floppy0: type=floppy removable=1 locked=0 [not inserted]
sd0: type=floppy removable=1 locked=0 [not inserted]
(qemu) change ide1-cd0 /dev/cdrom
(qemu) info block
virtio0: type=hd removable=0 file=/home/rhel5.9-x86_64.qcow2 ro=0 drv=qcow2 encrypted=0
ide0-hd0: type=hd removable=0 file=/dev/cdrom ro=0 drv=host_device encrypted=0
ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_device encrypted=0
floppy0: type=floppy removable=1 locked=0 [not inserted]
sd0: type=floppy removable=1 locked=0 [not inserted]

3)in guest

#eject ------>host CDROM successfully eject
4)push host CDROM-->wait about 10 sec
(qemu) info block
virtio0: type=hd removable=0 file=/home/rhel5.9-x86_64.qcow2 ro=0 drv=qcow2 encrypted=0
ide0-hd0: type=hd removable=0 file=/dev/cdrom ro=0 drv=host_device encrypted=0
ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_device encrypted=0
floppy0: type=floppy removable=1 locked=0 [not inserted]
sd0: type=floppy removable=1 locked=0 [not inserted 
5) repeat 4,5,about five times ,can successfully eject the host CDROM