On Tue, Apr 19, 2016 at 02:34:30PM +0100, Daniel P. Berrange wrote: > Have you ever considered integration with the QEMU NBD server. We > don't have APIs for enabling it explicitly in libvirt, but it strikes > me that it could be ideally suited for your needs. > > eg a hypothetical libvirt command to export a disk via NBD: > > virsh dom-export-disk myguest --readonly vda1 localhost 9000 > qemu-img create -f qcow2 -b nbd:localhost:9000 tmp-overlay.img > ...do stuff... > virsh dom-unexport-disk myguest vda1 > > Or to make cleanup easier, perhaps there's a way to tell QEMU > to close its NBD server after it has had 1 client connection. > > With this approach, you wouldn't need to take any lock on the > underlying real image.
It's been on my todo list for a long time, but this does require libvirt to be involved, and libvirt is not the default for upstream libguestfs. Even with the libvirt backend, there are still uses cases like: virt-df -a /mnt/vms/disk.img -h virt-inspector -a /mnt/vms/disk.img | grep some_insecure_software for f in /mnt/vms/*; do virt-alignment-scan -a $f; done and so on. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org