[libvirt] OS Eject & Removable Media

Greetings all, First, I'd like to thank everyone that's working on the libvirt project, it's certainly making my life a better place. Second, (there's always a second, eh?) I am using libvirtd 0.6.4 and KVM qemu-kvm-0.10.5, and when a guest OS ejects media, libvirtd doesn't seem to pick up the change. Looking through the API, I don't see a provision to probe for a list of block devices, so although qemu and kvm know about media changes, I don't think there's a way for libvirtd to know about them. I've scanned the list archives, and haven't really seen any discussion of this, but I'd be more than happy to be directed somewhere. Also, I have a couple of minor and hackish patches for the ruby bindings for attaching and removing devices, if someone's interested. Sincerely, Jacob Leaver

On Mon, Aug 24, 2009 at 11:21:14AM -0700, Jacob Leaver wrote:
Greetings all,
First, I'd like to thank everyone that's working on the libvirt project, it's certainly making my life a better place.
Second, (there's always a second, eh?) I am using libvirtd 0.6.4 and KVM qemu-kvm-0.10.5, and when a guest OS ejects media, libvirtd doesn't seem to pick up the change.
Looking through the API, I don't see a provision to probe for a list of block devices, so although qemu and kvm know about media changes, I don't think there's a way for libvirtd to know about them.
Yeah, that's pretty much the problem in a nutshell. No notificatons from QEMU The only immediate option i see is to run 'info block' every time we invoke virDomainGetXMLDesc(), in order to check if the CDROM media has been ejected. Mildly disgusting, but probably doable.
Also, I have a couple of minor and hackish patches for the ruby bindings for attaching and removing devices, if someone's interested.
By all means send them to this list & we'll take a look & commit them if reasonable. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Yeah, that's pretty much the problem in a nutshell. No notificatons from QEMU
The only immediate option i see is to run 'info block' every time we invoke virDomainGetXMLDesc(), in order to check if the CDROM media has been ejected. Mildly disgusting, but probably doable.
Thanks for the quick and friendly reply! It's nice to have confirmation. Looking through the code with creating a qemu driver patch (specifically) in mind, it looks like I'd need to create a function, probably similar to info blockstats, that took a dom and a path argument, and returned a file, or if it was specific to this task, took an additional filepath to compare against, and return a true or false. Then I'd want to add some functionality into either DomainXMLFromNative which might be too high-level, or possibly ParseCommandLineDisk in qemu_conf.c (which is ugly from a naming convention perspective, but simpler since all the data is right there.) I'd compare the returned filename with dev->src (in ParseCommandLineDisk) and change the src to null if there's no mounted media. I'm not so great at c coding, but I think I can hack something out if this sounds reasonable so far. Thanks, Jacob Leaver
participants (2)
-
Daniel P. Berrange
-
Jacob Leaver