]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
qemu: add support for -device pvpanic
authorHu Tao <hutao@cn.fujitsu.com>
Mon, 9 Dec 2013 09:11:15 +0000 (17:11 +0800)
committerEric Blake <eblake@redhat.com>
Fri, 13 Dec 2013 12:53:33 +0000 (05:53 -0700)
Map the new <panic> device in XML to the '-device pvpanic' command
line of qemu.  Clients can then couple the <panic> device and the
<on_crash> directive to control behavior when the guest reports
a panic to qemu.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
tests/qemucapabilitiesdata/caps_1.5.3-1.caps
tests/qemucapabilitiesdata/caps_1.6.0-1.caps
tests/qemucapabilitiesdata/caps_1.6.50-1.caps
tests/qemuxml2argvdata/qemuxml2argv-panic.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-panic.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index a68e555dc8d6c3a9ae9c34c3c3ef3e2319c831f1..62622d087e7cdbf9a4649c52a3673e80a157ac21 100644 (file)
@@ -245,6 +245,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "kvm-pit-lost-tick-policy",
 
               "boot-strict", /* 160 */
+              "pvpanic", /* 161 */
     );
 
 struct _virQEMUCaps {
@@ -1396,6 +1397,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "usb-storage", QEMU_CAPS_DEVICE_USB_STORAGE },
     { "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO },
     { "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
+    { "pvpanic", QEMU_CAPS_DEVICE_PANIC },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
index aea64ea146161c83228d8046f494761940a4adab..bbf4972cf1c40cbe4c937d2e272f55d9168c624a 100644 (file)
@@ -199,6 +199,7 @@ enum virQEMUCapsFlags {
     QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
     QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */
     QEMU_CAPS_BOOT_STRICT        = 160, /* -boot strict */
+    QEMU_CAPS_DEVICE_PANIC       = 161, /* -device pvpanic */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
index 9539be784d312191f8455f85889ae43925d4a573..a80559e755b29ae1dae2defad7c089a15021f0df 100644 (file)
@@ -9621,6 +9621,22 @@ qemuBuildCommandLine(virConnectPtr conn,
         goto error;
     }
 
+    if (def->panic) {
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) {
+            if (def->panic->info.addr.isa.iobase > 0) {
+                virCommandAddArg(cmd, "-device");
+                virCommandAddArgFormat(cmd, "pvpanic,ioport=%d",
+                                       def->panic->info.addr.isa.iobase);
+            } else {
+                virCommandAddArgList(cmd, "-device", "pvpanic", NULL);
+            }
+        } else {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("your QEMU is too old to support pvpanic"));
+            goto error;
+        }
+    }
+
     if (mlock) {
         unsigned long long memKB;
 
index 2b0044965e36dcde395aeb40a8acb3b1c59f92dc..7ca2c6547d1b03eff11c925a7e5fa23db79799ea 100644 (file)
     <flag name='ich9-intel-hda'/>
     <flag name='kvm-pit-lost-tick-policy'/>
     <flag name='boot-strict'/>
+    <flag name='pvpanic'/>
   </qemuCaps>
index 7bce4aa0642b18b6eac718f2ae132354c575735d..dcbf5d5ef421c19421f1c423eb7d6fca33ebe4d6 100644 (file)
     <flag name='ich9-intel-hda'/>
     <flag name='kvm-pit-lost-tick-policy'/>
     <flag name='boot-strict'/>
+    <flag name='pvpanic'/>
   </qemuCaps>
index bfaab9d2ce1959c413314c2e7f71fab63e79d932..1159f59954f8ec7d8c03eab8610a62d5bee78e72 100644 (file)
     <flag name='ich9-intel-hda'/>
     <flag name='kvm-pit-lost-tick-policy'/>
     <flag name='boot-strict'/>
+    <flag name='pvpanic'/>
   </qemuCaps>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic.args b/tests/qemuxml2argvdata/qemuxml2argv-panic.args
new file mode 100644 (file)
index 0000000..8e07cba
--- /dev/null
@@ -0,0 +1,6 @@
+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,ioport=1285
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic.xml b/tests/qemuxml2argvdata/qemuxml2argv-panic.xml
new file mode 100644 (file)
index 0000000..e354511
--- /dev/null
@@ -0,0 +1,31 @@
+<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>
+      <address type='isa' iobase='0x505'/>
+    </panic>
+  </devices>
+</domain>
index f75e457c656e7c5243b8eece4de5c2281afaf136..847e96f8560d9b64591b5514369fafefba6e9540 100644 (file)
@@ -1306,6 +1306,9 @@ mymain(void)
     DO_TEST("kvm-pit-device", QEMU_CAPS_NO_KVM_PIT,
             QEMU_CAPS_KVM_PIT_TICK_POLICY);
 
+    DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
+            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+
     virObjectUnref(driver.config);
     virObjectUnref(driver.caps);
     virObjectUnref(driver.xmlopt);
index 2a9849ce920c90cf1e7a61004946cfe2b580010c..89de0c951c0906b992580db988334bd74b4b9e20 100644 (file)
@@ -323,6 +323,8 @@ mymain(void)
     DO_TEST("pcihole64-none");
     DO_TEST("pcihole64-q35");
 
+    DO_TEST("panic");
+
     virObjectUnref(driver.caps);
     virObjectUnref(driver.xmlopt);