render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c401cc
From 1fb696dfda55579f323f53141b40b9e847723755 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <1fb696dfda55579f323f53141b40b9e847723755.1387385061.git.jdenemar@redhat.com>
c401cc
From: Hu Tao <hutao@cn.fujitsu.com>
c401cc
Date: Mon, 16 Dec 2013 11:58:22 -0700
c401cc
Subject: [PATCH] qemu: add support for -device pvpanic
c401cc
c401cc
RHEL 7.0: https://bugzilla.redhat.com/show_bug.cgi?id=996520
c401cc
c401cc
Map the new <panic> device in XML to the '-device pvpanic' command
c401cc
line of qemu.  Clients can then couple the <panic> device and the
c401cc
<on_crash> directive to control behavior when the guest reports
c401cc
a panic to qemu.
c401cc
c401cc
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
c401cc
Signed-off-by: Eric Blake <eblake@redhat.com>
c401cc
(cherry picked from commit 4d18758df88c7b1b646cab37979667a19f858a9c)
c401cc
c401cc
Conflicts:
c401cc
	src/qemu/qemu_capabilities.c - skipped other upstream capabilities
c401cc
	src/qemu/qemu_capabilities.h - likewise
c401cc
	tests/qemucapabilitiesdata/caps_1.5.3-1.caps - new upstream test not backported
c401cc
	tests/qemucapabilitiesdata/caps_1.6.0-1.caps - likewise
c401cc
	tests/qemucapabilitiesdata/caps_1.6.50-1.caps - likewise
c401cc
	tests/qemuxml2argvtest.c - context of upstream tests not backported
c401cc
	tests/qemuxml2xmltest.c - likewise
c401cc
	tests/qemuxml2argvdata/qemuxml2argv-panic.args - QEMU_AUDIO_DRV changes not backported
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/qemu/qemu_capabilities.c                   |  4 ++++
c401cc
 src/qemu/qemu_capabilities.h                   |  8 +++++--
c401cc
 src/qemu/qemu_command.c                        | 16 +++++++++++++
c401cc
 tests/qemuxml2argvdata/qemuxml2argv-panic.args |  6 +++++
c401cc
 tests/qemuxml2argvdata/qemuxml2argv-panic.xml  | 31 ++++++++++++++++++++++++++
c401cc
 tests/qemuxml2argvtest.c                       |  3 +++
c401cc
 tests/qemuxml2xmltest.c                        |  2 ++
c401cc
 7 files changed, 68 insertions(+), 2 deletions(-)
c401cc
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-panic.args
c401cc
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-panic.xml
c401cc
c401cc
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c401cc
index 9e0e597..ba17cce 100644
c401cc
--- a/src/qemu/qemu_capabilities.c
c401cc
+++ b/src/qemu/qemu_capabilities.c
c401cc
@@ -235,8 +235,11 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
c401cc
               "vnc-share-policy", /* 150 */
c401cc
               "device-del-event",
c401cc
               "dmi-to-pci-bridge",
c401cc
+
c401cc
+              /* RHEL backports below here */
c401cc
               "ich9-intel-hda",
c401cc
               "boot-strict",
c401cc
+              "pvpanic",
c401cc
     );
c401cc
 
c401cc
 struct _virQEMUCaps {
c401cc
@@ -1386,6 +1389,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
c401cc
     { "scsi-generic", QEMU_CAPS_DEVICE_SCSI_GENERIC },
c401cc
     { "i82801b11-bridge", QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE },
c401cc
     { "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
c401cc
+    { "pvpanic", QEMU_CAPS_DEVICE_PANIC },
c401cc
 };
c401cc
 
c401cc
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
c401cc
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
c401cc
index 7113185..dea1e13 100644
c401cc
--- a/src/qemu/qemu_capabilities.h
c401cc
+++ b/src/qemu/qemu_capabilities.h
c401cc
@@ -191,8 +191,12 @@ enum virQEMUCapsFlags {
c401cc
     QEMU_CAPS_VNC_SHARE_POLICY   = 150, /* set display sharing policy */
c401cc
     QEMU_CAPS_DEVICE_DEL_EVENT   = 151, /* DEVICE_DELETED event */
c401cc
     QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE  = 152, /* -device i82801b11-bridge */
c401cc
-    QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 153, /* -device ich9-intel-hda */
c401cc
-    QEMU_CAPS_BOOT_STRICT        = 154, /* -boot strict */
c401cc
+
c401cc
+    /* RHEL backports below here; since we are cherry-picking out of
c401cc
+     * order, we no longer track enum values in order. */
c401cc
+    QEMU_CAPS_DEVICE_ICH9_INTEL_HDA,    /* -device ich9-intel-hda */
c401cc
+    QEMU_CAPS_BOOT_STRICT,              /* -boot strict */
c401cc
+    QEMU_CAPS_DEVICE_PANIC,             /* -device pvpanic */
c401cc
 
c401cc
     QEMU_CAPS_LAST,                   /* this must always be the last item */
c401cc
 };
c401cc
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c401cc
index 4458f9a..35355b7 100644
c401cc
--- a/src/qemu/qemu_command.c
c401cc
+++ b/src/qemu/qemu_command.c
c401cc
@@ -9370,6 +9370,22 @@ qemuBuildCommandLine(virConnectPtr conn,
c401cc
         goto error;
c401cc
     }
c401cc
 
c401cc
+    if (def->panic) {
c401cc
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) {
c401cc
+            if (def->panic->info.addr.isa.iobase > 0) {
c401cc
+                virCommandAddArg(cmd, "-device");
c401cc
+                virCommandAddArgFormat(cmd, "pvpanic,ioport=%d",
c401cc
+                                       def->panic->info.addr.isa.iobase);
c401cc
+            } else {
c401cc
+                virCommandAddArgList(cmd, "-device", "pvpanic", NULL);
c401cc
+            }
c401cc
+        } else {
c401cc
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
c401cc
+                           _("your QEMU is too old to support pvpanic"));
c401cc
+            goto error;
c401cc
+        }
c401cc
+    }
c401cc
+
c401cc
     if (mlock) {
c401cc
         unsigned long long memKB;
c401cc
 
c401cc
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic.args b/tests/qemuxml2argvdata/qemuxml2argv-panic.args
c401cc
new file mode 100644
c401cc
index 0000000..dba0739
c401cc
--- /dev/null
c401cc
+++ b/tests/qemuxml2argvdata/qemuxml2argv-panic.args
c401cc
@@ -0,0 +1,6 @@
c401cc
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
c401cc
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
c401cc
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
c401cc
+-hda /dev/HostVG/QEMUGuest1 \
c401cc
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
c401cc
+-device pvpanic,ioport=1285
c401cc
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic.xml b/tests/qemuxml2argvdata/qemuxml2argv-panic.xml
c401cc
new file mode 100644
c401cc
index 0000000..e354511
c401cc
--- /dev/null
c401cc
+++ b/tests/qemuxml2argvdata/qemuxml2argv-panic.xml
c401cc
@@ -0,0 +1,31 @@
c401cc
+<domain type='qemu'>
c401cc
+  <name>QEMUGuest1</name>
c401cc
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
c401cc
+  <memory unit='KiB'>219136</memory>
c401cc
+  <currentMemory unit='KiB'>219136</currentMemory>
c401cc
+  <vcpu placement='static'>1</vcpu>
c401cc
+  <os>
c401cc
+    <type arch='i686' machine='pc'>hvm</type>
c401cc
+    <boot dev='hd'/>
c401cc
+  </os>
c401cc
+  <clock offset='utc'/>
c401cc
+  <on_poweroff>destroy</on_poweroff>
c401cc
+  <on_reboot>restart</on_reboot>
c401cc
+  <on_crash>destroy</on_crash>
c401cc
+  <devices>
c401cc
+    <emulator>/usr/bin/qemu</emulator>
c401cc
+    <disk type='block' device='disk'>
c401cc
+      <source dev='/dev/HostVG/QEMUGuest1'/>
c401cc
+      <target dev='hda' bus='ide'/>
c401cc
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
c401cc
+    </disk>
c401cc
+    <controller type='usb' index='0'/>
c401cc
+    <controller type='fdc' index='0'/>
c401cc
+    <controller type='ide' index='0'/>
c401cc
+    <controller type='pci' index='0' model='pci-root'/>
c401cc
+    <memballoon model='virtio'/>
c401cc
+    <panic>
c401cc
+      <address type='isa' iobase='0x505'/>
c401cc
+    </panic>
c401cc
+  </devices>
c401cc
+</domain>
c401cc
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c401cc
index 1beb49f..790d610 100644
c401cc
--- a/tests/qemuxml2argvtest.c
c401cc
+++ b/tests/qemuxml2argvtest.c
c401cc
@@ -1062,6 +1062,9 @@ mymain(void)
c401cc
     DO_TEST_PARSE_ERROR("pci-root-address",
c401cc
                         QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
c401cc
 
c401cc
+    DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
c401cc
+            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
c401cc
+
c401cc
     virObjectUnref(driver.config);
c401cc
     virObjectUnref(driver.caps);
c401cc
     virObjectUnref(driver.xmlopt);
c401cc
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
c401cc
index 4b6b01d..1f655ef 100644
c401cc
--- a/tests/qemuxml2xmltest.c
c401cc
+++ b/tests/qemuxml2xmltest.c
c401cc
@@ -315,6 +315,8 @@ mymain(void)
c401cc
 
c401cc
     DO_TEST_DIFFERENT("s390-defaultconsole");
c401cc
 
c401cc
+    DO_TEST("panic");
c401cc
+
c401cc
     virObjectUnref(driver.caps);
c401cc
     virObjectUnref(driver.xmlopt);
c401cc
 
c401cc
-- 
c401cc
1.8.5.1
c401cc