[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]