Bug 491913 - adding a new cd-rom device to a KVM guest fails in libvirt with obscure error
adding a new cd-rom device to a KVM guest fails in libvirt with obscure error
Status: CLOSED CURRENTRELEASE
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
All Linux
low Severity medium
: ---
: ---
Assigned To: Libvirt Maintainers
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-24 12:04 EDT by Bill Nottingham
Modified: 2015-03-18 04:52 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-18 04:52:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Bill Nottingham 2009-03-24 12:04:24 EDT
Description of problem:

Full virt 32-bit x86 guest, running up-to-date F-9.

I go to the hardware tab, and attach a file as an IDE CD-ROM. After thinking for a minute, it says the device can't be added, and I can schedule it to be added on the next boot. I click 'OK'.

Meanwhile, whatever it *tried* to do paniced the filesystem of the guest VM (connected via 'IDE' disk.)

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

qemu-system-x86-0.10-0.9.kvm20090310git.fc11.x86_64
virt-manager-0.7.0-1.fc11.x86_64
Comment 1 Cole Robinson 2009-03-24 12:13:50 EDT
Can you attach /var/log/libvirt/qemu/VMNAME.log and ~/.virt-manager/virt-manager.log?

The device hotplug upsetting the guest is probably a qemu issue.
Comment 2 Bill Nottingham 2009-03-24 12:51:41 EDT
[Tue, 24 Mar 2009 11:53:01 virt-manager 4460] DEBUG (addhardware:634) Adding device:
    <disk type='file' device='cdrom'>
      <source file='/var/lib/libvirt/images/boot.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
[Tue, 24 Mar 2009 11:53:01 virt-manager 4460] DEBUG (addhardware:640) Device could not be
 hotplugged: internal error No device with bus 'ide' and target 'hdc'
[Tue, 24 Mar 2009 11:53:04 virt-manager 4460] DEBUG (domain:1140) Redefine with <domain t
ype='qemu' id='2'>
  <name>upgrade-test2</name>
  <uuid>8d998806-abfc-8f15-d547-c9f22a467b69</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <source file='/var/lib/libvirt/images/upgrade-test.img'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='network'>
      <mac address='54:52:00:53:47:67'/>
      <source network='default'/>
      <target dev='vnet0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/3'/>
      <target port='0'/>
    </serial>
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' keymap='en-us'/>
      <disk type='file' device='cdrom'>
      <source file='/var/lib/libvirt/images/boot.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk></devices>
  <seclabel type='dynamic' model='selinux'/>
</domain>

[Tue, 24 Mar 2009 11:54:07 virt-manager 4460] DEBUG (engine:442) Destroying vm 'upgrade-t
est2'.

qemu log coming shortly.
Comment 3 Bill Nottingham 2009-03-24 12:52:59 EDT
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-system-x86_64 -S -M pc -no-kqem
u -m 1024 -smp 1 -name upgrade-test2 -uuid 8d998806-abfc-8f15-d547-c9f22a467b69 -monitor 
pty -pidfile /var/run/libvirt/qemu//upgrade-test2.pid -boot c -drive file=/var/lib/libvir
t/images/upgrade-test.img,if=ide,index=0,boot=on -net nic,macaddr=54:52:00:53:47:67,vlan=
0 -net tap,fd=16,script=,vlan=0,ifname=vnet0 -serial pty -parallel none -usb -vnc 127.0.0
.1:0 -k en-us 
char device redirected to /dev/pts/2
char device redirected to /dev/pts/3
cont
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
raw_aio_remove: aio request not found!
....
<rebooted>
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-system-x86_64 -S -M pc -no-kqem
u -m 1024 -smp 1 -name upgrade-test2 -uuid 8d998806-abfc-8f15-d547-c9f22a467b69 -monitor 
pty -pidfile /var/run/libvirt/qemu//upgrade-test2.pid -boot c -drive file=/var/lib/libvir
t/images/upgrade-test.img,if=ide,index=0,boot=on -drive file=/var/lib/libvirt/images/boot
.iso,if=ide,media=cdrom,index=2 -net nic,macaddr=54:52:00:53:47:67,vlan=0 -net tap,fd=17,
script=,vlan=0,ifname=vnet0 -serial pty -parallel none -usb -vnc 127.0.0.1:0 -k en-us
Comment 4 Mark McLoughlin 2009-03-25 12:17:26 EDT
> Device could not be hotplugged: internal error No device with bus 'ide' and 
> target 'hdc'

That comes from qemudDomainChangeEjectableMedia() - at a glance, it looks like it's probably a libvirt bug.

I don't think we're changing the media of an existing cd-rom, but rather adding a new cd-rom device.
Comment 5 Gerry Reno 2009-04-14 03:16:19 EDT
Just got this same problem using 'attach-device' in F10:

# virsh attach-device TEST1  TEST1.cdrom-dvd-iso-F7i386.xml
libvir: QEMU error : internal error No device with bus 'ide' and target 'hdc'
error: Failed to attach device from TEST1.cdrom-dvd-iso-F7i386.xml

# cat TEST1.cdrom-dvd-iso-F7i386.xml
    <disk type='file' device='cdrom'>
      <source file='/iso/fedora/f7/f7-i386-dvd.iso'/>
      <target dev='hdc'/>
      <readonly/>
    </disk>

# rpm -qa | grep virt
python-virtinst-0.400.0-5.fc10.noarch
virt-manager-0.6.0-5.fc10.i386
libvirt-0.5.1-2.fc10.i386
virt-viewer-0.0.3-3.fc10.i386
libvirt-python-0.5.1-2.fc10.i386
Comment 6 Gerry Reno 2009-04-14 03:50:39 EDT
Defining a cdrom from the config files does not work but I can define a cdrom from virt-manager gui.  It is ide/hdb but it is not attached to the running VM.  It attaches on first reboot, but it generates this SELinux AVC violation:


SELinux is preventing qemu-kvm (qemu_t) "write" to ./f7-i386-dvd.iso (var_t). Detailed DescriptionSELinux denied access requested by qemu-kvm. It is not expected that this access is required by qemu-kvm and this access may signal an intrusion attempt. It is also possible that the specific version or configuration of the application is causing it to require additional access. Allowing AccessSometimes labeling problems can cause SELinux denials. You could try to restore the default system file context for ./f7-i386-dvd.iso, restorecon -v './f7-i386-dvd.iso' If this does not work, there is currently no automatic way to allow this access. Instead, you can generate a local policy module to allow this access - see FAQ Or you can disable SELinux protection altogether. Disabling SELinux protection is not recommended. Please file a bug report against this package. 


It's trying to write to the readonly cdrom device.
Comment 7 Gerry Reno 2009-04-14 04:35:34 EDT
I did a ps -ef and looked at what libvirt is generating and then tried to run that command manually:

/usr/bin/qemu-kvm -S -M pc -m 512 -smp 1 -name TEST1 -monitor pty -no-reboot -boot cd -drive file=/var/lib/libvirt/images/TEST1.img,if=ide,index=0,boot=on -drive file=/iso/fedora/f7/f7-i386-dvd.iso,if=ide,index=1 -net nic,macaddr=00:16:3e:63:26:4b,vlan=0 -net tap,fd=18,script=,vlan=0,ifname=vnet1 -serial none -parallel none -usb -vnc 127.0.0.1:1 -k en-us

I took off the -S and reworked the tap with a ifup script so it would work.  But even then I could not get the cdrom working.  It would try to boot from cdrom but always get a 0003 fatal error.

Only when I redefine the cdrom from being a 'drive' to being a 'cdrom' was I finally able to get the cdrom to read and boot:

/usr/bin/qemu-kvm -M pc -m 512 -smp 1 -name TEST1 -monitor pty -no-reboot -boot d -drive file=/var/lib/libvirt/images/TEST1.img,if=ide,index=0 -cdrom /iso/fedora/f7/f7-i386-dvd.iso -net nic,macaddr=00:16:3e:63:26:4b,vlan=0 -net tap,vlan=0,script=/etc/qemu-ifup,ifname=vnet1  -serial none -parallel none -usb vnc 127.0.0.1:0 -k en-us


There just seems to be lots of issues with libvirt and getting cdroms working.
Comment 8 Cole Robinson 2009-04-14 09:33:16 EDT
Gerry, in Comment #5, that attach device should fail for a running VM, but the error message is misleading and bogus. You can't hotplug ide disks AFAIK.

In comment #6, my guess is that you accidentally tried to add the media as a regular ide disk, rather than a cdrom, hence it wanting write permissions and trying to use 'hdb' rather than 'hdc'. Posting ~/.virt-manager/virt-manager.log should confirm or deny this. There shouldn't be any selinux errors for cdrom devices on rawhide.

The command line in comment #7 seems to confirm that the iso was not attached to the guest as a cdrom device.
Comment 9 Gerry Reno 2009-04-14 12:13:01 EDT
QUOTE: You can't hotplug ide disks AFAIK.

Then it should tell the user that the attach will take place on the next reboot, not just fail.

QUOTE: In comment #6, my guess is that you accidentally tried to add the media as a regular ide disk, rather than a cdrom...

I deleted the current entry in the gui and set it up again.  It showed as hdc with type of cdrom.  I then chose CDROM in boot options, clicked Apply then clicked RUN.  And got this traceback:

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/engine.py", line 532, in run_domain
    vm.startup()
  File "/usr/share/virt-manager/virtManager/domain.py", line 380, in startup
    self.vm.create()
  File "/usr/lib/python2.5/site-packages/libvirt.py", line 285, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: internal error QEMU quit during console startup
Boot device 'd' was given twice


Still not able to use cdrom.
Comment 10 Cole Robinson 2009-04-14 12:39:21 EDT
Hmm, that boot device backtrace seems like a legit bug somewhere (possibly virt-manager). Can you file a separate bug against virt-manager with that backtrace, and please include your entire ~/.virt-manager/virt-manager.log?

As far as the 'ide' hotplug is concerned, virt-manager will inform the user that the device will be attached after the next reboot if the hotplug fails. virsh won't (as you saw), but virsh is intended to be a simple interface and map directly to the libvirt API, so won't try to determine the intentions of the user, just raising the API error.

The only libvirt bug I see here is that the error message:

"No device with bus 'ide' and target 'hdc'"

Needs to be improved if the user is attempting to hotplug an ide cdrom, not just change cdrom media (although unfortunately the semantics of the attach device command make this distinction impossible, so we will just need to make the message verbose.)
Comment 11 Gerry Reno 2009-04-14 12:57:16 EDT
And...
I just went back to virt manager gui and tried this a third time.  Removing and redeclaring the entry for the cdrom.  It showed again as hdc with type cdrom.  Selected cdrom from boot options and clicked Apply then clicked RUN.  This time I got the AVC denial again:

SELinux is preventing qemu-kvm (qemu_t) "write" to ./f7-i386-dvd.iso (var_t).
Comment 12 Mark McLoughlin 2009-04-19 09:28:31 EDT
I've just tested this myself with latest rawhide and it seems to be working as expected - we can't hotplug, virt-manager offers to add it for next boot and the guest doesn't panic.

(In reply to comment #7)
> There just seems to be lots of issues with libvirt and getting cdroms working.

Perhaps, but please try and limit each bugzilla to a single issue. Otherwise things just get way too confusing.

(In reply to comment #11)
> I got the AVC denial again:
> 
> SELinux is preventing qemu-kvm (qemu_t) "write" to ./f7-i386-dvd.iso (var_t).  

See bug #496250 - this AVC denial isn't actually a problem because qemu falls back to opening it for reading only

(In reply to comment #10)
> The only libvirt bug I see here is that the error message:
> 
> "No device with bus 'ide' and target 'hdc'"
> 
> Needs to be improved if the user is attempting to hotplug an ide cdrom

Yes, indeed - and it's a very minor issue as it doesn't appear in the UI.

Removing from F11VirtTarget and moving to libvirt upstream bugzilla
Comment 14 Ján Tomko 2015-03-18 04:52:45 EDT
commit afa44743b68139bf0c9a0ef2a16d70f178b22916
Author:     Peter Krempa <pkrempa@redhat.com>
AuthorDate: 2014-08-01 11:22:16 +0200
Commit:     Peter Krempa <pkrempa@redhat.com>
CommitDate: 2014-08-20 09:28:03 +0200

    qemu: Explicitly state that hotplugging cdroms and floppies doesn't work

git describe: v1.2.7-166-gafa4474 contains: v1.2.8-rc1~80

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