From: Paolo Bonzini <pbonzini@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
mimu@linux.vnet.ibm.com, agraf@suse.de, borntraeger@de.ibm.com,
bharata@linux.vnet.ibm.com, cornelia.huck@de.ibm.com,
"Igor Mammedov" <imammedo@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [PATCH v2 1/2] qom: Implement object_property_add_const_link()
Date: Fri, 01 May 2015 20:15:24 +0200 [thread overview]
Message-ID: <5543C2BC.8020208@redhat.com> (raw)
In-Reply-To: <1430489347-13772-2-git-send-email-ehabkost@redhat.com>
On 01/05/2015 16:09, Eduardo Habkost wrote:
> +void object_property_add_const_link(Object *obj, const char *name,
> + const char *type, Object *child,
> + ObjectPropertyLinkFlags flags,
> + Error **errp)
> +{
> + Object **childp = g_new0(Object*, 1);
> +
> + *childp = child;
> + object_property_add_link(obj, name, type, childp, NULL,
> + flags | OBJ_PROP_LINK_FREE_CHILD_POINTER, errp);
> +}
> +
This works, but is the extra functionality needed, compared to
an alias? Namely, when is flags going to be != 0?
FWIW, here is my ./.. patch. I'm all for adding a helper like
object_property_add_const_link on top if we go for it.
Another possibility is to not introduce any of our patches and reuse
the child<> getter and resolve functions in
object_property_add_const_link.
-------------------- 8< ---------------
>From 653ca80e93fcaa94c7fa172edbaef75457d4952d Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 31 Mar 2015 13:56:24 +0200
Subject: [PATCH] qom: add . and .. properties
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qom/object.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/qom/object.c b/qom/object.c
index b8dff43..3dd87b7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1783,9 +1783,51 @@ void object_property_set_description(Object *obj, const char *name,
op->description = g_strdup(description);
}
+static void property_get_dot(Object *obj, struct Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ gchar *path = object_get_canonical_path(obj);
+ visit_type_str(v, &path, name, errp);
+ g_free(path);
+}
+
+static Object *property_resolve_dot(Object *obj, void *opaque,
+ const gchar *part)
+{
+ return obj;
+}
+
+static void property_get_dotdot(Object *obj, struct Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ if (obj->parent) {
+ gchar *path = object_get_canonical_path(obj);
+ visit_type_str(v, &path, name, errp);
+ g_free(path);
+ } else {
+ gchar *path = (gchar *)"";
+ visit_type_str(v, &path, name, errp);
+ }
+}
+
+static Object *property_resolve_dotdot(Object *obj, void *opaque,
+ const gchar *part)
+{
+ return obj->parent;
+}
+
static void object_instance_init(Object *obj)
{
+ ObjectProperty *op;
object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
+
+ op = object_property_add(obj, ".", "link<Object>", property_get_dot,
+ NULL, NULL, NULL, NULL);
+ op->resolve = property_resolve_dot;
+
+ op = object_property_add(obj, "..", "link<Object>", property_get_dotdot,
+ NULL, NULL, NULL, NULL);
+ op->resolve = property_resolve_dotdot;
}
static void register_types(void)
--
2.3.5
next prev parent reply other threads:[~2015-05-01 18:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 14:09 [Qemu-devel] [PATCH v2 0/2] cpu: Add /machine/cpus[<index>] links Eduardo Habkost
2015-05-01 14:09 ` [Qemu-devel] [PATCH v2 1/2] qom: Implement object_property_add_const_link() Eduardo Habkost
2015-05-01 18:15 ` Paolo Bonzini [this message]
2015-05-05 16:06 ` Eduardo Habkost
2015-05-05 16:21 ` Paolo Bonzini
2015-05-01 14:09 ` [Qemu-devel] [PATCH v2 2/2] cpu: Register QOM links at /machine/cpus[<index>] 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=5543C2BC.8020208@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=bharata@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mimu@linux.vnet.ibm.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.