[libvirt-users] Questions related to the snapshot

Hi, I faced two problems with the snapshot: First issue, I can use the snapshot functions via the virsh correctly such as snapshot-list. And when I removed the snapshot XML files from /var/lib/libvirt/qemu/snapshot/**/, I don't see the snapshot of the Virtual Machine any more. That's correct. But after I copying the XML files back, I can't see the the snapshot as well. Only if I restart my laptop can I see them. However, restarting is what I want to avoid. Because I wish I could utilize the functions in a server in the future. Does anyone have ideas about this, Did I do something wrong or it's a limitation. So far, I am using the qemu-img command to check the snapshot and do the revert without restarting my laptop. Because the snapshots are already embedded in the img file. Second issue, I find if I create the XML file of snapshot by using getXMLDesc and output to a new file in python, there is a slightly different. But, the new XML file can't be recognized even if I restart my laptop. The new XML file miss the attribute <active> as far as I can see, is it so important? Here is one example: The original XML in the default folder: <domainsnapshot> <name>Ex</name> <description>Snapshot of OS updates</description> <state>running</state> <parent> <name>1342427860</name> </parent> <creationTime>1342428835</creationTime> <domain> <uuid>2c853de2-6bba-ad26-bf05-0045e5f1beb9</uuid> </domain> <active>0</active> </domainsnapshot> The new XML file I created: <domainsnapshot> <name>Ex</name> <description>Snapshot of OS updates</description> <state>running</state> <parent> <name>1342427860</name> </parent> <creationTime>1342428835</creationTime> <domain> <uuid>2c853de2-6bba-ad26-bf05-0045e5f1beb9</uuid> </domain> </domainsnapshot> Thank you so much. Best Regards Tan

On 07/19/2012 05:38 AM, lin tan wrote:
Hi,
I faced two problems with the snapshot:
First issue, I can use the snapshot functions via the virsh correctly such as snapshot-list.
So far, so good.
And when I removed the snapshot XML files from /var/lib/libvirt/qemu/snapshot/**/,
Ouch. You should never modify files in /var/lib/libvirt - they are internal only. If you want to remove a snapshot, you should do so through the public API (virsh snapshot-delete, in this case).
I don't see the snapshot of the Virtual Machine any more. That's correct.
No, it's sheer dumb luck. You mucked with libvirt's internal storage, so all bets are off.
But after I copying the XML files back, I can't see the the snapshot as well. Only if I restart my laptop can I see them.
You might also get lucky and see them by restarting just libvirtd, rather than your entire computer.
However, restarting is what I want to avoid. Because I wish I could utilize the functions in a server in the future. Does anyone have ideas about this, Did I do something wrong or it's a limitation.
What are you really trying to do? Then we can tell you how to do it using the APIs instead of mucking around with files behind libvirt's back.
So far, I am using the qemu-img command to check the snapshot and do the revert without restarting my laptop. Because the snapshots are already embedded in the img file.
Second issue, I find if I create the XML file of snapshot by using getXMLDesc and output to a new file in python, there is a slightly different. But, the new XML file can't be recognized even if I restart my laptop. The new XML file miss the attribute <active> as far as I can see, is it so important?
The attribute <active> is an internal-only detail, it only shows up in the /var/lib/libvirt locations because that is where libvirt stores internal-only information. You should never directly manipulate it. Instead, if you want to reinstate XML for a snapshot description after having previously erased that metadata, the correct approach is: virsh snapshot-create $dom $file --redefine [--current] where the optional use of --current will control whether /var/lib/libvirt sets the <active> internal element to 0 or 1. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
lin tan