[PATCH v4 2/3] test: Sync GetXML INACTIVE behavior with live driver

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

 



- Error if INACTIVE requested for transient object
- Force dumping INACTIVE XML when object is inactive

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 src/test/test_driver.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 153ab7cdc2..e7d2b6c866 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -7514,15 +7514,30 @@ testNodeDeviceGetXMLDesc(virNodeDevicePtr dev,
 {
     testDriver *driver = dev->conn->privateData;
     virNodeDeviceObj *obj;
+    virNodeDeviceDef *def;
     char *ret = NULL;
 
     virCheckFlags(VIR_NODE_DEVICE_XML_INACTIVE, NULL);
 
     if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
         return NULL;
+    def = virNodeDeviceObjGetDef(obj);
 
-    ret = virNodeDeviceDefFormat(virNodeDeviceObjGetDef(obj), flags);
+    if (flags & VIR_NODE_DEVICE_XML_INACTIVE) {
+        if (!virNodeDeviceObjIsPersistent(obj)) {
+            virReportError(VIR_ERR_OPERATION_INVALID,
+                           _("node device '%1$s' is not persistent"),
+                           def->name);
+            goto cleanup;
+        }
+    } else {
+        if (!virNodeDeviceObjIsActive(obj))
+            flags |= VIR_NODE_DEVICE_XML_INACTIVE;
+    }
 
+    ret = virNodeDeviceDefFormat(def, flags);
+
+ cleanup:
     virNodeDeviceObjEndAPI(&obj);
     return ret;
 }
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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