On Feb 13, 2012, at 10:27 PM, Eric Blake wrote: > 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 deb > > The 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. Yeah, tried both update-device and normal attach-detach routines to no avail. > >> >> 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. Yeah that's correct, we have compiled that libvirt version ourselves. We've been looking at the source but haven't been able to see any obvious errors, but we have noticed that the force flag is not properly propagated from the python API to Xen (although it doesn't affect the naming problem). However, we're only going for a proof of concept implementation at this point and won't spend more time looking into this at the moment (we can circumvent the problems by calling xm instead of using the libvirt API). Thanks for your response and advice in any case. Regards, Daniel > > -- > Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 > Libvirt virtualization library http://libvirt.org >