Bug 709585

Summary: qemu-kvm can not start with /dev/sr0 if no media in physical cdrom
Product: Red Hat Enterprise Linux 5 Reporter: Mike Cao <bcao>
Component: kvmAssignee: Markus Armbruster <armbru>
Status: CLOSED DEFERRED QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.7CC: bcao, bughunt, byrnejb, gcosta, juzhang, michen, mkenneth, nerijus, rhod, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-10 20:15:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 580948    

Description Mike Cao 2011-06-01 05:52:55 UTC
Description of problem:
,do not insert media in physical cdrom  ,try to start guest with -cdrom /dev/sr0 ,qemu-kvm could not start 

Version-Release number of selected component (if applicable):
# uname -r
# rpm -q kvm

How reproducible:

Steps to Reproduce:
1.Do not insert any media in physical cdrom
2.start guest with -drive file=/dev/sr0,if=ide,media=cdrom
eg:/usr/libexec/qemu-kvm -M rhel5.6.0 -m 2048 -smp 4,sockets=4,cores=1,threads=1 -name RHEL6u1 -uuid 7c9a4b2c-8d58-6771-7748-0ce92bfd83f7 -monitor stdio -no-kvm-pit-reinjection -boot dc -drive file=/dev/stress/rhel6u1,if=virtio,boot=on,format=raw,cache=none -drive file=/dev/cdrom,if=ide,format=raw,cache=none,media=cdrom,bus=1,unit=0 -net nic,macaddr=54:52:00:7d:dd:37,vlan=0,model=virtio -net tap,vlan=0,downscript=no -serial pty -parallel none -usb -usbdevice tablet -vnc :2 -k en-us -vga cirrus -balloon none -notify all
Actual results:
qemu-kvm can not start with error :
qemu: could not open disk image /dev/cdrom

Expected results:
qemu-kvm could start 

Additional info:
Tried with /usr/libexec/qemu-kvm -cdrom /dev/sr0  ,does not hit this issue.

Comment 1 Mike Cao 2011-06-01 08:48:54 UTC
more info :

keep the tray open on the host ,start guest with 
/usr/libexec/qemu-kvm -drive file=/dev/sr0,if=ide,media=cdrom

Actual Results: the tray will auto-closed.

keep the tray open on the host ,start guest with 
/usr/libexec/qemu-kvm -cdrom /dev/sr0

Actual Restuls: the tray will *not* close

Comment 2 Markus Armbruster 2011-08-09 08:16:14 UTC
"-cdrom /dev/sr0" is shorthand for "-drive file=/dev/sr0,if=ide,index=2,media=cdrom".  Differences to the failing test case: lacks format=raw,cache=none, uses index=2 instead of bus=1,unit=0.  In my testing, format=raw causes the failure.

Comment 3 Markus Armbruster 2011-08-09 08:31:02 UTC
Without "format=raw", we get driver "host_device", which does the right thing for /dev/sr0.

"format=raw" overrides that: we get driver "raw", which can't cope with host devices.  In particular, it can't cope with ENOMEDIUM.

Comment 4 Markus Armbruster 2011-08-09 08:37:31 UTC
Mike, does libvirt use format=raw with file=/dev/sr0?

Could you give me the relevant part of the domain XML?  Should be an element <disk> within element <devices>.

Comment 5 Mike Cao 2011-08-09 09:13:00 UTC
(In reply to comment #4)
> Mike, does libvirt use format=raw with file=/dev/sr0?
> Could you give me the relevant part of the domain XML?  Should be an element
> <disk> within element <devices>.

yes .

this is the CLI generates by virt-manager

 /usr/libexec/qemu-kvm -S -M rhel5.4.0 -m 512 -smp 1,sockets=1,cores=1,threads=1 -name tt -uuid 77b30b96-b94b-89ac-e641-fc5c4d5fe71a -monitor unix:/var/lib/libvirt/qemu/tt.monitor,server,nowait -localtime -no-kvm-pit-reinjection -no-reboot -boot dc -drive file=/var/lib/libvirt/images/tt.img,if=ide,bus=0,unit=0,boot=on,format=raw,cache=none -drive file=/dev/sr0,if=ide,media=cdrom,bus=1,unit=0,readonly=on,format=raw -net nic,macaddr=54:52:00:79:fc:ab,vlan=0 -net tap,fd=20,vlan=0 -serial pty -parallel none -usb -usbdevice tablet -vnc -k en-us -vga cirrus -balloon virtio

Comment 6 Mike Cao 2011-08-09 09:14:15 UTC
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sr0'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' unit='0'/>

Comment 7 Markus Armbruster 2011-08-09 09:20:07 UTC
Note type='raw' in comment#6.  Apparently, virt-manager creates it that way.  Hmm.

Comment 8 Markus Armbruster 2011-08-09 09:28:12 UTC
Summary of findings so far:

format=raw doesn't work with /dev/sr0.  Omitting format=raw works.  format=host_device works.

Apparently, virt-manager specifically asks for "raw".

Things are different in RHEL-6: format=raw works, format=host_device doesn't, format=host_cdrom does (doesn't exist in RHEL-5).

Comment 10 James B. Byrne 2014-02-13 17:29:30 UTC
Guest OS = MS-WinV7proSP1 (updated to date)

The guest OS installed without difficulty via virt-manager. The guest responded to console commands and mouse actions, obtained network access and was updated.  Subsequent to the controlled shutdown of the guest system and power down of the vm the guest image fails to start giving instead this error:

virsh start brws-ms-v7-37v.brockley.harte-lyne.ca
error: Failed to start domain brws-ms-v7-37v.brockley.harte-lyne.ca
error: cannot open file '/dev/sr0': No medium found

Examination of the guest configuration file shows this:

     30     <disk type='block' device='cdrom'>
     31       <driver name='qemu' type='raw'/>
     32       <source dev='/dev/sr0'/>
     33       <target dev='hdc' bus='ide'/>
     34       <readonly/>
     35       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     36     </disk>

Despite the inference I draw from the above bug report, that the <driver> tag attribute 'format' actually refers to the attribute 'type' as the attribute format' is not found anywhere in the guest configuration file, one cannot in fact change the driver attribute 'type' to any value other than raw. Any attempt to do so results in this message:

unsupported configuration: unknown driver format value 'host_cdrom'
Failed. Try again? [y,n,f,?]:

Further, the value 'f' is not permitted so one cannot forcibly save the
configuration to determine if in fact it might work.

Is this a regression?

Comment 11 James B. Byrne 2014-02-13 17:44:21 UTC
P.S.  Loading a medium into the CDROM device permits the guest to start normally.

Comment 12 Mike Cao 2014-02-14 00:43:38 UTC
(In reply to James B. Byrne from comment #10)
> RHEl6
> qemu-kvm-
> virt-manager.x86_64-0.9.0-19.el6
> Guest OS = MS-WinV7proSP1 (updated to date)

This bug is used to track RHEL5 kVM bug  ,pls report it on RHEL6 against qemu-kvm component if you think it is a bug

Comment 13 David Tonhofer 2014-05-16 10:14:18 UTC
Happens on Fedora 20, too. 

Guest OS = MS-WinV7proSP1 (updated to date)

# virsh dumpxml win7

    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sr0'/>
      <target dev='hdb' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>

Comment 14 Nerijus Baliƫnas 2014-06-28 11:28:00 UTC
Bug 1065480 is reported against F20.