mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
domain_conf: Format <pvpanic/> 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):
<devices>
<emulator>/usr/bin/qemu</emulator>
...
<panic>
</panic>
</devices>
Lets format "<panic/>" instead.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
1 parent
d196444c49
commit
b39b1397ea
5 files changed
+52
-6
No files matched your search
+14
-6
@@ -18840,13 +18840,21 @@ virDomainWatchdogDefFormat(virBufferPtr buf,
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,29 @@
|
||||
<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>
|
||||
@@ -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,
|
||||
|
||||
@@ -401,6 +401,7 @@ mymain(void)
|
||||
DO_TEST("pcihole64-q35");
|
||||
|
||||
DO_TEST("panic");
|
||||
DO_TEST("panic-no-address");
|
||||
|
||||
DO_TEST_DIFFERENT("disk-backing-chains");
|
||||
|
||||
|
||||
Reference in new issue
Block a user