[PATCH 15/16] snapshot: Tweaks to support new bulk dumpxml/import API

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

 



Change the return value of virDomainSnapshotObjLisParse() to return
the number of snapshots imported, and allow a return of 0 (the
original proposal of adding a flag to virDomainSnapshotCreateXML
required returning an arbitrary non-NULL snapshot, but with a new API
that returns a count, we are no longer constrained to a non-empty
list).

Document which flags are supported (namely, just SECURE) in
virDomainSnapshotObjListFormat().

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/conf/virdomainsnapshotobjlist.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapshotobjlist.c
index 31ed1c672d..b7dc74b27f 100644
--- a/src/conf/virdomainsnapshotobjlist.c
+++ b/src/conf/virdomainsnapshotobjlist.c
@@ -39,8 +39,10 @@ struct _virDomainSnapshotObjList {
 };


-/* Parse a <snapshots> XML entry into snapshots, which must start empty.
- * Any <domain> sub-elements of a <domainsnapshot> must match domain_uuid.
+/* Parse a <snapshots> XML entry into snapshots, which must start
+ * empty.  Any <domain> sub-elements of a <domainsnapshot> must match
+ * domain_uuid.  @flags is virDomainSnapshotParseFlags. Return the
+ * number of snapshots parsed, or -1 on error.
  */
 int
 virDomainSnapshotObjListParse(const char *xmlStr,
@@ -94,11 +96,6 @@ virDomainSnapshotObjListParse(const char *xmlStr,

     if ((n = virXPathNodeSet("./domainsnapshot", ctxt, &nodes)) < 0)
         goto cleanup;
-    if (!n) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("expected at least one <domainsnapshot> child"));
-        goto cleanup;
-    }

     for (i = 0; i < n; i++) {
         virDomainSnapshotDefPtr def;
@@ -133,7 +130,7 @@ virDomainSnapshotObjListParse(const char *xmlStr,
         virDomainSnapshotSetCurrent(snapshots, snap);
     }

-    ret = 0;
+    ret = n;
  cleanup:
     if (ret < 0) {
         /* There were no snapshots before this call; so on error, just
@@ -172,8 +169,9 @@ virDomainSnapshotFormatOne(void *payload,
 }


-/* Format the XML for all snapshots in the list into buf. On error,
- * clear the buffer and return -1. */
+/* Format the XML for all snapshots in the list into buf. @flags is
+ * virDomainSnapshotFormatFlags. On error, clear the buffer and return
+ * -1. */
 int
 virDomainSnapshotObjListFormat(virBufferPtr buf,
                                const char *uuidstr,
@@ -190,6 +188,7 @@ virDomainSnapshotObjListFormat(virBufferPtr buf,
         .flags = flags,
     };

+    virCheckFlags(VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE, -1);
     virBufferAddLit(buf, "<snapshots");
     virBufferEscapeString(buf, " current='%s'",
                           virDomainSnapshotGetCurrentName(snapshots));
-- 
2.20.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux