From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: "Alistair Francis" <alistair.francis@xilinx.com>,
"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
"Andreas Färber" <afaerber@suse.de>,
"Igor Mammedov" <imammedo@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Sascha Silbe" <silbe@linux.vnet.ibm.com>,
"Alexander Graf" <agraf@suse.de>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Fam Zheng" <famz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 1/6] qom: introduce TypeInfo name aliases
Date: Thu, 4 Jan 2018 11:40:41 -0300 [thread overview]
Message-ID: <20180104144046.30793-2-f4bug@amsat.org> (raw)
In-Reply-To: <20180104144046.30793-1-f4bug@amsat.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/qom/object.h | 3 +++
qom/object.c | 18 ++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index dc73d59660..5d6e8795d4 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -428,6 +428,8 @@ struct Object
* TypeInfo:
* @name: The name of the type.
* @parent: The name of the parent type.
+ * @aliases: A list of alias names for the type. This should point to a static
+ * array that's terminated with a zero filled element.
* @instance_size: The size of the object (derivative of #Object). If
* @instance_size is 0, then the size of the object will be the size of the
* parent object.
@@ -468,6 +470,7 @@ struct TypeInfo
{
const char *name;
const char *parent;
+ const char **aliases;
size_t instance_size;
void (*instance_init)(Object *obj);
diff --git a/qom/object.c b/qom/object.c
index c58c52d518..c532a8aa65 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -83,10 +83,15 @@ static GHashTable *type_table_get(void)
static bool enumerating_types;
-static void type_table_add(TypeImpl *ti)
+static void type_table_add_with_key(TypeImpl *ti, const char *key_name)
{
assert(!enumerating_types);
- g_hash_table_insert(type_table_get(), (void *)ti->name, ti);
+ g_hash_table_insert(type_table_get(), (void *)key_name, ti);
+}
+
+static void type_table_add(TypeImpl *ti)
+{
+ type_table_add_with_key(ti, ti->name);
}
static TypeImpl *type_table_lookup(const char *name)
@@ -137,6 +142,15 @@ static TypeImpl *type_register_internal(const TypeInfo *info)
ti = type_new(info);
type_table_add(ti);
+
+ if (info->aliases) {
+ int i;
+
+ for (i = 0; info->aliases[i]; i++) {
+ type_table_add_with_key(ti, info->aliases[i]);
+ }
+ }
+
return ti;
}
--
2.15.1
next prev parent reply other threads:[~2018-01-04 14:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-04 14:40 [Qemu-devel] [RFC PATCH 0/6] qom: introduce TypeInfo name aliases Philippe Mathieu-Daudé
2018-01-04 14:40 ` Philippe Mathieu-Daudé [this message]
2018-01-04 14:40 ` [Qemu-devel] [RFC PATCH 2/6] hw/net/e1000: real device name is 'e1000-82540em', 'e1000' is an alias Philippe Mathieu-Daudé
2018-01-04 16:24 ` Dr. David Alan Gilbert
2018-01-04 16:34 ` Philippe Mathieu-Daudé
2018-01-04 16:41 ` Dr. David Alan Gilbert
2018-01-04 14:40 ` [Qemu-devel] [RFC PATCH 3/6] hw/char/cadence_uart: add FDT aliases Philippe Mathieu-Daudé
2018-01-06 2:19 ` Alistair Francis
2018-01-04 14:40 ` [Qemu-devel] [RFC PATCH 4/6] arm/xlnx-zynq: use FDT names for the Cadence UART Philippe Mathieu-Daudé
2018-01-06 2:20 ` Alistair Francis
2018-01-08 12:54 ` Igor Mammedov
2018-01-08 13:17 ` Thomas Huth
2018-01-08 13:51 ` Philippe Mathieu-Daudé
2018-01-08 14:01 ` Igor Mammedov
2018-01-04 14:40 ` [Qemu-devel] [RFC PATCH 5/6] hw/net/cadence_gem: add FDT names as alias Philippe Mathieu-Daudé
2018-01-06 2:20 ` Alistair Francis
2018-01-04 14:40 ` [Qemu-devel] [RFC PATCH 6/6] hw/arm/xlnx-zynq: use FDT names for the Cadence GEM Philippe Mathieu-Daudé
2018-01-06 2:20 ` Alistair Francis
2018-01-04 19:22 ` [Qemu-devel] [RFC PATCH 0/6] qom: introduce TypeInfo name aliases Eduardo Habkost
2018-01-08 12:51 ` Igor Mammedov
2018-01-08 14:10 ` Philippe Mathieu-Daudé
2018-01-12 14:11 ` Eduardo Habkost
2018-01-08 16:12 ` Eduardo Habkost
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=20180104144046.30793-2-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=alistair.francis@xilinx.com \
--cc=armbru@redhat.com \
--cc=crosthwaite.peter@gmail.com \
--cc=edgar.iglesias@xilinx.com \
--cc=ehabkost@redhat.com \
--cc=famz@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=silbe@linux.vnet.ibm.com \
--cc=stefanha@redhat.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).