RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1019926 - Virtual machine does not start if CD is not in drive
Summary: Virtual machine does not start if CD is not in drive
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.4
Hardware: All
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Martin Kletzander
QA Contact: Virtualization Bugs
URL:
Whiteboard:
: 1065507 (view as bug list)
Depends On: 868673
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-16 16:00 UTC by Mikuláš Patočka
Modified: 2014-10-14 04:17 UTC (History)
6 users (show)

Fixed In Version: libvirt-0.10.2-35.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-14 04:17:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1374 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2014-10-14 08:11:54 UTC

Description Mikuláš Patočka 2013-10-16 16:00:45 UTC
Description of problem:
If virtual machine's virtual CD drive is assigned to a physical CD drive and
there is no CD in the physical CD drive, the virtual machine does not start.

Version-Release number of selected component (if applicable):
RHEL6.4

How reproducible:
Always

Steps to Reproduce:
1. Have some virtual machine
2. Put some CD into the physical CD drive
3. Go to virt manager, attach the physical CD drive to the virtual machine
4. Turn off the virtual machine
5. Remove the CD from the drive
6. Try to start the virtual machine again

Actual results:
You get this error:
Error starting domain: nelze otevřít soubor '/dev/sr0': Médium nebylo nalezeno
Details:
Error starting domain: nelze otevřít soubor '/dev/sr0': Médium nebylo nalezeno

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 44, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/domain.py", line 1063, in startup
    self._backend.create()
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 678, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: nelze otevřít soubor '/dev/sr0': Médium nebylo nalezeno

Expected results:
The virtual machine should start.

Additional info:
Note - if you use O_NONBLOCK flag to the open syscall, you can open a CDROM
drive (/dev/sr0) even if there is no CD in it. If you don't use the O_NONBLOCK
flag, you can't open a device /dev/sr0 if there is no CD in it - it fails with
-ENOMEDIUM. You should modify virt manager to use O_NONBLOCK so that it doesn't
fail when there is no CD in the drive.

Comment 2 Martin Kletzander 2014-02-20 08:21:13 UTC
The thing is that virt-manager cannot yet specify startupPolicy for disks and libvirt can specify that for block device only upstream.  Can you attach the output of 'virsh dumpxml <domain_name>' in here?  Thank you.

Due to these not being specified, libvirt will fail starting a domain when some of the disks (cdroms, etc.) are missing and this is on purpose.

Comment 4 Mikuláš Patočka 2014-02-20 23:40:29 UTC
(In reply to Martin Kletzander from comment #2)
> The thing is that virt-manager cannot yet specify startupPolicy for disks
> and libvirt can specify that for block device only upstream.  Can you attach
> the output of 'virsh dumpxml <domain_name>' in here?  Thank you.
> 
> Due to these not being specified, libvirt will fail starting a domain when
> some of the disks (cdroms, etc.) are missing and this is on purpose.

The problem is not that the cdrom is missing. The cdrom is there; there is no CD
in it.

You should find a piece of code in libvirtd that generated this error:
"Error starting domain: nelze otevřít soubor '/dev/sr0': Médium nebylo nalezeno"
and modify that code so that it passes O_NONBLOCK flag to the open syscall.

I believe that when you use O_NONBLOCK flag when opening the cdrom, it will work.

Comment 5 Martin Kletzander 2014-02-21 07:22:00 UTC
Let me explain a bit differently.  Previously, libvirt was designed so it prevents starting of incomplete guests.  By incomplete I mean missing a disk, cd or even CD in that drive.  Libvirt cannot know whether you want the CD to be attached and empty or whether that's a mistake.  If it is not and you want the drive to be empty (in the guest), you should acknowledge it by removing the 'dev' attribute or the 'source' element.  virt-manager can do that by clicking 'disconnect' on that drive.  On newer libvirt this can be done automatically, but starting qemu with a block drive which has no medium in it is unsupported.

So I guess there's a solution for every use case.

Comment 6 Mikuláš Patočka 2014-02-21 08:04:01 UTC
The problem is that if the virtual machine is being used by a user without
computer science skills (as it was in this case when this bug happened), your
solution doesn't work.

The user doesn't know what "/dev/sr0" is. She can't decode the stacktrace. She
doesn't know that she should go to the virtual machine configuration panel,
select the cd-rom and click on the "disconnect" button - the error message
doesn't tell that she should do it!

The user simply expects that the machine just works. Why should she be forced to
do extra tasks when she removes or inserts CD to a drive? Why does she get a
completely cryptic error message with a stacktrace?

If you start a virtual machine with CD in the drive and then remove the CD, the
virtual machine continues to run correctly. The virtual machine can run without
CD in the drive. If the virtual machine can run without CD in the drive, there is
no reason why do we need to prevent it from starting without CD in the drive.

I understand that you don't want to start a virtual machine when some device is
missing because it may cause a lot of trouble. However, in this case, the device
is not missing - /dev/sr0 is there, and you can open it (if you added O_NONBLOCK
to the open syscall) and attach it to the virtual machine.

I think that adding O_NONBLOCK to relevant places will fix this problem.

Comment 7 Jiri Denemark 2014-03-27 10:25:33 UTC
*** Bug 1065507 has been marked as a duplicate of this bug. ***

Comment 8 chhu 2014-04-03 10:12:16 UTC
Reproduced with packages:
libvirt-0.10.2-29.el6.x86_64
qemu-kvm-0.12.1.2-2.423.el6.x86_64

Test steps:
1. make sure there is no CD in the cdrom, start a guest with xml below:
# virsh define r6-test.xml 
Domain r6 defined from r6-test.xml

# virsh dumpxml r6| grep disk -A 7
    ......
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source dev='/dev/sr0'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

# virsh start r6
error: Failed to start domain r6
error: cannot open file '/dev/sr0': No medium found

Test results:
failed to start the guest without CD in the cdrom with source dev in xml.

Comment 10 Martin Kletzander 2014-04-24 15:09:41 UTC
Fixed upstream with v1.2.3-173-g9556681:

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

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

Comment 14 chhu 2014-05-12 03:53:58 UTC
Reproduced on libvirt-0.10.2-33.el6.x86_64,

Verified with packages:
libvirt-0.10.2-35.el6.x86_64

Test steps:
1. make sure there is no CD in the cdrom, start a guest with xml below successfully.
# virsh create r6-test.xml 
Domain r6-qcow2 created from r6-test.xml

# virsh dumpxml r6-qcow2| grep disk -A 8
......
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source dev='/dev/sr0'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

2. Create another domain, put a CD into the physical CD drive, go to virt manager, attach the physical CD drive to the virtual machine, turn off the virtual machine, remove the CD from the drive, then start the virtual machine again successfully.

Test results:
command work well.

Comment 16 errata-xmlrpc 2014-10-14 04:17:48 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-2014-1374.html


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