diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapshotobjlist.c index e2f2110108d671e9a990af7208b1f778b3c79c7e..7f2340404f1427cf165754f32e0d9b0f4c5a06a4 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -43,8 +43,10 @@ struct _virDomainSnapshotObjList { }; -/* Parse a XML entry into snapshots, which must start empty. - * Any sub-elements of a must match domain_uuid. +/* Parse a XML entry into snapshots, which must start + * empty. Any sub-elements of a must match + * domain_uuid. @flags is virDomainSnapshotParseFlags. Return the + * number of snapshots parsed, or -1 on error. */ int virDomainSnapshotObjListParse(const char *xmlStr, @@ -98,11 +100,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 child")); - goto cleanup; - } for (i = 0; i < n; i++) { virDomainSnapshotDefPtr def; @@ -137,7 +134,7 @@ virDomainSnapshotObjListParse(const char *xmlStr, (*current_snap)->def->current = true; } - ret = 0; + ret = n; cleanup: if (ret < 0) { /* There were no snapshots before this call; so on error, just @@ -177,8 +174,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, @@ -196,6 +194,7 @@ virDomainSnapshotObjListFormat(virBufferPtr buf, .flags = flags, }; + virCheckFlags(VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE, -1); virBufferAddLit(buf, "