[libvirt] [PATCHv2 16/20] conf: Add helper to determine if snapshot is external

Eric Blake eblake at redhat.com
Tue Nov 6 17:51:46 UTC 2012


On 11/01/2012 10:22 AM, Peter Krempa wrote:
> Snapshots are external if they are "disk snapshots" or if they have an
> external memory image. Other possibilities are not supported (yet).

And given the discussion on 15/20, even though it might be technically
possible to mix internal and external disk images into a single
snapshot, we are going to forbid that mix for now (because it has
interesting ramifications on how to do a revert), so this approach looks
sane.

> ---
>  src/conf/snapshot_conf.c | 11 +++++++++++
>  src/conf/snapshot_conf.h |  2 ++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 14 insertions(+)
> 
> diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
> index 691950a..5d9df57 100644
> --- a/src/conf/snapshot_conf.c
> +++ b/src/conf/snapshot_conf.c
> @@ -1023,3 +1023,14 @@ cleanup:
>      }
>      return ret;
>  }
> +
> +
> +bool
> +virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap)
> +{
> +    if (snap->def->state == VIR_DOMAIN_DISK_SNAPSHOT ||
> +        snap->def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
> +        return true;
> +
> +    return false;
> +}

This isn't quite true.  If the snapshot is offline, then
snap->def->state will be VIR_DOMAIN_SHUTOFF, not
VIR_DOMAIN_DISK_SNAPSHOT.  If state is shutoff, you're going to have to
loop over the disks to see if any of them requested external.

-- 
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: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121106/f1de2a58/attachment-0001.sig>


More information about the libvir-list mailing list