[Libguestfs] Concurrent scanning of same disk

Daniel P. Berrange berrange at redhat.com
Thu May 28 11:10:27 UTC 2015


On Wed, May 27, 2015 at 09:38:38AM +0300, NoxDaFox wrote:
> Greetings,
> 
> I am suffering of several weird errors which show randomly and make me
> suspect some concurrency issue.
> 
> Libguestfs version is 1.28.1, linux kernel 3.16, libvirt 1.2.9 and qemu 2.1.
> 
> What I'm trying to do is comparing the disk state at two different point of
> a guest execution.
> Disk snapshots are taken through libvirt in different moments (I am aware
> of caching issue), from such snapshots, new disks are created using the
> "qemu-img convert" command with backing file pointing to the disk being
> executed.

Am I right in understanding that the guest VM is /running/ while you
invoke 'qemu-img convert' ?

If so, that is bad practice - it is not supported to invoke qemu-img
against /any/ disk image that is currently open by a running QEMU
process. You /might/ get away with it if the disk image is raw, since
you'll (usually) just end up with a dirty guest filesystem that can
be recovered by replaying the journal. With qcow2 though it is worse
because QEMU may have in-memory changes to the qcow2 sector allocation
tables which are in-flight and so qemu-img can end up with inconsistent
data.

You really need to use the libvirt live snapshot APIs/tools to take
copies of disks attached to running VMs. This further gives the option
to quiesce the guest, if consistency of guest OS data is desired too.
There are quite a few ways to use the libvirt APIs, but one example
is shown here

  http://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the Libguestfs mailing list