]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Automatically add <panic> element for pSeries guests.
authorAndrea Bolognani <abologna@redhat.com>
Thu, 28 May 2015 14:39:13 +0000 (16:39 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 1 Jun 2015 10:44:37 +0000 (06:44 -0400)
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.

docs/formatdomain.html.in
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
tests/qemuxml2argvdata/qemuxml2argv-pseries-nvram.xml
tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-panic-missing.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index 7dd5fa9912443ad80f757a3904d38e3896252cc4..178199679ed357ca92fb4715cc88df3c12f9592b 100644 (file)
@@ -5943,6 +5943,11 @@ qemu-kvm -net nic,model=? /dev/null
       guest.
       <span class="since">Since 1.2.1, QEMU and KVM only</span>
     </p>
+    <p>
+      For pSeries guests, this feature is always enabled since it's
+      implemented by the guest firmware, thus libvirt automatically
+      adds the <code>panic</code> element to the domain XML.
+    </p>
     <p>
       Example: usage of panic configuration
     </p>
index db8554b79e3fd7a89fdaa6f105350b80713b18b9..12a1d97889397b306eca629b05433a7efc2e0597 100644 (file)
@@ -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;
 }
 
index d9ae4af9d43e0764ef9b4c006ee55a67046cc534..3a962098034019985ffd55bbdb127041252024c0 100644 (file)
@@ -37,5 +37,6 @@
       <model type='cirrus' vram='16384' heads='1'/>
     </video>
     <memballoon model='none'/>
+    <panic/>
   </devices>
 </domain>
index 9703bd4c355b81b181fdb79735d9734cef9ac1dd..619186a526bc6ef4b9e4b8b1b283a621ce0cee82 100644 (file)
@@ -20,5 +20,6 @@
     <nvram>
       <address type='spapr-vio' reg='0x4000'/>
     </nvram>
+    <panic/>
   </devices>
 </domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-panic-missing.args
new file mode 100644 (file)
index 0000000..30e4b43
--- /dev/null
@@ -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 (file)
index 0000000..8980847
--- /dev/null
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>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-system-ppc64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <serial type='pty'>
+      <target port='0'/>
+      <address type='spapr-vio'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <address type='spapr-vio'/>
+    </console>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index f822670322744cb375d600f5dcde1f749b4a2dc5..11e09ce10d43cdcfcfce11d73e03558fc5c6dd1e 100644 (file)
@@ -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 (file)
index 0000000..9312975
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>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-system-ppc64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <serial type='pty'>
+      <target port='0'/>
+      <address type='spapr-vio'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+      <address type='spapr-vio'/>
+    </console>
+    <memballoon model='none'/>
+    <panic/>
+  </devices>
+</domain>
index c147795d86f7fbd61280c30697a213d3ae49d6f4..4cc1b6a57cdbe04ddf9fdafcfe62aa745d947f19 100644 (file)
@@ -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 */