[libvirt-users] Rollback to running VM

I would like to make a snapshot of a running VM, let it continue to run after the shapshot, and then at some later time roll back the VM to that previous running state. Can I do that with libvirt? If so, how? I understand that this will cause all kinds of havoc with things like ongoing TCP connections, and I accept that risk. -- Gary Jackson

On Tue, Sep 19, 2017 at 01:28:45PM +0000, Jackson, Gary L. wrote:
I would like to make a snapshot of a running VM, let it continue to run after the shapshot, and then at some later time roll back the VM to that previous running state. Can I do that with libvirt? If so, how? I understand that this will cause all kinds of havoc with things like ongoing TCP connections, and I accept that risk.
Check `man virsh` and the description to commands `snapshot-create-as` and `snapshot-revert`. If more information is needed, feel free to ask, although if deep knowledge is required I might need to rely on someone else to reply then. Have a nice day, Martin
-- Gary Jackson
_______________________________________________ libvirt-users mailing list libvirt-users@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-users

On 9/19/2017 9:56 AM, Martin Kletzander wrote:
On Tue, Sep 19, 2017 at 01:28:45PM +0000, Jackson, Gary L. wrote:
I would like to make a snapshot of a running VM, let it continue to run after the shapshot, and then at some later time roll back the VM to that previous running state. Can I do that with libvirt? If so, how? I understand that this will cause all kinds of havoc with things like ongoing TCP connections, and I accept that risk.
Check `man virsh` and the description to commands `snapshot-create-as` and `snapshot-revert`. If more information is needed, feel free to ask, although if deep knowledge is required I might need to rely on someone else to reply then.
agreed. This is definitely achievable with snapshot-create-as. You'll prefer to shutdown the VM to make it work, but it can be done live using the --running flag. I've never tried this. The man page isnt entirely clear but it seems like it will effectively reboot to the state when the snapshot was taken. Mechanics wise, you take the snapshot. Now you have a new disk image file (usually with -snap, but you can name it whatever using snapshot-as), that will be recording the changes that are happening to the OS. The old image at the time of the snapshot is still there under the original name. If you look in the xml file, you'll see it has changed the path of the disk image to the new snapshot file. The new snapshot is a 'sparse copy' in that is recording all of the new changes happening, but it has a reference pointer pointing back to the original image for things that have not changed. At any point, you can shut down your VM and boot off the original image, which discards all of the changes. Or you can decide that you want to 'blockcommit' all of the changes back to the original image which you can do online without impact. (I use this with ZFS replication to provide rollback capability per VM image to another host in case of host failure)

Will snapshot-revert restore the processor and memory state of the VM as it was at the time of the snapshot? -- Gary Jackson On 9/19/17, 11:10 AM, "libvirt-users-bounces@redhat.com on behalf of Doug Hughes" <libvirt-users-bounces@redhat.com on behalf of doug.hughes@keystonenap.com> wrote: On 9/19/2017 9:56 AM, Martin Kletzander wrote: > On Tue, Sep 19, 2017 at 01:28:45PM +0000, Jackson, Gary L. wrote: >> >> I would like to make a snapshot of a running VM, let it continue to run >> after the shapshot, and then at some later time roll back the VM to >> that previous running state. Can I do that with libvirt? If so, how? I >> understand that this will cause all kinds of havoc with things like >> ongoing TCP connections, and I accept that risk. >> > > Check `man virsh` and the description to commands `snapshot-create-as` > and `snapshot-revert`. If more information is needed, feel free to ask, > although if deep knowledge is required I might need to rely on someone > else to reply then. agreed. This is definitely achievable with snapshot-create-as. You'll prefer to shutdown the VM to make it work, but it can be done live using the --running flag. I've never tried this. The man page isnt entirely clear but it seems like it will effectively reboot to the state when the snapshot was taken. Mechanics wise, you take the snapshot. Now you have a new disk image file (usually with -snap, but you can name it whatever using snapshot-as), that will be recording the changes that are happening to the OS. The old image at the time of the snapshot is still there under the original name. If you look in the xml file, you'll see it has changed the path of the disk image to the new snapshot file. The new snapshot is a 'sparse copy' in that is recording all of the new changes happening, but it has a reference pointer pointing back to the original image for things that have not changed. At any point, you can shut down your VM and boot off the original image, which discards all of the changes. Or you can decide that you want to 'blockcommit' all of the changes back to the original image which you can do online without impact. (I use this with ZFS replication to provide rollback capability per VM image to another host in case of host failure)

According to this page: https://wiki.libvirt.org/page/Snapshots It saves complete memory state, or crash-consistent disk state, but not both. You probably want to test it thoroughly and see how it does. I only use the disk-consistent snapshots. On 9/19/2017 11:17 AM, Jackson, Gary L. wrote:
Will snapshot-revert restore the processor and memory state of the VM as it was at the time of the snapshot?
-- Doug Hughes Keystone NAP Fairless Hills, PA 1.844.KEYBLOCK (539.2562)

Thanks! The vanilla snapshot-create-as and revert commands work just exactly the way I’d want them to. I’d gotten a bit confused by the documentation and went down a rabbit hole with external snapshots. Is there any way to make the snapshot and restore faster, like maybe by a decimal order of magnitude? For example, will PXE booting the VM and running it entirely off of a RAM disk and also using a RAM disk for the backing store help? -- Gary Jackson From: Doug Hughes <doug.hughes@keystonenap.com> Date: Tuesday, September 19, 2017 at 11:25 AM To: "Jackson, Gary L." <Gary.Jackson@jhuapl.edu>, "libvirt-users@redhat.com" <libvirt-users@redhat.com> Subject: Re: [libvirt-users] Rollback to running VM According to this page: https://wiki.libvirt.org/page/Snapshots It saves complete memory state, or crash-consistent disk state, but not both. You probably want to test it thoroughly and see how it does. I only use the disk-consistent snapshots. On 9/19/2017 11:17 AM, Jackson, Gary L. wrote: Will snapshot-revert restore the processor and memory state of the VM as it was at the time of the snapshot? -- Doug Hughes Keystone NAP Fairless Hills, PA 1.844.KEYBLOCK (539.2562) [cid:image001.png@01D33146.522ABA40]

I would estimate you are bounded by memory bandwidth (GB/sec - so not much, but proportional to memory size) and disk bandwidth. So, using SSD will help for certain vs spinning. I'm not sure about the catch-22 implicit with using a ramdisk, but since the ramdisk should be previsioned from the host to the guest, it seems like it should work. There may be other bottlenecks in drivers, etc. Not in my knowledge domain. On 9/19/2017 12:53 PM, Jackson, Gary L. wrote:
Thanks! The vanilla snapshot-create-as and revert commands work just exactly the way I’d want them to. I’d gotten a bit confused by the documentation and went down a rabbit hole with external snapshots.
Is there any way to make the snapshot and restore faster, like maybe by a decimal order of magnitude? For example, will PXE booting the VM and running it entirely off of a RAM disk and also using a RAM disk for the backing store help?
--
Gary Jackson
*From: *Doug Hughes <doug.hughes@keystonenap.com> *Date: *Tuesday, September 19, 2017 at 11:25 AM *To: *"Jackson, Gary L." <Gary.Jackson@jhuapl.edu>, "libvirt-users@redhat.com" <libvirt-users@redhat.com> *Subject: *Re: [libvirt-users] Rollback to running VM
According to this page: https://wiki.libvirt.org/page/Snapshots <https://wiki.libvirt.org/page/Snapshots> It saves complete memory state, or crash-consistent disk state, but not both.
You probably want to test it thoroughly and see how it does. I only use the disk-consistent snapshots.
On 9/19/2017 11:17 AM, Jackson, Gary L. wrote:
Will snapshot-revert restore the processor and memory state of the VM as it was at the time of the snapshot?
--
Doug Hughes Keystone NAP Fairless Hills, PA 1.844.KEYBLOCK (539.2562)
-- Doug Hughes Keystone NAP Fairless Hills, PA 1.844.KEYBLOCK (539.2562)

Putting the image on tmpfs cut the snapshot time down by quite a bit. It didn’t do much for the restore time, probably because the images I’m using fit in the file cache already. Now I’m going to look in to profiling qemu to see where it’s spending all of its time. -- Gary Jackson From: Doug Hughes <doug.hughes@keystonenap.com> Date: Tuesday, September 19, 2017 at 12:59 PM To: "Jackson, Gary L." <Gary.Jackson@jhuapl.edu>, "libvirt-users@redhat.com" <libvirt-users@redhat.com> Subject: Re: [libvirt-users] Rollback to running VM I would estimate you are bounded by memory bandwidth (GB/sec - so not much, but proportional to memory size) and disk bandwidth. So, using SSD will help for certain vs spinning. I'm not sure about the catch-22 implicit with using a ramdisk, but since the ramdisk should be previsioned from the host to the guest, it seems like it should work. There may be other bottlenecks in drivers, etc. Not in my knowledge domain. On 9/19/2017 12:53 PM, Jackson, Gary L. wrote: Thanks! The vanilla snapshot-create-as and revert commands work just exactly the way I’d want them to. I’d gotten a bit confused by the documentation and went down a rabbit hole with external snapshots. Is there any way to make the snapshot and restore faster, like maybe by a decimal order of magnitude? For example, will PXE booting the VM and running it entirely off of a RAM disk and also using a RAM disk for the backing store help? -- Gary Jackson From: Doug Hughes <doug.hughes@keystonenap.com><mailto:doug.hughes@keystonenap.com> Date: Tuesday, September 19, 2017 at 11:25 AM To: "Jackson, Gary L." <Gary.Jackson@jhuapl.edu><mailto:Gary.Jackson@jhuapl.edu>, "libvirt-users@redhat.com"<mailto:libvirt-users@redhat.com> <libvirt-users@redhat.com><mailto:libvirt-users@redhat.com> Subject: Re: [libvirt-users] Rollback to running VM According to this page: https://wiki.libvirt.org/page/Snapshots It saves complete memory state, or crash-consistent disk state, but not both. You probably want to test it thoroughly and see how it does. I only use the disk-consistent snapshots. On 9/19/2017 11:17 AM, Jackson, Gary L. wrote: Will snapshot-revert restore the processor and memory state of the VM as it was at the time of the snapshot? -- Doug Hughes Keystone NAP Fairless Hills, PA 1.844.KEYBLOCK (539.2562) [cid:image001.png@01D33386.90476A70] -- Doug Hughes Keystone NAP Fairless Hills, PA 1.844.KEYBLOCK (539.2562) [cid:image002.png@01D33386.90476A70]
participants (3)
-
Doug Hughes
-
Jackson, Gary L.
-
Martin Kletzander