From: Peter Krempa Date: Mon, 25 Jul 2016 08:33:03 +0000 (+0200) Subject: tests: qemuxml2xml: Avoid crash when processing an XML that fails to parse X-Git-Tag: v2.1.0-rc1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c934f1e0fdd84c78d3173e5a72a4facd106c0b40;p=thirdparty%2Flibvirt.git tests: qemuxml2xml: Avoid crash when processing an XML that fails to parse 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. --- diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8a184d271f..5f04b8b6f0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -112,9 +112,12 @@ testGetStatuXMLPrefixVcpus(virBufferPtr buf, virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - while ((vcpuid = virBitmapNextSetBit(data->activeVcpus, vcpuid)) >= 0) - virBufferAsprintf(buf, "\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, "\n", + vcpuid, vcpuid + 3803519); + } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n");