qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PULL 12/12] qom: Add object_property_add_const_link()
Date: Wed, 20 May 2015 17:51:46 +0200	[thread overview]
Message-ID: <1432137106-8295-13-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1432137106-8295-1-git-send-email-afaerber@suse.de>

From: Paolo Bonzini <pbonzini@redhat.com>

This helper adds a read-only link<> property.

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 16 ++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 270a3ef..e8fb863 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1449,6 +1449,24 @@ void object_property_add_alias(Object *obj, const char *name,
                                Error **errp);
 
 /**
+ * object_property_add_const_link:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @target: the object to be referred by the link
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add an unmodifiable link for a property on an object.  This function will
+ * add a property of type link<TYPE> where TYPE is the type of @target.
+ *
+ * The caller must ensure that @target stays alive as long as
+ * this property exists.  In the case @target is a child of @obj,
+ * this will be the case.  Otherwise, the caller is responsible for
+ * taking a reference.
+ */
+void object_property_add_const_link(Object *obj, const char *name,
+                                    Object *target, Error **errp);
+
+/**
  * object_property_set_description:
  * @obj: the object owning the property
  * @name: the name of the property
diff --git a/qom/object.c b/qom/object.c
index f1b289c..8f0d8a7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1386,6 +1386,22 @@ out:
     g_free(full_type);
 }
 
+void object_property_add_const_link(Object *obj, const char *name,
+                                    Object *target, Error **errp)
+{
+    char *link_type;
+    ObjectProperty *op;
+
+    link_type = g_strdup_printf("link<%s>", object_get_typename(target));
+    op = object_property_add(obj, name, link_type,
+                             object_get_child_property, NULL,
+                             NULL, target, errp);
+    if (op != NULL) {
+        op->resolve = object_resolve_child_property;
+    }
+    g_free(link_type);
+}
+
 gchar *object_get_canonical_path_component(Object *obj)
 {
     ObjectProperty *prop = NULL;
-- 
2.1.4

  parent reply	other threads:[~2015-05-20 15:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20 15:51 [Qemu-devel] [PULL 00/12] QOM devices patch queue 2015-05-20 Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 01/12] qom: strdup() target property name on object_property_add_alias() Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 02/12] qdev: Free property names after registering gpio aliases Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 03/12] tests: Use qtest_add_data_func() consistently Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 04/12] scripts: Add support for path as argument of qom-tree Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 05/12] backends: Fix typename of 'policy' enum property in hostmem obj Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 06/12] doc: Document user creatable object types in help text Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 07/12] vl: Create (most) objects before creating chardev backends Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 08/12] qom: Add helper method for getting user objects root Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 09/12] qom: Add object_new_with_props() / object_new_withpropv() helpers Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 10/12] qom: Make enum string tables const-correct Andreas Färber
2015-05-20 15:51 ` [Qemu-devel] [PULL 11/12] qom: Add an object_property_add_enum() helper function Andreas Färber
2015-05-20 15:51 ` Andreas Färber [this message]
2015-05-21 11:18 ` [Qemu-devel] [PULL 00/12] QOM devices patch queue 2015-05-20 Peter Maydell
2015-05-21 11:53   ` Daniel P. Berrange
2015-05-27 18:16     ` Andreas Färber
2015-05-29 13:51       ` Daniel P. Berrange
2015-05-29 13:57         ` Peter Maydell
2015-05-29 14:08           ` Daniel P. Berrange
2015-05-29 14:14             ` Peter Maydell

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=1432137106-8295-13-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=pbonzini@redhat.com \
    --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 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).