qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Stefano Stabellini" <stefano.stabellini@eu.citrix.com>,
	"Hu Tao" <hutao@cn.fujitsu.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Paul Durrant" <Paul.Durrant@citrix.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Laszlo Ersek" <lersek@redhat.com>,
	=?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH v3 07/18] pvpanic: initialization cleanup
Date: Thu, 4 Jul 2013 12:12:58 +0300	[thread overview]
Message-ID: <1372928939-2712-8-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1372928939-2712-1-git-send-email-mst@redhat.com>

Avoid use of static variables: PC systems
initialize pvpanic device through pvpanic_init,
so we can simply create the fw_cfg file at that point.
This also makes it possible to skip device
creation completely if fw_cfg is not there, e.g. for xen -
so the ports it reserves are not discoverable by guests.

Also, make pvpanic_init void since callers ignore return
status anyway.

Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Paul Durrant <Paul.Durrant@citrix.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pvpanic.c    | 30 ++++++++++++++++--------------
 include/hw/i386/pc.h |  2 +-
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 060099b..83ed226 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -97,26 +97,28 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 {
     ISADevice *d = ISA_DEVICE(dev);
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
-    static bool port_configured;
-    FWCfgState *fw_cfg;
 
     isa_register_ioport(d, &s->io, s->ioport);
+}
 
-    if (!port_configured) {
-        fw_cfg = fw_cfg_find();
-        if (fw_cfg) {
-            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
-                            g_memdup(&s->ioport, sizeof(s->ioport)),
-                            sizeof(s->ioport));
-            port_configured = true;
-        }
-    }
+static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg)
+{
+    PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
+
+    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
+                    g_memdup(&s->ioport, sizeof(s->ioport)),
+                    sizeof(s->ioport));
 }
 
-int pvpanic_init(ISABus *bus)
+void pvpanic_init(ISABus *bus)
 {
-    isa_create_simple(bus, TYPE_ISA_PVPANIC_DEVICE);
-    return 0;
+    ISADevice *dev;
+    FWCfgState *fw_cfg = fw_cfg_find();
+    if (!fw_cfg) {
+        return;
+    }
+    dev = isa_create_simple (bus, TYPE_ISA_PVPANIC_DEVICE);
+    pvpanic_fw_cfg(dev, fw_cfg);
 }
 
 static Property pvpanic_isa_properties[] = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index dbdd523..5949e7e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -193,7 +193,7 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
 void pc_system_firmware_init(MemoryRegion *rom_memory);
 
 /* pvpanic.c */
-int pvpanic_init(ISABus *bus);
+void pvpanic_init(ISABus *bus);
 
 /* e820 types */
 #define E820_RAM        1
-- 
MST

  parent reply	other threads:[~2013-07-04  9:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-04  9:12 [Qemu-devel] [PULL v3 00/18] pci,misc enhancements Michael S. Tsirkin
2013-07-04  9:12 ` [Qemu-devel] [PATCH v3 01/18] range: add Range structure Michael S. Tsirkin
2013-07-04  9:12 ` [Qemu-devel] [PATCH v3 02/18] pci: store PCI hole ranges in guestinfo structure Michael S. Tsirkin
2013-07-04  9:12 ` [Qemu-devel] [PATCH v3 03/18] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
2013-07-04  9:12 ` [Qemu-devel] [PATCH v3 04/18] pc_piix: cleanup init compat handling Michael S. Tsirkin
2013-07-04  9:12 ` [Qemu-devel] [PATCH v3 05/18] e1000: cleanup process_tx_desc Michael S. Tsirkin
2013-07-04  9:12 ` [Qemu-devel] [PATCH v3 06/18] MAINTAINERS: s/Marcelo/Paolo/ Michael S. Tsirkin
2013-07-04  9:12 ` Michael S. Tsirkin [this message]
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 08/18] pvpanic: fix fwcfg for big endian hosts Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 09/18] pci: Cleanup configuration for pci-hotplug.c Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 10/18] pci: Move pci_read_devaddr to pci-hotplug-old.c Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 11/18] pci: Abolish pci_find_root_bus() Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 12/18] pci: Use helper to find device's root bus in pci_find_domain() Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 13/18] pci: Replace pci_find_domain() with more general pci_root_bus_path() Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 14/18] pci: Add root bus argument to pci_get_bus_devfn() Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 15/18] pci: Add root bus parameter to pci_nic_init() Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 16/18] pci: Simpler implementation of primary PCI bus Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 17/18] pci: Remove domain from PCIHostBus Michael S. Tsirkin
2013-07-04  9:13 ` [Qemu-devel] [PATCH v3 18/18] pci: Fold host_buses list into PCIHostState functionality Michael S. Tsirkin
2013-07-07 16:27 ` [Qemu-devel] [PULL v3 00/18] pci,misc enhancements Anthony Liguori
2013-07-07 20:08   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372928939-2712-8-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).