qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: "Alexey Kardashevskiy" <aik@ozlabs.ru>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-ppc@nongnu.org, "Alexander Graf" <agraf@suse.de>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH v3 4/5] qdev: introduce get_fw_dev_path() callback
Date: Tue, 10 Dec 2013 18:32:36 +1100	[thread overview]
Message-ID: <1386660757-7505-5-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1386660757-7505-1-git-send-email-aik@ozlabs.ru>

QEMU supports firmware names for all devices in the QEMU tree but
some architectures expect some parts of firmware path names in different
format.

This introduces a firmware-pathname-change interface definition.
If some machines needs to redefine the firmware path format, it has
to add a child object to the /machine object with the "machine-fw-path"
interface defines.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v3:
* QEMUMachine callback is replaced with an interface so the @current_machine
symbol is no more required
---
 hw/core/qdev.c         | 35 ++++++++++++++++++++++++++++++++++-
 include/hw/qdev-core.h | 15 +++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index e374a93..4675d68 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -497,6 +497,36 @@ static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
     return NULL;
 }
 
+typedef struct FWPathInterfaceSearch {
+    BusState *bus;
+    DeviceState *dev;
+    char *ret;
+} FWPathInterfaceSearch;
+
+static int qdev_machine_try_get_fwpath(Object *o, void *opaque)
+{
+    FWPathInterfaceSearch *p = opaque;
+    ObjectClass *oc = object_get_class(o);
+    MachineFWPathClass *c = (MachineFWPathClass *)
+        object_class_dynamic_cast(oc, TYPE_MACHINE_FWPATH);
+
+    if (c && c->get_fw_dev_path) {
+        p->ret = c->get_fw_dev_path(p->bus, p->dev);
+        return 1;
+    }
+
+    return 0;
+}
+
+static char *machine_get_fw_dev_path(BusState *bus, DeviceState *dev)
+{
+    FWPathInterfaceSearch p = { bus, dev, NULL };
+
+    object_child_foreach(qdev_get_machine(), qdev_machine_try_get_fwpath, &p);
+
+    return p.ret;
+}
+
 static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
 {
     int l = 0;
@@ -504,7 +534,10 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
     if (dev && dev->parent_bus) {
         char *d;
         l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
-        d = bus_get_fw_dev_path(dev->parent_bus, dev);
+        d = machine_get_fw_dev_path(dev->parent_bus, dev);
+        if (!d) {
+            d = bus_get_fw_dev_path(dev->parent_bus, dev);
+        }
         if (d) {
             l += snprintf(p + l, size - l, "%s", d);
             g_free(d);
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index f2043a6..49892fb 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -307,4 +307,19 @@ extern int qdev_hotplug;
 
 char *qdev_get_dev_path(DeviceState *dev);
 
+/*
+ * Definition of a "get firmware patch" interface
+ */
+#define TYPE_MACHINE_FWPATH "machine-fw-path"
+
+#define MACHINE_FWPATH_CLASS(klass) \
+     OBJECT_CLASS_CHECK(MachineFWPathClass, (klass), TYPE_MACHINE_FWPATH)
+
+typedef struct MachineFWPathClass {
+    /* private */
+    InterfaceClass parent;
+    /* public */
+    char *(*get_fw_dev_path)(BusState *bus, DeviceState *dev);
+} MachineFWPathClass;
+
 #endif
-- 
1.8.4.rc4

  parent reply	other threads:[~2013-12-10  7:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10  7:32 [Qemu-devel] [PATCH v3 0/5] spapr: add bootindex support Alexey Kardashevskiy
2013-12-10  7:32 ` [Qemu-devel] [PATCH v3 1/5] boot: extend get_boot_devices_list() to ignore suffixes Alexey Kardashevskiy
2013-12-10  9:21   ` Paolo Bonzini
2013-12-11  3:56     ` Alexey Kardashevskiy
2013-12-10  7:32 ` [Qemu-devel] [PATCH v3 2/5] spapr-llan: add to boot device list Alexey Kardashevskiy
2013-12-10  7:32 ` [Qemu-devel] [PATCH v3 3/5] spapr-vio: fix firmware names Alexey Kardashevskiy
2013-12-10  7:32 ` Alexey Kardashevskiy [this message]
2013-12-10  7:32 ` [Qemu-devel] [PATCH v3 5/5] spapr: define interface to fix device pathname Alexey Kardashevskiy

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=1386660757-7505-5-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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).