]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
test: Allow specifying object transient state in driver XML
authorCole Robinson <crobinso@redhat.com>
Tue, 6 Aug 2013 22:36:30 +0000 (18:36 -0400)
committerCole Robinson <crobinso@redhat.com>
Tue, 1 Oct 2013 15:27:21 +0000 (11:27 -0400)
Similar to the runstate commit, allow a boolean <test:transient/>
element for setting domain persistence at driver startup.

src/test/test_driver.c

index 48b5ec14302c7c8b9d785d7ef98ecdb831944507..87a87cce5422c4552bc8e2f2acf78bd1b9eab80b 100644 (file)
@@ -159,6 +159,7 @@ typedef struct _testDomainNamespaceDef testDomainNamespaceDef;
 typedef testDomainNamespaceDef *testDomainNamespaceDefPtr;
 struct _testDomainNamespaceDef {
     int runstate;
+    bool transient;
 };
 
 static void
@@ -189,6 +190,13 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
     if (VIR_ALLOC(nsdata) < 0)
         return -1;
 
+    tmp = virXPathBoolean("boolean(./test:transient)", ctxt);
+    if (tmp == -1) {
+        virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid transient"));
+        goto error;
+    }
+    nsdata->transient = tmp;
+
     tmp = virXPathUInt("string(./test:runstate)", ctxt, &tmpuint);
     if (tmp == 0) {
         if (tmpuint >= VIR_DOMAIN_LAST) {
@@ -205,6 +213,12 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
         goto error;
     }
 
+    if (nsdata->transient && nsdata->runstate == VIR_DOMAIN_SHUTOFF) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+            _("transient domain cannot have runstate 'shutoff'"));
+        goto error;
+    }
+
     *data = nsdata;
     return 0;
 
@@ -922,7 +936,7 @@ testParseDomains(testConnPtr privconn,
         }
 
         nsdata = def->namespaceData;
-        obj->persistent = 1;
+        obj->persistent = !nsdata->transient;
 
         if (nsdata->runstate != VIR_DOMAIN_SHUTOFF) {
             if (testDomainStartState(privconn, obj,