[libvirt-users] virsh uses internally qemu-img ?

Kashyap Chamarthy kchamart at redhat.com
Mon Nov 30 12:50:47 UTC 2015


On Mon, Nov 30, 2015 at 01:57:24AM +0100, Lentes, Bernd wrote:
> Hi,
> 
> i read that virsh uses internally qemu-img
> (http://serverfault.com/questions/692435/qemu-img-snapshot-on-live-vm).
> Is that true ? so snapshotting a running vm with virsh or qemu-img is
> the same ?

Functionally, it is the same.

However:

Snapshotting of guests using `virsh` will let libvirt track the
life-cycle of the snapshot and management/revert/clean-up of snapshots
is easier.

The `qemu-img` command:

    $ qemu-img snapshot -c snap1 f23vm.qcow2

    [And, to your question: "Will the above command harm the running VMs
    filesystem ?", it depends on what is running inside your guest.  To
    ensure you have a consistent guest disk state, use the
    qemu-guest-agent inside the guest, and supply the '--quiesce' flag
    to `virsh-snapshot-create-as` command. See [1]

Maps to `virsh`:

    $ virsh snapshot-create-as f23vm snap1 "Clean F23"

This results in:

    - The original and the delta (the snaphot) will be stored in the
      same qcow2 file (f23vm.qcow2).  These type of snapshots are called
      'internal snapshots'  -- these are possible only with qcow2
      format.

    - The guest _will_ be paused briefly.
    
    - Libvirt tracking the snapshot status of the guest.

If you want to have snapshots without any guest downtime, you can use
the more robust 'external snapshots', which operates differently: when a
snapshot is taken, a _new_ qcow2 file is created, which will track the
new guest writes from there on.  And, the old image will become
read-only backing file.  Some more context on it here[2].

These type of snapshots can be performed using the 'qemu-kvm-ev'
packages, which you can obtain from the oVirt repositories

    http://resources.ovirt.org/pub/ovirt-master-snapshot/rpm/el7/x86_64/

Or from the CentOS build system:

    http://cbs.centos.org/koji/packageinfo?packageID=539

Ideally these should be available in a repository, but I can't find one
at the moment.


[1] http://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit
[2] http://wiki.libvirt.org/page/I_created_an_external_snapshot%2C_but_libvirt_won't_let_me_delete_or_revert_to_it

-- 
/kashyap




More information about the libvirt-users mailing list