virsh attach-disk doesn't work

Bug #203020 reported by Adam Sommer
36
This bug affects 4 people
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Medium
Unassigned

Bug Description

Output of "virsh -c qemu:///system attach-disk domain /dev/sr0 /media/cdrom" gives:

  libvir: QEMU error ��e: only CDROM disk devices can be attached

Tried both with and without sudo. Also, CDROM is a sata device, but I guess that doesn't make a difference. Tried doing virsh dumpxml editing the file then doing virsh define as well, still not working.

Thanks

Revision history for this message
Martin Emrich (emme) wrote :

I was not able to attach a CDROM device either.

via virsh, I get this:
attach-disk winxp /home/martin/path/to/my.iso hdc --mode readonly --driver file --type cdrom
(I tried various combinations of --driver, --type and --mode as well as hda,hdc,/dev/hdc,cdrom,/dev/cdrom and /dev/media for the target)

via virt-manager, I get this in an error box after completing the "add storage" wizard:
Unable to complete install: 'Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/addhardware.py", line 514, in add_device
    self.vm.add_device(xml)
  File "/usr/share/virt-manager/virtManager/domain.py", line 729, in add_device
    raise RuntimeError, "Unable to attach device to live guest, libvirt reported error:\n" + device_exception
RuntimeError: Unable to attach device to live guest, libvirt reported error:
virDomainAttachDevice() failed CDROM not attached, cannot change media'

Changed in libvirt:
status: New → Confirmed
Revision history for this message
Martin Emrich (emme) wrote :

Oops, missed to paste the virsh error message:

virsh # attach-disk winxp /home/martin/path/to/my.iso hdc --mode readonly --driver file --type cdrom
libvir: QEMU Fehler winxp: CDROM not attached, cannot change media

Ciao
Martin

Revision history for this message
Omega (atrauzzi) wrote :

I'm getting the same or a similar error.

Unable to complete install: 'Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/addhardware.py", line 514, in add_device
    self.vm.add_device(xml)
  File "/usr/share/virt-manager/virtManager/domain.py", line 729, in add_device
    raise RuntimeError, "Unable to attach device to live guest, libvirt reported error:\n" + device_exception
RuntimeError: Unable to attach device to live guest, libvirt reported error:
virDomainAttachDevice() failed CDROM not attached, cannot change media
'

Seems like there are a lot of things to sort out with KVM, especially UI. I have faith! ;)

Revision history for this message
Nicolas Diogo (nicolasdiogo) wrote :

hi,

i also need to make the cdrom of my laptop available to virtual machines but virtual manager does not do it.

any thoughts if this is a but with the GUI or some more sinister?

Thanks

Nicolas

Revision history for this message
besson3c (joe-netmusician) wrote :

Did anybody ever find a solution to this problem? I'm still trying to work around this to get my CD attached somehow...

Revision history for this message
Jonathan Ultis (jonathan-ultis) wrote :

I ended up doing

virsh dumpxml MYDOMAIN > MYDOMAIN.xml
virsh destroy MYDOMAIN

- manually add the cdrom definition to MYDOMAIN.xml -

virsh create MYDOMAIN.xml

where the cdrom definition looks like:

<disk type='file' device='cdrom'>
      <source file='MY_ISO'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
</disk>

Revision history for this message
Jean Daniel Browne (jeandaniel.browne) wrote :

I can confirm the attach-device command does not work. When attaching a file as a disk to the guest when the guest is active, virsh answers an error message 'cannot be hotplugged'. When attaching a file when thee guest is inactive, virsh answers 'cannot attach device on inactive domain'.

Here is how to reproduce the manipulation

~$ dd if=/dev/zero of=toto bs=1k count=1000

~$ cat titi
<disk type='file'><source file='/home/j/toto'/> <target dev='hdc'/> </disk>

~$ sudo virsh
virsh # attach-device winxp titi
error: Failed to attach device from titi
error: this function is not supported by the hypervisor: disk bus 'ide' cannot be hotplugged.

virsh # destroy winxp
Domain winxp destroyed

virsh # attach-device winxp titi
error: Failed to attach device from titi
error: internal error cannot attach device on inactive domain

On a fresh jaunty alpha6, libvirt-bin package version is 0.6.1-0ubuntu3,

~$ virsh version
Connecting to uri: qemu:///system
Compiled against library: libvir 0.6.1
Using library: libvir 0.6.1
Using API: QEMU 0.6.1

Revision history for this message
Theodotos Andreou (theodotos) wrote :

I run this command:

root@vhost# virsh attach-disk vm.linux.dom boot.iso hdc
Connecting to uri: qemu:///system
libvir: QEMU error : this function is not supported by the hypervisor: only CDROM disk devices can be attached

I am not sure if the syntax is correct. The VM was stopped when I attempted this

Revision history for this message
Alvin (alvind) wrote :

Looks like this one is fixed in Karmic (still, backports for a stable version would be nice)
Tested, using libvirt-bin 0.7.0-1ubuntu3
I can't find a related note in the changelog. Maybe this is a bug in another package?

With running virtual guest 'systools':

alvin@virthost02:~$ virsh attach-disk systools /srv/iso/Windows2003-R2-en-sp2.iso hdc --mode readonly --driver file --type cdrom
Connecting to uri: qemu:///system
Disk attached successfully

Revision history for this message
Jamin W. Collins (jcollins) wrote :

I found using a device xml file works in Jaunty with 0.7.0-0ubuntu0~ppa2, haven't tried older version, but it may work with them as well. I could not get the attach or detach -disk options to work. However using the device xml seems to work. I've attached the xml file I use to attach my system's physical CD-ROM to the VM. Detaching is (oddly enough) accomplished by attaching an empty device. I'll upload the no-cdrom.xml after this.

virsh attach-device winxp ~/cdrom.xml

Revision history for this message
Jamin W. Collins (jcollins) wrote :
Changed in libvirt (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Niels Huylebroeck (red15) wrote :

Backport would be nice, searched a bit around possible fix from upstream is in :

commit 426f9772b84752b4901b72fd382ff6e28e258efd
Author: Daniel P. Berrange <email address hidden>
Date: Mon May 11 15:14:24 2009 +0000
Description: Fix QEMU ARGV detection with kvm >= 85

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Per comment #9, this bug should be marked fix-released. Should be fixed in Lucid. Please re-open if you can reproduce it there.

Changed in libvirt (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers