yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
5d360b
From 9d150071a8170807a0e5f638e3eddbbc29219ddc Mon Sep 17 00:00:00 2001
5d360b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
5d360b
Date: Wed, 13 Dec 2017 13:38:45 +0100
5d360b
Subject: [PATCH 14/41] fw_cfg: enable DMA if -device vmcoreinfo
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: <20171213133912.26176-15-marcandre.lureau@redhat.com>
5d360b
Patchwork-id: 78364
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 14/41] fw_cfg: enable DMA if -device vmcoreinfo
5d360b
Bugzilla: 1411490
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
Upstream status: RHEL-only
5d360b
5d360b
vmcoreinfo needs fw_cfg with DMA enabled. However, for compatibility
5d360b
reasons, DMA can't be enabled by default. In order to avoid having a
5d360b
RHEL-specific libvirt patch to enable DMA when vmcoreinfo device is
5d360b
requested, it can be done in qemu directly.
5d360b
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 hw/nvram/fw_cfg.c | 17 +++++++++++++++++
5d360b
 1 file changed, 17 insertions(+)
5d360b
5d360b
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
5d360b
index 616c782..7caf43c 100644
5d360b
--- a/hw/nvram/fw_cfg.c
5d360b
+++ b/hw/nvram/fw_cfg.c
5d360b
@@ -30,6 +30,7 @@
5d360b
 #include "trace.h"
5d360b
 #include "qemu/error-report.h"
5d360b
 #include "qemu/config-file.h"
5d360b
+#include "qemu/option.h"
5d360b
 
5d360b
 #define FW_CFG_CTL_SIZE 2
5d360b
 #define FW_CFG_DATA_SIZE 1
5d360b
@@ -675,6 +676,17 @@ static void fw_cfg_machine_ready(struct Notifier *n, void *data)
5d360b
     fw_cfg_add_file(s, "bootorder", (uint8_t*)bootindex, len);
5d360b
 }
5d360b
 
5d360b
+static int driver_is_vmcoreinfo(QemuOpts *opts, void *opaque)
5d360b
+{
5d360b
+    return g_strcmp0(qemu_opt_get(opts, "driver"), "vmcoreinfo") == 0;
5d360b
+}
5d360b
+
5d360b
+static bool opts_has_vmcoreinfo(void)
5d360b
+{
5d360b
+    return qemu_opts_foreach(qemu_find_opts("device"),
5d360b
+                             driver_is_vmcoreinfo, NULL, 1) != 0;
5d360b
+}
5d360b
+
5d360b
 static FWCfgState *
5d360b
 fw_cfg_init_dma(uint32_t ctl_port, uint32_t data_port,
5d360b
                 uint32_t dma_port,
5d360b
@@ -692,6 +704,11 @@ fw_cfg_init_dma(uint32_t ctl_port, uint32_t data_port,
5d360b
     qdev_prop_set_uint32(dev, "data_iobase", data_port);
5d360b
     qdev_prop_set_uint32(dev, "dma_iobase", dma_port);
5d360b
 
5d360b
+    if (opts_has_vmcoreinfo()) {
5d360b
+        /* RHEL-only: enable DMA operations for vmcoreinfo device */
5d360b
+        qdev_prop_set_bit(dev, "dma_enabled", true);
5d360b
+    }
5d360b
+
5d360b
     if (!dma_requested) {
5d360b
         qdev_prop_set_bit(dev, "dma_enabled", false);
5d360b
     }
5d360b
-- 
5d360b
1.8.3.1
5d360b