[libvirt] libvirt external disk-only snapshot will pause the VM?

Hello folks, If I give command to take external disk-only live snapshot, such as # virsh snapshot-create-as vm1 snapshot_vm1 --disk-only will the guest OS be paused or suspend while the snapshot being taken? Thanks very much! Best, Yuanzhen

On 08/05/2014 03:54 PM, Yuanzhen Gu wrote:
Hello folks,
If I give command to take external disk-only live snapshot, such as # virsh snapshot-create-as vm1 snapshot_vm1 --disk-only
will the guest OS be paused or suspend while the snapshot being taken?
The guest will temporarily pause, but the time that it remains paused will be a fraction of a second. In practice, it is no longer than the time that the guest is paused when doing live migration. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Thanks very much Eric! This is exactly what I guessed, I just wondering where I could find this piece of code and control the the pause time of guest, while the snapshot being taken? thanks ! Best, Yuanzhen On Tue, Aug 5, 2014 at 6:30 PM, Eric Blake <eblake@redhat.com> wrote:
On 08/05/2014 03:54 PM, Yuanzhen Gu wrote:
Hello folks,
If I give command to take external disk-only live snapshot, such as # virsh snapshot-create-as vm1 snapshot_vm1 --disk-only
will the guest OS be paused or suspend while the snapshot being taken?
The guest will temporarily pause, but the time that it remains paused will be a fraction of a second. In practice, it is no longer than the time that the guest is paused when doing live migration.
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/06/2014 08:36 AM, Yuanzhen Gu wrote: [please don't top-post on technical lists]
Thanks very much Eric! This is exactly what I guessed, I just wondering where I could find this piece of code and control the the pause time of guest, while the snapshot being taken? thanks !
Actually, for new enough qemu (one with the 'transaction' QMP command), or for a guest where only one disk is being snapshotted, there is no pause required. See qemuDomainSnapshotCreateDiskActiveExternal in src/qemu/qemu_driver.c. When a pause is required, it is only for the fraction of a second required to issue a followup qemu QMP command to resume the guest, so there is no need for a knob to control the pause time (it is as already as fast as possible). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

yes, I got your point, thanks very much Eric. If I want to take a distributed snapshot, which need pause all the VMs and then take snapshot, how can I control the pause for all the VMs? Is there only way that I turn to freeze/thaw functions? and freeze/thaw only for file systems, not for the whole guest, am I right? Thanks a lot! Best, Yuanzhen On Wed, Aug 6, 2014 at 11:35 AM, Eric Blake <eblake@redhat.com> wrote:
On 08/06/2014 08:36 AM, Yuanzhen Gu wrote:
[please don't top-post on technical lists]
Thanks very much Eric! This is exactly what I guessed, I just wondering where I could find this piece of code and control the the pause time of guest, while the snapshot being taken? thanks !
Actually, for new enough qemu (one with the 'transaction' QMP command), or for a guest where only one disk is being snapshotted, there is no pause required. See qemuDomainSnapshotCreateDiskActiveExternal in src/qemu/qemu_driver.c. When a pause is required, it is only for the fraction of a second required to issue a followup qemu QMP command to resume the guest, so there is no need for a knob to control the pause time (it is as already as fast as possible).
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/06/2014 10:06 AM, Yuanzhen Gu wrote:
yes, I got your point, thanks very much Eric.
not entirely, because you still top-posted.
If I want to take a distributed snapshot, which need pause all the VMs and then take snapshot, how can I control the pause for all the VMs?
You mean, you have multiple VMs, and want to take a snapshot of all their storage at the same point in time? Then it is up to you to manually pause all the guests before taking the snapshot in each of them. Taking an external disk snapshot works while a guest is paused.
Is there only way that I turn to freeze/thaw functions?
Guest freeze/thaw (virDomainFSFreeze) only works on a live guest. So what you will have to do is: virDomainFSFreeze(vm1, ...) virDomainFSFreeze(vm2, ...) virDomainSuspend(vm1) virDomainSuspend(vm2) virDomainSnapshotCreateXML(vm1, ...) virDomainSnapshotCreateXML(vm2, ...) virDomainResume(vm1) virDomainResume(vm2) virDomainFSThaw(vm1, ...) virDOmainFSThaw(vm2, ...) However, I honestly don't know why you think you need disk snapshots from the same point in time across multiple VMs, though. Compare it to bare metal - how would you take a snapshot of multiple hosts? Either they are independent storage (and it doesn't matter if they are not precisely at the same point in time), or they are using clustered storage visible by all hosts in the cluster (but in that case, use your cluster storage management tools to take the snapshot, rather than trying to take a point-in-time snapshot of the low-level storage on each host and coordinating all the hosts to do it at the same point in time).
and freeze/thaw only for file systems, not for the whole guest, am I right?
freeze/thaw is for all freezeable file systems on the whole guest, but it requires guest cooperation. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Aug 6, 2014 at 12:27 PM, Eric Blake <eblake@redhat.com> wrote:
On 08/06/2014 10:06 AM, Yuanzhen Gu wrote:
yes, I got your point, thanks very much Eric.
not entirely, because you still top-posted.
got it entirely this time, not top-posted.
If I want to take a distributed snapshot, which need pause all the VMs
and
then take snapshot, how can I control the pause for all the VMs?
You mean, you have multiple VMs, and want to take a snapshot of all their storage at the same point in time? Then it is up to you to manually pause all the guests before taking the snapshot in each of them. Taking an external disk snapshot works while a guest is paused.
I need take live snapshot for multiple VMs at the same time
Is there only way that I turn to freeze/thaw functions?
Guest freeze/thaw (virDomainFSFreeze) only works on a live guest. So what you will have to do is:
virDomainFSFreeze(vm1, ...) virDomainFSFreeze(vm2, ...) virDomainSuspend(vm1) virDomainSuspend(vm2) virDomainSnapshotCreateXML(vm1, ...) virDomainSnapshotCreateXML(vm2, ...) virDomainResume(vm1) virDomainResume(vm2) virDomainFSThaw(vm1, ...) virDOmainFSThaw(vm2, ...)
I see, thanks.
However, I honestly don't know why you think you need disk snapshots from the same point in time across multiple VMs, though.
you suggested that external disk-only snapshot, libvirt will freeze/thaw before/after taking snapshot
Compare it to bare metal - how would you take a snapshot of multiple hosts? Either they are independent storage (and it doesn't matter if they are not precisely at the same point in time), or they are using clustered storage visible by all hosts in the cluster (but in that case, use your cluster storage management tools to take the snapshot, rather than trying to take a point-in-time snapshot of the low-level storage on each host and coordinating all the hosts to do it at the same point in time).
good question. I'll think about it clear my mind first and then answer it, thanks!
and freeze/thaw only for file systems, not for the whole guest, am I
right?
freeze/thaw is for all freezeable file systems on the whole guest, but it requires guest cooperation.
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/06/2014 11:17 AM, Yuanzhen Gu wrote:
Guest freeze/thaw (virDomainFSFreeze) only works on a live guest. So what you will have to do is:
virDomainFSFreeze(vm1, ...) virDomainFSFreeze(vm2, ...) virDomainSuspend(vm1) virDomainSuspend(vm2) virDomainSnapshotCreateXML(vm1, ...) virDomainSnapshotCreateXML(vm2, ...) virDomainResume(vm1) virDomainResume(vm2) virDomainFSThaw(vm1, ...) virDOmainFSThaw(vm2, ...)
I see, thanks.
However, I honestly don't know why you think you need disk snapshots from the same point in time across multiple VMs, though.
you suggested that external disk-only snapshot, libvirt will freeze/thaw before/after taking snapshot
For a single guest, yes, libvirt can handle both the freeze/thaw and any necessary pause/resume of the guest automatically. But as soon as you are coordinating multiple guests, it is up to you do to the coordination. Libvirt handles the case of taking a snapshot when the guest is already frozen and paused, but the burden of doing the three steps in parallel across VMs is now up to you instead of all three steps in a single API call for one VM. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Aug 6, 2014 at 1:23 PM, Eric Blake <eblake@redhat.com> wrote:
On 08/06/2014 11:17 AM, Yuanzhen Gu wrote:
Guest freeze/thaw (virDomainFSFreeze) only works on a live guest. So what you will have to do is:
virDomainFSFreeze(vm1, ...) virDomainFSFreeze(vm2, ...) virDomainSuspend(vm1) virDomainSuspend(vm2) virDomainSnapshotCreateXML(vm1, ...) virDomainSnapshotCreateXML(vm2, ...) virDomainResume(vm1) virDomainResume(vm2) virDomainFSThaw(vm1, ...) virDOmainFSThaw(vm2, ...)
I see, thanks.
However, I honestly don't know why you think you need disk snapshots from the same point in time across multiple VMs, though.
you suggested that external disk-only snapshot, libvirt will freeze/thaw before/after taking snapshot
For a single guest, yes, libvirt can handle both the freeze/thaw and any necessary pause/resume of the guest automatically. But as soon as you are coordinating multiple guests, it is up to you do to the coordination. Libvirt handles the case of taking a snapshot when the guest is already frozen and paused, but the burden of doing the three steps in parallel across VMs is now up to you instead of all three steps in a single API call for one VM.
I see, thanks Eric.
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Yuanzhen Gu