[PATCH 01/25] tests: qemuxml2xml: Avoid crash when processing an XML that fails to parse

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

 



Failure to parse a XML that was not supposed to fail would result into a
crash in the test suite as the vcpu bitmap would not be filled prior to
the active XML->XML test.

Skip formatting of the vcpu snippet in the fake status XML formatter in
such case to avoid the crash. The test would fail anyways.
---
 tests/qemuxml2xmltest.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 8a184d2..5f04b8b 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -112,9 +112,12 @@ testGetStatuXMLPrefixVcpus(virBufferPtr buf,
     virBufferAddLit(buf, "<vcpus>\n");
     virBufferAdjustIndent(buf, 2);

-    while ((vcpuid = virBitmapNextSetBit(data->activeVcpus, vcpuid)) >= 0)
-        virBufferAsprintf(buf, "<vcpu id='%zd' pid='%zd'/>\n",
-                          vcpuid, vcpuid + 3803519);
+    /* Make sure we can format the fake vcpu list. The test will fail regardles. */
+    if (data->activeVcpus) {
+        while ((vcpuid = virBitmapNextSetBit(data->activeVcpus, vcpuid)) >= 0)
+            virBufferAsprintf(buf, "<vcpu id='%zd' pid='%zd'/>\n",
+                              vcpuid, vcpuid + 3803519);
+    }

     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</vcpus>\n");
-- 
2.9.0

--
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]