From: Andrea Bolognani
Date: Thu, 28 May 2015 14:39:13 +0000 (+0200)
Subject: qemu: Automatically add element for pSeries guests.
X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=778c56f0002ffdcb6121b39c7db858859658f942;p=libvirt.git
qemu: Automatically add element for pSeries guests.
The guest firmware provides the same functionality as the pvpanic
device, and the relevant element should always be present in the
domain XML to reflect this fact, so add it after parsing the
definition if it wasn't there already.
---
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 7dd5fa9912..178199679e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5943,6 +5943,11 @@ qemu-kvm -net nic,model=? /dev/null
guest.
Since 1.2.1, QEMU and KVM only
+
+ For pSeries guests, this feature is always enabled since it's
+ implemented by the guest firmware, thus libvirt automatically
+ adds the panic
element to the domain XML.
+
Example: usage of panic configuration
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index db8554b79e..12a1d97889 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -959,6 +959,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
bool addDefaultMemballoon = true;
bool addDefaultUSBKBD = false;
bool addDefaultUSBMouse = false;
+ bool addPanicDevice = false;
if (def->os.bootloader || def->os.bootloaderArgs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -1011,6 +1012,11 @@ qemuDomainDefPostParse(virDomainDefPtr def,
addPCIRoot = true;
addDefaultUSBKBD = true;
addDefaultUSBMouse = true;
+ /* For pSeries guests, the firmware provides the same
+ * functionality as the pvpanic device, so automatically
+ * add the definition if not already present */
+ if (STRPREFIX(def->os.machine, "pseries"))
+ addPanicDevice = true;
break;
case VIR_ARCH_ALPHA:
@@ -1093,6 +1099,14 @@ qemuDomainDefPostParse(virDomainDefPtr def,
VIR_DOMAIN_INPUT_BUS_USB) < 0)
return -1;
+ if (addPanicDevice && !def->panic) {
+ virDomainPanicDefPtr panic;
+ if (VIR_ALLOC(panic) < 0)
+ return -1;
+
+ def->panic = panic;
+ }
+
return 0;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
index d9ae4af9d4..3a96209803 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
@@ -37,5 +37,6 @@
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.xml
index 9703bd4c35..619186a526 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.xml
@@ -20,5 +20,6 @@
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
new file mode 100644
index 0000000000..30e4b43a64
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
@@ -0,0 +1,7 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -smp 1 -nographic \
+-nodefconfig -nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -usb \
+-chardev pty,id=charserial0 \
+-device spapr-vty,chardev=charserial0,reg=0x30000000
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.xml
new file mode 100644
index 0000000000..8980847141
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
+ 524288
+ 524288
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-ppc64
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f822670322..11e09ce10d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1365,6 +1365,8 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("pseries-panic-missing",
+ QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("pseries-panic-no-address",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST_FAILURE("pseries-panic-address",
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
new file mode 100644
index 0000000000..9312975800
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml
@@ -0,0 +1,30 @@
+
+ QEMUGuest1
+ 1ccfd97d-5eb4-478a-bbe6-88d254c16db7
+ 524288
+ 524288
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-ppc64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c147795d86..4cc1b6a57c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -537,6 +537,7 @@ mymain(void)
DO_TEST("virtio-rng-egd");
DO_TEST("pseries-nvram");
+ DO_TEST_DIFFERENT("pseries-panic-missing");
DO_TEST("pseries-panic-no-address");
/* These tests generate different XML */