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>,
	"Anthony Liguori" <anthony@codemonkey.ws>
Subject: [Qemu-devel] [PATCH RFC 2/3] qom: Introduce object_realize()
Date: Mon, 26 Mar 2012 15:46:51 +0200	[thread overview]
Message-ID: <1332769612-4247-3-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1332769612-4247-1-git-send-email-afaerber@suse.de>

Wrap setting of Object::realized property, error reporting and exit(1)
into a helper function.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Cc: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/object.h |    9 +++++++++
 qom/object.c          |   11 +++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/qemu/object.h b/include/qemu/object.h
index 742b5b6..dc8ae0f 100644
--- a/include/qemu/object.h
+++ b/include/qemu/object.h
@@ -467,6 +467,15 @@ void object_initialize_with_type(void *data, Type type);
 void object_initialize(void *obj, const char *typename);
 
 /**
+ * object_realize:
+ * @obj: The object to realize.
+ *
+ * This function will complete the initialization of an object based on
+ * properties set by setting the "realized" property to true.
+ */
+void object_realize(Object *obj);
+
+/**
  * object_finalize:
  * @obj: The object to finalize.
  *
diff --git a/qom/object.c b/qom/object.c
index ec143ad..33f6efc 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -327,6 +327,17 @@ void object_initialize(void *data, const char *typename)
     object_initialize_with_type(data, type);
 }
 
+void object_realize(Object *obj)
+{
+    Error *err = NULL;
+
+    object_property_set_bool(obj, true, "realized", &err);
+    if (error_is_set(&err)) {
+        qerror_report_err(err);
+        exit(1);
+    }
+}
+
 static void object_property_del_all(Object *obj)
 {
     while (!QTAILQ_EMPTY(&obj->properties)) {
-- 
1.7.7

  parent reply	other threads:[~2012-03-26 13:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 13:46 [Qemu-devel] [PATCH RFC 0/3] qom: Generalize qdev init to "realize" Andreas Färber
2012-03-26 13:46 ` [Qemu-devel] [PATCH RFC 1/3] qom: Add "realized" property to Object Andreas Färber
2012-03-26 15:07   ` Andreas Färber
2012-03-27  9:25   ` Stefan Hajnoczi
2012-03-26 13:46 ` Andreas Färber [this message]
2012-03-26 13:46 ` [Qemu-devel] [PATCH RFC 3/3] qdev: Hook up DeviceClass::init to ObjectClass::realize Andreas Färber
2012-03-26 13:54   ` Andreas Färber
2012-03-27 16:19 ` [Qemu-devel] [PATCH RFC 0/3] qom: Generalize qdev init to "realize" Paolo Bonzini
2012-03-27 16:28   ` Anthony Liguori
2012-03-27 16:33     ` Peter Maydell
2012-03-27 16:46       ` Paolo Bonzini
2012-03-27 18:56         ` Anthony Liguori
2012-03-27 16:41     ` Paolo Bonzini

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=1332769612-4247-3-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --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).