From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH v5 3/8] vl: create (most) objects before creating chardev backends
Date: Wed, 27 May 2015 16:07:51 +0100 [thread overview]
Message-ID: <1432739276-10452-4-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1432739276-10452-1-git-send-email-berrange@redhat.com>
Some types of object must be created before chardevs, other types of
object must be created after chardevs. As such there is no option but
to create objects in two phases.
This takes the decision to create as many object types as possible
right away before anyother backends are created, and only delay
creation of those few which have an explicit dependency on the
chardevs. Hopefully the set which need delaying will remain small
over time.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/vl.c b/vl.c
index 15bccc4..b7c7511 100644
--- a/vl.c
+++ b/vl.c
@@ -2601,6 +2601,33 @@ static int machine_set_property(const char *name, const char *value,
return 0;
}
+
+/*
+ * Initial object creation happens before all other
+ * QEMU data types are created. The majority of objects
+ * can be created at this point. The rng-egd object
+ * cannot be created here, as it depends on the chardev
+ * already existing.
+ */
+static bool object_create_initial(const char *type)
+{
+ if (g_str_equal(type, "rng-egd")) {
+ return false;
+ }
+ return true;
+}
+
+
+/*
+ * The remainder of object creation happens after the
+ * creation of chardev, fsdev and device data types.
+ */
+static bool object_create_delayed(const char *type)
+{
+ return !object_create_initial(type);
+}
+
+
static int object_create(QemuOpts *opts, void *opaque)
{
Error *err = NULL;
@@ -2609,6 +2636,7 @@ static int object_create(QemuOpts *opts, void *opaque)
void *dummy = NULL;
OptsVisitor *ov;
QDict *pdict;
+ bool (*type_predicate)(const char *) = opaque;
ov = opts_visitor_new(opts);
pdict = qemu_opts_to_qdict(opts, NULL);
@@ -2623,6 +2651,9 @@ static int object_create(QemuOpts *opts, void *opaque)
if (err) {
goto out;
}
+ if (!type_predicate(type)) {
+ goto out;
+ }
qdict_del(pdict, "id");
visit_type_str(opts_get_visitor(ov), &id, "id", &err);
@@ -4031,6 +4062,12 @@ int main(int argc, char **argv, char **envp)
socket_init();
+ if (qemu_opts_foreach(qemu_find_opts("object"),
+ object_create,
+ object_create_initial, 0) != 0) {
+ exit(1);
+ }
+
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
@@ -4050,7 +4087,8 @@ int main(int argc, char **argv, char **envp)
}
if (qemu_opts_foreach(qemu_find_opts("object"),
- object_create, NULL, 0) != 0) {
+ object_create,
+ object_create_delayed, 0) != 0) {
exit(1);
}
--
2.4.1
next prev parent reply other threads:[~2015-05-27 15:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 15:07 [Qemu-devel] [PATCH v5 0/8] qom: misc fixes & enhancements to support TLS work Daniel P. Berrange
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 1/8] backends: fix typename of 'policy' enum property in hostmem obj Daniel P. Berrange
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 2/8] doc: document user creatable object types in help text Daniel P. Berrange
2015-05-27 15:07 ` Daniel P. Berrange [this message]
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 4/8] qom: add helper method for getting user objects root Daniel P. Berrange
2015-06-19 16:41 ` Andreas Färber
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 5/8] qom: add object_new_with_props / object_new_withpropv constructors Daniel P. Berrange
2015-06-19 16:04 ` Eric Blake
2015-06-19 16:08 ` Andreas Färber
2015-06-19 16:17 ` Eric Blake
2015-06-19 16:43 ` Andreas Färber
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 6/8] qom: make enum string tables const-correct Daniel P. Berrange
2015-06-19 16:05 ` Eric Blake
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 7/8] qom: add a object_property_add_enum helper method Daniel P. Berrange
2015-06-19 16:12 ` Eric Blake
2015-06-19 16:26 ` Andreas Färber
2015-06-19 16:38 ` Eric Blake
2015-06-19 16:44 ` Andreas Färber
2015-05-27 15:07 ` [Qemu-devel] [PATCH v5 8/8] qom: don't pass string table to object_get_enum method Daniel P. Berrange
2015-06-19 15:15 ` Andreas Färber
2015-06-19 16:15 ` Eric Blake
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=1432739276-10452-4-git-send-email-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=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).