cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From ed600bcecaa095b7cd0a6b5f52caaa3312fab840 Mon Sep 17 00:00:00 2001
218e99
From: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
Date: Wed, 6 Nov 2013 16:32:31 +0100
218e99
Subject: [PATCH 72/81] pvpanic: initialization cleanup
218e99
218e99
RH-Author: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
Message-id: <1383755557-21590-4-git-send-email-marcel.a@redhat.com>
218e99
Patchwork-id: 55548
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH v3 3/9] pvpanic: initialization cleanup
218e99
Bugzilla: 990601
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
218e99
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
218e99
218e99
From: "Michael S. Tsirkin" <mst@redhat.com>
218e99
218e99
Avoid use of static variables: PC systems
218e99
initialize pvpanic device through pvpanic_init,
218e99
so we can simply create the fw_cfg file at that point.
218e99
This also makes it possible to skip device
218e99
creation completely if fw_cfg is not there, e.g. for xen -
218e99
so the ports it reserves are not discoverable by guests.
218e99
218e99
Also, make pvpanic_init void since callers ignore return
218e99
status anyway.
218e99
218e99
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
218e99
Cc: Laszlo Ersek <lersek@redhat.com>
218e99
Cc: Paul Durrant <Paul.Durrant@citrix.com>
218e99
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
218e99
(cherry picked from commit bc3e6a0d6c8ab6cd7cd4b576ed567756f1dcabd2)
218e99
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
218e99
Conflicts:
218e99
	hw/misc/pvpanic.c
218e99
218e99
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
---
218e99
 hw/misc/pvpanic.c    | 32 +++++++++++++++++---------------
218e99
 include/hw/i386/pc.h |  2 +-
218e99
 2 files changed, 18 insertions(+), 16 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/misc/pvpanic.c    |   32 +++++++++++++++++---------------
218e99
 include/hw/i386/pc.h |    2 +-
218e99
 2 files changed, 18 insertions(+), 16 deletions(-)
218e99
218e99
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
218e99
index ddd8bdd..8263225 100644
218e99
--- a/hw/misc/pvpanic.c
218e99
+++ b/hw/misc/pvpanic.c
218e99
@@ -89,29 +89,31 @@ static const MemoryRegionOps pvpanic_ops = {
218e99
 static int pvpanic_isa_initfn(ISADevice *dev)
218e99
 {
218e99
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
218e99
-    static bool port_configured;
218e99
-    FWCfgState *fw_cfg;
218e99
 
218e99
     memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1);
218e99
     isa_register_ioport(dev, &s->io, s->ioport);
218e99
 
218e99
-    if (!port_configured) {
218e99
-        fw_cfg = fw_cfg_find();
218e99
-        if (fw_cfg) {
218e99
-            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
218e99
-                            g_memdup(&s->ioport, sizeof(s->ioport)),
218e99
-                            sizeof(s->ioport));
218e99
-            port_configured = true;
218e99
-        }
218e99
-    }
218e99
-
218e99
     return 0;
218e99
 }
218e99
 
218e99
-int pvpanic_init(ISABus *bus)
218e99
+static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg)
218e99
 {
218e99
-    isa_create_simple(bus, TYPE_ISA_PVPANIC_DEVICE);
218e99
-    return 0;
218e99
+    PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
218e99
+
218e99
+    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
218e99
+                    g_memdup(&s->ioport, sizeof(s->ioport)),
218e99
+                    sizeof(s->ioport));
218e99
+}
218e99
+
218e99
+void pvpanic_init(ISABus *bus)
218e99
+{
218e99
+    ISADevice *dev;
218e99
+    FWCfgState *fw_cfg = fw_cfg_find();
218e99
+    if (!fw_cfg) {
218e99
+        return;
218e99
+    }
218e99
+    dev = isa_create_simple (bus, TYPE_ISA_PVPANIC_DEVICE);
218e99
+    pvpanic_fw_cfg(dev, fw_cfg);
218e99
 }
218e99
 
218e99
 static Property pvpanic_isa_properties[] = {
218e99
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
218e99
index 45487ba..72f6882 100644
218e99
--- a/include/hw/i386/pc.h
218e99
+++ b/include/hw/i386/pc.h
218e99
@@ -175,7 +175,7 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
218e99
 void pc_system_firmware_init(MemoryRegion *rom_memory);
218e99
 
218e99
 /* pvpanic.c */
218e99
-int pvpanic_init(ISABus *bus);
218e99
+void pvpanic_init(ISABus *bus);
218e99
 
218e99
 /* e820 types */
218e99
 #define E820_RAM        1
218e99
-- 
218e99
1.7.1
218e99