Hi! We're struggling to get device detaching to work reliably using Xen. We can reliably use the same code to manage devices using Libvirt+KVM without any problems. We've tested this on Xen with both CD-ROM and USB devices without success. See below for detailed descriptions. Thankful for any help! Regards, Daniel Espling --- For CD-ROM, we can mount them using attach-device but cannot remove them using the correspoding call to detach-device: cdrom7.xml contains: <disk type='file' device='cdrom'> <driver name='file' type='raw'/> <source file='/opt/diskimages/test7.iso'/> <target dev='hdc' bus='ide'/> <readonly/> </disk> eject.xml contains: <disk type='block' device='cdrom'> <driver name='file'/> <target dev='hdc' bus='ide'/> <readonly/> </disk> cdrom8.xml is identical to cdrom7.xml apart from the .iso file used. # virsh attach-device deb cdrom7.xml Device attached successfully # virsh detach-device deb cdrom7.xml error: no such device in deb # virsh attach-device deb eject.xml error: Failed to attach device from eject.xml error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected') # virsh update-device deb cdrom8.xml --persistent error: Failed to update device from cdrom8.xml error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected') dumpxml shows the cdrom device attached exactly as it's defined in the xml. Using virsh we're able to use "virsh detach-disk deb hdc" to unmount the CD-ROM, but we need to be able to do this using the python API. We cannot find a corresponding call to detach-disk and we therefore have to rely on detach-device instead, right? Are there any flags we can use for detachDeviceFlags() to replicate the functionality of detach-disk? ---- Similarly for USB devices, we can mount them OK but not remove them using the corresponding call to detach-device. Calling detach-disk works, but again we need to find the corresponding call for this function using the python API. One thing we've found with mounting USB devices is that they seem to be mounted on the SCSI bus instead of the USB one as specified: Example: usb7.xml contains: <disk type='file' device='disk'> <driver name='file' type='raw'/> <source file='/opt/diskimages/test7.iso'/> <target dev='sda' bus='usb'/> <readonly/> </disk> dumpxml shows: <disk type='file' device='disk'> <driver name='file'/> <source file='/opt/diskimages/test7.iso'/> <target dev='sda' bus='scsi'/> <readonly/> </disk> # virsh attach-device deb usb7.xml Device attached successfully Test attaching again (expected to fail): # virsh attach-device deb usb7.xml error: Failed to attach device from usb7.xml error: Requested operation is not valid: target 'sda' already exists `-testgrid7.leeds.ac.uk /opt/recontext # virsh detach-device deb usb7.xml error: no such device in deb ---- Relevant info: Compiled against library: libvir 0.9.9 Using library: libvir 0.9.9 Using API: Xen 0.9.9 Running hypervisor: Xen 4.0.0 Running CentOS 5.5 (final) Linux 2.6.32.24 #3 SMP Fri Oct 29 16:22:02 BST 2010 x86_64 x86_64 x86_64 GNU/Linux -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120210/8f453908/attachment.htm>
One detail; the code we used in KVM had a driver name='qemu', and running that code right away gives the error message; # virsh attach-device deb cdrom7.xml 1 error: Failed to attach device from cdrom7.xml error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Block device type "qemu" is invalid.') //Daniel On Feb 10, 2012, at 11:24 AM, Daniel Espling wrote:> Hi! > > We're struggling to get device detaching to work reliably using Xen. We can reliably use the same code to manage devices using Libvirt+KVM without any problems. We've tested this on Xen with both CD-ROM and USB devices without success. See below for detailed descriptions. > > Thankful for any help! > > Regards, > Daniel Espling > > --- > > For CD-ROM, we can mount them using attach-device but cannot remove them using the correspoding call to detach-device: > > cdrom7.xml contains: > <disk type='file' device='cdrom'> > <driver name='file' type='raw'/> > <source file='/opt/diskimages/test7.iso'/> > <target dev='hdc' bus='ide'/> > <readonly/> > </disk> > > eject.xml contains: > <disk type='block' device='cdrom'> > <driver name='file'/> > <target dev='hdc' bus='ide'/> > <readonly/> > </disk> > > cdrom8.xml is identical to cdrom7.xml apart from the .iso file used. > > # virsh attach-device deb cdrom7.xml > Device attached successfully > > # virsh detach-device deb cdrom7.xml > error: no such device in deb > > # virsh attach-device deb eject.xml > error: Failed to attach device from eject.xml > error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected') > > # virsh update-device deb cdrom8.xml --persistent > error: Failed to update device from cdrom8.xml > error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected') > > dumpxml shows the cdrom device attached exactly as it's defined in the xml. > > Using virsh we're able to use "virsh detach-disk deb hdc" to unmount the CD-ROM, but we need to be able to do this using the python API. We cannot find a corresponding call to detach-disk and we therefore have to rely on detach-device instead, right? Are there any flags we can use for detachDeviceFlags() to replicate the functionality of detach-disk? > > ---- > > Similarly for USB devices, we can mount them OK but not remove them using the corresponding call to detach-device. Calling detach-disk works, but again we need to find the corresponding call for this function using the python API. One thing we've found with mounting USB devices is that they seem to be mounted on the SCSI bus instead of the USB one as specified: > > Example: > > usb7.xml contains: > <disk type='file' device='disk'> > <driver name='file' type='raw'/> > <source file='/opt/diskimages/test7.iso'/> > <target dev='sda' bus='usb'/> > <readonly/> > </disk> > > dumpxml shows: > <disk type='file' device='disk'> > <driver name='file'/> > <source file='/opt/diskimages/test7.iso'/> > <target dev='sda' bus='scsi'/> > <readonly/> > </disk> > > # virsh attach-device deb usb7.xml > Device attached successfully > > Test attaching again (expected to fail): > # virsh attach-device deb usb7.xml > error: Failed to attach device from usb7.xml > error: Requested operation is not valid: target 'sda' already exists > > `-testgrid7.leeds.ac.uk /opt/recontext # virsh detach-device deb usb7.xml > error: no such device in deb > > ---- > > Relevant info: > > Compiled against library: libvir 0.9.9 > Using library: libvir 0.9.9 > Using API: Xen 0.9.9 > Running hypervisor: Xen 4.0.0 > > Running CentOS 5.5 (final) > Linux 2.6.32.24 #3 SMP Fri Oct 29 16:22:02 BST 2010 x86_64 x86_64 x86_64 GNU/Linux > _______________________________________________ > libvirt-users mailing list > libvirt-users at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120210/a4f9a1b4/attachment.htm>
On 02/10/2012 03:24 AM, Daniel Espling wrote:> Hi! > > We're struggling to get device detaching to work reliably using Xen.I haven't personally tried it under xen, so there may indeed be some lurking bugs.> > # virsh attach-device deb cdrom7.xml > Device attached successfully > > # virsh detach-device deb cdrom7.xml > error: no such device in debThe detach code is picky - you will have the best results if the XML you detach matches exactly what 'virsh dumpxml deb' says for the device, which might be slightly different than what you originally attached (such as the addition of an <address> element stating how the guest sees the device).> > # virsh attach-device deb eject.xml > error: Failed to attach device from eject.xml > error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected') > > # virsh update-device deb cdrom8.xml --persistent > error: Failed to update device from cdrom8.xml > error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected') > > dumpxml shows the cdrom device attached exactly as it's defined in the xml.But it looks like you already tried that. Have you also tried 'virsh update-device'? The act of removing a media from a CD-ROM is _not_ detaching the CD-ROM device altogether, but updating it to have no media.> > Using virsh we're able to use "virsh detach-disk deb hdc" to unmount the CD-ROM, but we need to be able to do this using the python API. We cannot find a corresponding call to detach-disk and we therefore have to rely on detach-device instead, right? Are there any flags we can use for detachDeviceFlags() to replicate the functionality of detach-disk?'virsh detach-disk' is just syntactic sugar around virDomainDetachDevice; which is the same API being used by 'virsh detach-device' but with more convenient command line arguments. So since there is only one API called by both virsh commands, it would be the same API that you target through the python bindings if you are trying to do it in python.> Relevant info: > > Compiled against library: libvir 0.9.9 > Using library: libvir 0.9.9 > Using API: Xen 0.9.9 > Running hypervisor: Xen 4.0.0 > > Running CentOS 5.5 (final)CentOS 5 doesn't ship with that new of a libvirt out-of-the-box, so since you are already building from source, you might have to invest some time in the source code to see if the xen drivers in libvirt have a bug in this area. Sorry I'm not able to help more. -- Eric Blake eblake at redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 620 bytes Desc: OpenPGP digital signature URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120213/bb6e50ed/attachment.sig>