On 2/23/19 4:24 PM, Eric Blake wrote:
> Add a new function to make it possible to parse a list of snapshots
> at once.  This is a counterpart to the previous patch making it
> possible to produce all snapshots in a single XML string, and
> intentionally parses the same top-level element <snapshots> with
> an optional attribute current='name'.
> 
> Note that existing REDEFINE code uses virDomainSnapshotRedefinePrep()
> for some sanity checking - much of that checking involves parent/child
> relationships (which make sense when doing one element at a time and
> worrying about replacement), but where this patch gets away with the
> much simpler final call to virDomainSnapshotUpdateRelations() (for
> all relationship checking after the end, since we know we started with
> no relations at all, and since checking parent relationships
> per-snapshot is not viable as we don't control which order the
> snapshots appear in).  All other domain-agnostic sanity checks used
> during a redefinition are copied here.

Some day maybe there's a helper that can handle both uses...

> 
> Signed-off-by: Eric Blake <ebl...@redhat.com>
> ---
>  src/conf/snapshot_conf.h |   7 ++
>  src/conf/snapshot_conf.c | 135 +++++++++++++++++++++++++++++++++++++++
>  src/libvirt_private.syms |   1 +
>  3 files changed, 143 insertions(+)
> 
> diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
> index 19ab75f895..6a92241fe6 100644
> --- a/src/conf/snapshot_conf.h
> +++ b/src/conf/snapshot_conf.h
> @@ -117,6 +117,13 @@ virDomainSnapshotDefPtr 
> virDomainSnapshotDefParseNode(xmlDocPtr xml,
>                                                        virCapsPtr caps,
>                                                        virDomainXMLOptionPtr 
> xmlopt,
>                                                        unsigned int flags);
> +int virDomainSnapshotDefParseList(const char *xmlSstr,
> +                                  const unsigned char *domain_uuid,
> +                                  virDomainSnapshotObjListPtr snapshots,
> +                                  virDomainSnapshotObjPtr *current_snap,
> +                                  virCapsPtr caps,
> +                                  virDomainXMLOptionPtr xmlopt,
> +                                  unsigned int flags);

virDomainSnapshotObjListParse (consistency w/
virDomainSnapshotObjListFormat)

>  void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
>  char *virDomainSnapshotDefFormat(const char *uuidstr,
>                                   virDomainSnapshotDefPtr def,
> diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
> index 963dc10247..61e26726e9 100644
> --- a/src/conf/snapshot_conf.c
> +++ b/src/conf/snapshot_conf.c
> @@ -426,6 +426,141 @@ virDomainSnapshotDefParseString(const char *xmlStr,
>  }
> 
> 
> +int virDomainSnapshotDefParseList(const char *xmlStr,
> +                                  const unsigned char *domain_uuid,
> +                                  virDomainSnapshotObjListPtr snapshots,
> +                                  virDomainSnapshotObjPtr *current_snap,
> +                                  virCapsPtr caps,
> +                                  virDomainXMLOptionPtr xmlopt,
> +                                  unsigned int flags)

int
virDomainSnapshotObjListParse(...)

> +{
> +    int ret = -1;
> +    xmlDocPtr xml;
> +    xmlNodePtr root;
> +    xmlXPathContextPtr ctxt = NULL;
> +    char *current = NULL;
> +    int n;
> +    size_t i;
> +    VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
> +    int keepBlanksDefault = xmlKeepBlanksDefault(0);
VIR_AUTOFREE(char *) current = NULL;

Typically it's been requested to keep all the VIR_AUTO* at the end of
arguments... Of course beyond the one change Peter decided not to
re-open his editor to modify after review comment requested otherwise.

[...]

> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index c623737c30..96f54a97fe 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -881,6 +881,7 @@ virDomainSnapshotAssignDef;
>  virDomainSnapshotDefFormat;
>  virDomainSnapshotDefFree;
>  virDomainSnapshotDefIsExternal;
> +virDomainSnapshotDefParseList;

virDomainSnapshotObjListParse;

>  virDomainSnapshotDefParseString;
>  virDomainSnapshotDropParent;
>  virDomainSnapshotFindByName;
> 

Simple enough adjustments...

Reviewed-by: John Ferlan <jfer...@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to