cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From b33784c26d96c3c020f4b0245f77731af3f88b8e Mon Sep 17 00:00:00 2001
218e99
From: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
Date: Wed, 6 Nov 2013 16:32:29 +0100
218e99
Subject: [PATCH 70/81] fw_cfg: add API to find FW cfg object
218e99
218e99
RH-Author: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
Message-id: <1383755557-21590-2-git-send-email-marcel.a@redhat.com>
218e99
Patchwork-id: 55546
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH v3 1/9] fw_cfg: add API to find FW cfg object
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
Remove some code duplication by adding a
218e99
function to look up the fw cfg file.
218e99
This way, we don't need to duplicate same strings everywhere.
218e99
Use by both fw cfg and pvpanic device.
218e99
218e99
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
218e99
(cherry picked from commit 600c60b76d0682f6c39d19bfff79da9321e8cf86)
218e99
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
---
218e99
 hw/misc/pvpanic.c         |  2 +-
218e99
 hw/nvram/fw_cfg.c         | 15 ++++++++++++---
218e99
 include/hw/nvram/fw_cfg.h |  2 ++
218e99
 3 files changed, 15 insertions(+), 4 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/misc/pvpanic.c         |    2 +-
218e99
 hw/nvram/fw_cfg.c         |   15 ++++++++++++---
218e99
 include/hw/nvram/fw_cfg.h |    2 ++
218e99
 3 files changed, 15 insertions(+), 4 deletions(-)
218e99
218e99
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
218e99
index 439d636..d17c3c9 100644
218e99
--- a/hw/misc/pvpanic.c
218e99
+++ b/hw/misc/pvpanic.c
218e99
@@ -96,7 +96,7 @@ static int pvpanic_isa_initfn(ISADevice *dev)
218e99
     isa_register_ioport(dev, &s->io, s->ioport);
218e99
 
218e99
     if (!port_configured) {
218e99
-        fw_cfg = object_resolve_path("/machine/fw_cfg", NULL);
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
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
218e99
index 3fa1488..064344d 100644
218e99
--- a/hw/nvram/fw_cfg.c
218e99
+++ b/hw/nvram/fw_cfg.c
218e99
@@ -32,6 +32,9 @@
218e99
 
218e99
 #define FW_CFG_SIZE 2
218e99
 #define FW_CFG_DATA_SIZE 1
218e99
+#define TYPE_FW_CFG "fw_cfg"
218e99
+#define FW_CFG_NAME "fw_cfg"
218e99
+#define FW_CFG_PATH "/machine/" FW_CFG_NAME
218e99
 
218e99
 typedef struct FWCfgEntry {
218e99
     uint32_t len;
218e99
@@ -493,8 +496,8 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
218e99
 
218e99
     s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
218e99
 
218e99
-    if (!object_resolve_path("/machine/fw_cfg", NULL)) {
218e99
-        object_property_add_child(qdev_get_machine(), "fw_cfg", OBJECT(s),
218e99
+    if (!object_resolve_path(FW_CFG_PATH, NULL)) {
218e99
+        object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s),
218e99
                                   NULL);
218e99
     }
218e99
 
218e99
@@ -553,6 +556,12 @@ static Property fw_cfg_properties[] = {
218e99
     DEFINE_PROP_END_OF_LIST(),
218e99
 };
218e99
 
218e99
+FWCfgState *fw_cfg_find(void)
218e99
+{
218e99
+    return OBJECT_CHECK(FWCfgState, object_resolve_path(FW_CFG_PATH, NULL),
218e99
+                        TYPE_FW_CFG);
218e99
+}
218e99
+
218e99
 static void fw_cfg_class_init(ObjectClass *klass, void *data)
218e99
 {
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
@@ -565,7 +574,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data)
218e99
 }
218e99
 
218e99
 static const TypeInfo fw_cfg_info = {
218e99
-    .name          = "fw_cfg",
218e99
+    .name          = TYPE_FW_CFG,
218e99
     .parent        = TYPE_SYS_BUS_DEVICE,
218e99
     .instance_size = sizeof(FWCfgState),
218e99
     .class_init    = fw_cfg_class_init,
218e99
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
218e99
index 3e4a334..48a8aa4 100644
218e99
--- a/include/hw/nvram/fw_cfg.h
218e99
+++ b/include/hw/nvram/fw_cfg.h
218e99
@@ -73,6 +73,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
218e99
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
218e99
                         hwaddr crl_addr, hwaddr data_addr);
218e99
 
218e99
+FWCfgState *fw_cfg_find(void);
218e99
+
218e99
 #endif /* NO_QEMU_PROTOS */
218e99
 
218e99
 #endif
218e99
-- 
218e99
1.7.1
218e99