On 08/10/2011 04:08 PM, Eric Blake wrote:
Undefining
++++++++++
In one regards, undefining a domain that has snapshots is just as bad as
undefining a domain with managed save state - since libvirt is
maintaining metadata about snapshot hierarchies, leaving this metadata
behind _will_ interfere with creation of a new domain by the same name.
However, since both checkpoints and snapshots are stored in
user-accessible disk images, and only the metadata is stored by libvirt,
it should eventually be possible for the user to decide whether to
discard the metadata but keep the snapshot contents intact in the disk
images, or to discard both the metadata and the disk image snapshots.
Meanwhile, I propose changing the default behavior of
virDomainUndefine[Flags] to reject attempts to undefine a domain with
any defined snapshots, and to add a new flag for virDomainUndefineFlags,
virDomainUndefineFlags(,VIR_DOMAIN_UNDEFINE_SNAPSHOTS), to act as
shorthand for calling virDomainSnapshotDelete for all snapshots tied to
the domain. Note that this deletes the metadata, but not the underlying
storage volumes.
Hmm. VIR_DOMAIN_UNDEFINE_MANAGED_SAVE is only needed for
virDomainUndefineFlags, since managed save is a persistent-only
possibility (a running domain does not have a managed save). But
VIR_DOMAIN_UNDEFINE_SNAPSHOTS is needed for both virDomainUndefineFlags
and virDomainDestroyFlags (since transient domains can have both
checkpoints and disk snapshots).
And while we added virDomainDestroyFlags in 0.9.4, we missed adding
virDomainShutdownFlags. Oh well - no convenience flag for the shutdown
case. But it does mean that both virDomainDestroy and virDomainShutdown
will have to fail by default if they would strand some snapshot metadata.
Also, I need to clarify the change to failure case. It is not fatal to
have snapshot metadata when converting a running guest from persistent
to transient, nor is it fatal to shutdown or destroy a persistent guest
with snapshots - in those cases, the domain still exists. The fatal
case is only whens stranding snapshot data (undefine on an inactive
domain, or destroy/shutdown on a transient domain).
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org