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