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] qdev: Realize on machine creation done
Date: Mon, 15 Jul 2013 15:40:38 +0200 [thread overview]
Message-ID: <1373895639-21476-3-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1373895639-21476-1-git-send-email-afaerber@suse.de>
As a preparation for Anthony's targetted late realization of devices,
iterate /machine children in qdev_machine_creation_done() and set
realized = true for devices.
Suggested-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/core/qdev.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 33e874a..ec621cd 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -332,8 +332,37 @@ void qdev_free(DeviceState *dev)
object_unparent(OBJECT(dev));
}
+static int object_realize_one(Object *obj, void *opaque)
+{
+ Error **errp = opaque;
+
+ if (object_dynamic_cast(obj, TYPE_DEVICE)) {
+ Error *err = NULL;
+
+ object_property_set_bool(obj, true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return -1;
+ }
+ return 0;
+ } else {
+ return object_child_foreach(obj, object_realize_one, opaque);
+ }
+}
+
void qdev_machine_creation_done(void)
{
+ Error *err = NULL;
+
+ object_child_foreach(qdev_get_machine(), object_realize_one, &err);
+ if (err != NULL) {
+ qerror_report_err(err);
+ error_free(err);
+ /* In the future we may want to let the user address any errors
+ * via QMP, but for now there's not much we can do here. */
+ exit(1);
+ }
+
/*
* ok, initial machine setup is done, starting from now we can
* only create hotpluggable devices
--
1.8.1.4
next prev parent reply other threads:[~2013-07-15 13:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-15 13:40 [Qemu-devel] [PATCH RFC 0/3] Recursive QOM realize Andreas Färber
2013-07-15 13:40 ` [Qemu-devel] [PATCH RFC 1/3] qdev: Add support for recursive realization Andreas Färber
2013-07-15 13:40 ` Andreas Färber [this message]
2013-07-15 13:40 ` [Qemu-devel] [PATCH RFC 3/3] qdev: Assert no new devices get created during realization Andreas Färber
2013-07-15 14:43 ` [Qemu-devel] [PATCH RFC 0/3] Recursive QOM realize Paolo Bonzini
2013-07-15 15:06 ` Andreas Färber
2013-07-15 15:37 ` Paolo Bonzini
2013-07-16 12:19 ` Andreas Färber
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=1373895639-21476-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).