From: Michal Privoznik Date: Thu, 26 Feb 2015 14:28:07 +0000 (+0100) Subject: domain_conf: Format without address correctly X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b39b1397ea6e6155b5e363d456196504093edd07;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git domain_conf: Format without address correctly We have something like pvpanic device. However, in some cases it does not have any address assigned, in which case we produce this ugly XML (still valid though): /usr/bin/qemu ... Lets format "" instead. Signed-off-by: Michal Privoznik --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 01a3fbc3a..cc8616b7c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18840,13 +18840,21 @@ virDomainWatchdogDefFormat(virBufferPtr buf, static int virDomainPanicDefFormat(virBufferPtr buf, virDomainPanicDefPtr def) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - if (virDomainDeviceInfoFormat(buf, &def->info, 0) < 0) - return -1; - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBuffer childrenBuf = VIR_BUFFER_INITIALIZER; + int indent = virBufferGetIndent(buf, false); + virBufferAddLit(buf, "info, 0) < 0) + return -1; + if (virBufferUse(&childrenBuf)) { + virBufferAddLit(buf, ">\n"); + virBufferAddBuffer(buf, &childrenBuf); + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } + virBufferFreeAndReset(&childrenBuf); return 0; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.args b/tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.args new file mode 100644 index 000000000..3cbd688b2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ +-hda /dev/HostVG/QEMUGuest1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -device pvpanic diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.xml b/tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.xml new file mode 100644 index 000000000..79f8a1e15 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-panic-no-address.xml @@ -0,0 +1,29 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 00fd044ff..e2ad71344 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1522,6 +1522,9 @@ mymain(void) DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); + DO_TEST("panic-no-address", QEMU_CAPS_DEVICE_PANIC, + QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); + DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS); DO_TEST("shmem", QEMU_CAPS_PCIDEVICE, diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 2bec2b2d0..6608ccaf7 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -401,6 +401,7 @@ mymain(void) DO_TEST("pcihole64-q35"); DO_TEST("panic"); + DO_TEST("panic-no-address"); DO_TEST_DIFFERENT("disk-backing-chains");