[PATCH 09/10] Make qemuhotplugtest work with persistent domains

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

 



It was previously working only with attachments/detachments
to the live domain. Now it can test attaching/detaching to
the persistent domain too.
---
 tests/qemuhotplugtest.c | 43 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)

diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 1501e31..0244519 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -234,12 +234,29 @@ testQemuHotplug(const void *data)
     if (virAsprintf(&domain_filename, "%s/qemuhotplugtestdomains/qemuhotplug-%s.xml",
                     abs_srcdir, test->domain_filename) < 0 ||
         virAsprintf(&device_filename, "%s/qemuhotplugtestdevices/qemuhotplug-%s.xml",
-                    abs_srcdir, test->device_filename) < 0 ||
-        virAsprintf(&result_filename,
+                    abs_srcdir, test->device_filename) < 0)
+        goto cleanup;
+
+    switch (target) {
+    case VIR_DOMAIN_AFFECT_LIVE:
+        if (virAsprintf(&result_filename,
                     "%s/qemuhotplugtestdomains/qemuhotplug-%s+%s.xml",
                     abs_srcdir, test->domain_filename,
                     test->device_filename) < 0)
+            goto cleanup;
+        break;
+    case VIR_DOMAIN_AFFECT_CONFIG:
+        if (virAsprintf(&result_filename,
+                    "%s/qemuhotplugtestdomains/qemuhotplug-%s+%s+config.xml",
+                    abs_srcdir, test->domain_filename,
+                    test->device_filename) < 0)
+            goto cleanup;
+        break;
+    default:
+        VIR_TEST_VERBOSE("target can either be VIR_DOMAIN_AFFECT_LIVE"
+                         " or VIR_DOMAIN_AFFECT_CONFIG\n");
         goto cleanup;
+    }
 
     if (virTestLoadFile(domain_filename, &domain_xml) < 0 ||
         virTestLoadFile(device_filename, &device_xml) < 0)
@@ -303,16 +320,26 @@ testQemuHotplug(const void *data)
              * envelope */
             VIR_FREE(dev);
         }
-        if (ret == 0 || fail)
-            ret = testQemuHotplugCheckResult(vm->def, result_xml,
-                                             result_filename, fail);
+        if (ret == 0 || fail) {
+            if (target == VIR_DOMAIN_AFFECT_LIVE)
+                ret = testQemuHotplugCheckResult(vm->def, result_xml,
+                                                 result_filename, fail);
+            else if (target == VIR_DOMAIN_AFFECT_CONFIG)
+                ret = testQemuHotplugCheckResult(vm->newDef, result_xml,
+                                                 result_filename, fail);
+        }
         break;
 
     case DETACH:
         ret = testQemuHotplugDetach(vm, dev, device_xml, target);
-        if (ret == 0 || fail)
-            ret = testQemuHotplugCheckResult(vm->def, domain_xml,
-                                             domain_filename, fail);
+        if (ret == 0 || fail) {
+            if (target == VIR_DOMAIN_AFFECT_LIVE)
+                ret = testQemuHotplugCheckResult(vm->def, domain_xml,
+                                                 domain_filename, fail);
+            else if (target == VIR_DOMAIN_AFFECT_CONFIG)
+                ret = testQemuHotplugCheckResult(vm->newDef, domain_xml,
+                                                 domain_filename, fail);
+        }
         break;
 
     case UPDATE:
-- 
1.9.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]