static int virDomainPanicDefFormat(virBufferPtr buf,
virDomainPanicDefPtr def)
{
- virBufferAddLit(buf, "<panic>\n");
- virBufferAdjustIndent(buf, 2);
- if (virDomainDeviceInfoFormat(buf, &def->info, 0) < 0)
- return -1;
- virBufferAdjustIndent(buf, -2);
- virBufferAddLit(buf, "</panic>\n");
+ virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
+ int indent = virBufferGetIndent(buf, false);
+ virBufferAddLit(buf, "<panic");
+ virBufferAdjustIndent(&childrenBuf, indent + 2);
+ if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, 0) < 0)
+ return -1;
+ if (virBufferUse(&childrenBuf)) {
+ virBufferAddLit(buf, ">\n");
+ virBufferAddBuffer(buf, &childrenBuf);
+ virBufferAddLit(buf, "</panic>\n");
+ } else {
+ virBufferAddLit(buf, "/>\n");
+ }
+ virBufferFreeAndReset(&childrenBuf);
return 0;
}
--- /dev/null
+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
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='fdc' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ <panic/>
+ </devices>
+</domain>
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,
DO_TEST("pcihole64-q35");
DO_TEST("panic");
+ DO_TEST("panic-no-address");
DO_TEST_DIFFERENT("disk-backing-chains");