Discussion:
[fedora-virt] How to revert an external snapshot
Dario Lesca
2015-03-04 14:16:32 UTC
Permalink
vm='win7-64'
virsh snapshot-create-as "$vm" "$vm-snap1" "snap1 description" \
--diskspec vda,file="/virt/$vm-snap1.qcow2" \
--disk-only --atomic
My virsh / libvirt is the last from Fedora 21
1.2.9.2
-rw-r--r-- 1 qemu qemu 17182753280 4 mar 14.14 win7-64.qcow2
-rw-r--r-- 1 root root 558628864 4 mar 14.35 win7-64-snap1.qcow2
Nome Creation Time Stato
------------------------------------------------------------
win7-64-snap1 2015-03-04 14:21:15 +0100 shutoff
errore: unsupported configuration: revert to external snapshot not supported yet
There is some way to revert my vm to previous state?

Many thanks for help.
--
Dario Lesca
(inviato dal mio Linux Fedora 21 con Gnome 3.14)
Cole Robinson
2015-03-04 14:49:09 UTC
Permalink
Post by Dario Lesca
vm='win7-64'
virsh snapshot-create-as "$vm" "$vm-snap1" "snap1 description" \
--diskspec vda,file="/virt/$vm-snap1.qcow2" \
--disk-only --atomic
My virsh / libvirt is the last from Fedora 21
1.2.9.2
-rw-r--r-- 1 qemu qemu 17182753280 4 mar 14.14 win7-64.qcow2
-rw-r--r-- 1 root root 558628864 4 mar 14.35 win7-64-snap1.qcow2
Nome Creation Time Stato
------------------------------------------------------------
win7-64-snap1 2015-03-04 14:21:15 +0100 shutoff
errore: unsupported configuration: revert to external snapshot not supported yet
There is some way to revert my vm to previous state?
Many thanks for help.
You can do it by hand: Power off the VM, edit the XML to point at the desired
disk image.

However, if you point at the root file and make disk changes, the snapshot
overlay will then become invalid. So if you want to use the root contents
again, you'll need to create another overlay based on the root image, and
point your VM at that. This confusion is one of the reasons that stuff isn't
implemented in libvirt yet

- Cole
Dario Lesca
2015-03-04 16:43:30 UTC
Permalink
Post by Cole Robinson
Post by Dario Lesca
...
There is some way to revert my vm to previous state?
You can do it by hand: Power off the VM, edit the XML to point at the desired
disk image.
Ok, thanks Cole, I have modify the point at the disk image to original
root disk image:

before "<source file='/virt/win7-64-snap1.qcow2'/>"
after "<source file='/virt/win7-64.qcow2'/>"

Then I have remove the image overlay /virt/win7-64-snap1.qcow2

Now all work fine.
Post by Cole Robinson
However, if you point at the root file and make disk changes, the snapshot
overlay will then become invalid. So if you want to use the root contents
again, you'll need to create another overlay based on the root image, and
point your VM at that. This confusion is one of the reasons that stuff isn't
implemented in libvirt yet
Nome Creation Time Stato
------------------------------------------------------------
win7-64-snap1 2015-03-04 14:21:15 +0100 shutoff
So, I have remove the machine and recreate it and the snapshot is gone
away.

Thanks for help.
--
Dario Lesca
(inviato dal mio Linux Fedora 21 con Gnome 3.14)
Cole Robinson
2015-03-04 17:01:53 UTC
Permalink
Post by Dario Lesca
Post by Cole Robinson
Post by Dario Lesca
...
There is some way to revert my vm to previous state?
You can do it by hand: Power off the VM, edit the XML to point at the desired
disk image.
Ok, thanks Cole, I have modify the point at the disk image to original
before "<source file='/virt/win7-64-snap1.qcow2'/>"
after "<source file='/virt/win7-64.qcow2'/>"
Then I have remove the image overlay /virt/win7-64-snap1.qcow2
Now all work fine.
Post by Cole Robinson
However, if you point at the root file and make disk changes, the snapshot
overlay will then become invalid. So if you want to use the root contents
again, you'll need to create another overlay based on the root image, and
point your VM at that. This confusion is one of the reasons that stuff isn't
implemented in libvirt yet
Nome Creation Time Stato
------------------------------------------------------------
win7-64-snap1 2015-03-04 14:21:15 +0100 shutoff
So, I have remove the machine and recreate it and the snapshot is gone
away.
For that last bit, you should be able to do:

sudo virsh snapshot-delete --metadata $snapshot-name

- Cole
Dario Lesca
2015-03-09 08:40:43 UTC
Permalink
Post by Cole Robinson
sudo virsh snapshot-delete --metadata $snapshot-name
Thanks Cole, and thanks also to Kashyap for the useful link.

But, for me, traslate this info into a procedure (shell script) for do
an hot backup/restore of my virtual machine is difficult.

I intend use external snapshot for transfer, without poweroff, a guest
from host to bk-host.

With external snapshot, my idea was to transfer the base image from host
to bk-host and, at the end of copy base image, to remove the snapshot on
host.

It's possible to do that or something like this?
there is already some scripts?

Thanks for your help ... and great work.
--
Dario Lesca
(inviato dal mio Linux Fedora 21 con Gnome 3.14)
Eric Blake
2015-03-09 16:37:55 UTC
Permalink
Post by Dario Lesca
Post by Cole Robinson
sudo virsh snapshot-delete --metadata $snapshot-name
Thanks Cole, and thanks also to Kashyap for the useful link.
But, for me, traslate this info into a procedure (shell script) for do
an hot backup/restore of my virtual machine is difficult.
I intend use external snapshot for transfer, without poweroff, a guest
from host to bk-host.
With external snapshot, my idea was to transfer the base image from host
to bk-host and, at the end of copy base image, to remove the snapshot on
host.
It's possible to do that or something like this?
Yes. It sounds like this will do it:

# Create the external snapshot
virsh snapshot-create $dom --no-metadata --disk-only
# Copy the base image to bk-host, for an appropriate $copy
"$copy" host... bk-host...
# Commit the temporary qcow2 snapshot wrapper back into the main disk
foreach disk in $dom:
virsh blockcommit $dom $disk --active --shallow --verbose --pivot

and now your host is back to executing with the original file as active,
with no notion that a backup was taken in the meantime, and with guest
downtime limited to millisecond or less ranges. The backup image now
stored on bk-host is not consistent (that is, libvirt still needs to add
support for a 'snapshot-create --quiesce' flag); if that matters, you
can use this longer sequence (assuming you have new enough libvirt):

virsh domfsfreeze $dom
virsh snapshot-create $dom --no-metadata --disk-only
virsh domfsthaw $dom
"$copy" host... bk-host...
etc.
Post by Dario Lesca
there is already some scripts?
I don't know if anyone else has tried to script it, but I haven't.
Post by Dario Lesca
Thanks for your help ... and great work.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Kashyap Chamarthy
2015-03-09 17:10:43 UTC
Permalink
Post by Eric Blake
Post by Dario Lesca
Post by Cole Robinson
sudo virsh snapshot-delete --metadata $snapshot-name
Thanks Cole, and thanks also to Kashyap for the useful link.
But, for me, traslate this info into a procedure (shell script) for do
an hot backup/restore of my virtual machine is difficult.
I intend use external snapshot for transfer, without poweroff, a guest
from host to bk-host.
With external snapshot, my idea was to transfer the base image from host
to bk-host and, at the end of copy base image, to remove the snapshot on
host.
It's possible to do that or something like this?
# Create the external snapshot
virsh snapshot-create $dom --no-metadata --disk-only
# Copy the base image to bk-host, for an appropriate $copy
"$copy" host... bk-host...
# Commit the temporary qcow2 snapshot wrapper back into the main disk
virsh blockcommit $dom $disk --active --shallow --verbose --pivot
The above procedure (derived from mailing lists conversation with Eric)
is documented here with a little more commentary:

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

--
/kashyap
Post by Eric Blake
and now your host is back to executing with the original file as active,
with no notion that a backup was taken in the meantime, and with guest
downtime limited to millisecond or less ranges. The backup image now
stored on bk-host is not consistent (that is, libvirt still needs to add
support for a 'snapshot-create --quiesce' flag); if that matters, you
virsh domfsfreeze $dom
virsh snapshot-create $dom --no-metadata --disk-only
virsh domfsthaw $dom
Thanks for the 'domfsthaw' reminder, I forgot about it.
Post by Eric Blake
"$copy" host... bk-host...
etc.
Post by Dario Lesca
there is already some scripts?
I don't know if anyone else has tried to script it, but I haven't.
Kashyap Chamarthy
2015-03-05 09:00:29 UTC
Permalink
Post by Dario Lesca
Post by Cole Robinson
Post by Dario Lesca
...
There is some way to revert my vm to previous state?
You can do it by hand: Power off the VM, edit the XML to point at the desired
disk image.
Ok, thanks Cole, I have modify the point at the disk image to original
before "<source file='/virt/win7-64-snap1.qcow2'/>"
after "<source file='/virt/win7-64.qcow2'/>"
Then I have remove the image overlay /virt/win7-64-snap1.qcow2
Now all work fine.
Post by Cole Robinson
However, if you point at the root file and make disk changes, the snapshot
overlay will then become invalid. So if you want to use the root contents
again, you'll need to create another overlay based on the root image, and
point your VM at that. This confusion is one of the reasons that stuff isn't
implemented in libvirt yet
Nome Creation Time Stato
------------------------------------------------------------
win7-64-snap1 2015-03-04 14:21:15 +0100 shutoff
So, I have remove the machine and recreate it and the snapshot is gone
away.
Thanks for help.
Along with what Cole said, here is some more explanation
into revert/deletion of external snapshots (written by Eric Blake)

http://wiki.libvirt.org/page/I_created_an_external_snapshot,_but_libvirt_won%27t_let_me_delete_or_revert_to_it

And, also look up the archives of 'libvirt-users' mailing list for
similar questions -- there's lot of useful info there too.
--
/kashyap
Loading...