The user can pass it in as a subelement of <domain> as we already
do for storage volumes.
---
src/test/test_driver.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 09260ba..67c6d68 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -924,6 +924,68 @@ error:
}
static int
+testParseDomainSnapshots(testConnPtr privconn,
+ virDomainObjPtr domobj,
+ const char *file,
+ xmlXPathContextPtr ctxt,
+ xmlNodePtr rootnode)
+{
+ char *xpath;
+ size_t i;
+ int num, ret = -1;
+ xmlNodePtr *nodes = NULL;
+
+ /* Find storage volumes */
+ if (virAsprintf(&xpath, "%s/domainsnapshot", xmlGetNodePath(rootnode))
< 0)
+ goto error;
+
+ num = virXPathNodeSet(xpath, ctxt, &nodes);
+ VIR_FREE(xpath);
+ if (num < 0) {
+ goto error;
+ }
+
+ for (i = 0; i < num; i++) {
+ virDomainSnapshotObjPtr snap;
+ virDomainSnapshotDefPtr def;
+ xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file,
+ "domainsnapshot");
+ if (!node)
+ goto error;
+
+ def = virDomainSnapshotDefParseNode(ctxt->doc, node,
+ privconn->caps,
+ privconn->xmlopt,
+ 1 << VIR_DOMAIN_VIRT_TEST,
+ VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
+ VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
+ VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
+ if (!def)
+ goto error;
+
+ if (!(snap = virDomainSnapshotAssignDef(domobj->snapshots, def))) {
+ virDomainSnapshotDefFree(def);
+ goto error;
+ }
+
+ if (def->current) {
+ if (domobj->current_snapshot) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("more than one snapshot claims to be
active"));
+ goto error;
+ }
+
+ domobj->current_snapshot = snap;
+ }
+ }
+
+ ret = 0;
+error:
+ VIR_FREE(nodes);
+ return ret;
+}
+
+static int
testParseDomains(testConnPtr privconn,
const char *file,
xmlXPathContextPtr ctxt)
@@ -976,6 +1038,11 @@ testParseDomains(testConnPtr privconn,
goto error;
}
+ if (testParseDomainSnapshots(privconn, obj, file, ctxt, node) < 0) {
+ virObjectUnlock(obj);
+ goto error;
+ }
+
obj->persistent = !transient;
if (runstate != VIR_DOMAIN_SHUTOFF) {
if (testDomainStartState(privconn, obj,
--
1.8.3.1