[libvirt-users] Questions related to the snapshot

Eric Blake eblake at redhat.com
Thu Jul 19 13:34:20 UTC 2012


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 at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20120719/8508e728/attachment.sig>


More information about the libvirt-users mailing list