Bug 868673

Summary: booting guest with empty host cdrom: cannot open file '/dev/sr0': No medium found
Product: [Community] Virtualization Tools Reporter: Cole Robinson <crobinso>
Component: libvirtAssignee: Martin Kletzander <mkletzan>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: acathrow, berrange, clalancette, dallan, itamar, jforbes, laine, libvirt-maint, mkletzan, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-24 11:11:21 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 1019926    

Description Cole Robinson 2012-10-21 11:35:52 EDT
Using disk XML

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

And no media in the host CDROM, booting fails like:

  error: cannot open file '/dev/sr0': No medium found

This is coming from:

qemu_command.c:qemuDomainDetermineDiskChain->virStorageFileGetMetadata

Easy-ish fix is to use O_NONBLOCK when opening the path, but then trying to read the non-existing file header later on just fails with an i/o error.

qemu has handled this for a while by trying to detect host devices and altering open flags appropriately, see the *probe* functions here: 

http://git.qemu.org/?p=qemu.git;a=blob;f=block/raw-posix.c

This is something we explicitly made work in qemu in the past due to user request, so it'd be nice to get it working again.
Comment 1 Cole Robinson 2013-12-16 14:53:22 EST
Still relevant with libvirt 1.1.3 in fedora 20, but given that no one else has complained in 2 releases, moving it to the upstream tracker
Comment 2 Martin Kletzander 2014-04-24 11:11:21 EDT
Fixed upstream with v1.2.3-173-g9556681:

commit 955668138873f2dd9b2e9989fecaddb33dc149c7
Author: Martin Kletzander <mkletzan@redhat.com>
Date:   Wed Apr 16 17:31:50 2014 +0200

    qemu: don't check for backing chains for formats w/o snapshot support