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 v3 07/14] vl: Create (most) objects before creating chardev backends
Date: Fri, 19 Jun 2015 19:24:40 +0200	[thread overview]
Message-ID: <1434734687-5578-8-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1434734687-5578-1-git-send-email-afaerber@suse.de>

From: "Daniel P. Berrange" <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>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index 2201e27..c839071 100644
--- a/vl.c
+++ b/vl.c
@@ -2671,6 +2671,33 @@ static int machine_set_property(void *opaque,
     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(void *opaque, QemuOpts *opts, Error **errp)
 {
     Error *err = NULL;
@@ -2679,6 +2706,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp)
     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);
@@ -2693,6 +2721,9 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp)
     if (err) {
         goto out;
     }
+    if (!type_predicate(type)) {
+        goto out;
+    }
 
     qdict_del(pdict, "id");
     visit_type_str(opts_get_visitor(ov), &id, "id", &err);
@@ -4114,6 +4145,12 @@ int main(int argc, char **argv, char **envp)
 
     socket_init();
 
+    if (qemu_opts_foreach(qemu_find_opts("object"),
+                          object_create,
+                          object_create_initial, NULL)) {
+        exit(1);
+    }
+
     if (qemu_opts_foreach(qemu_find_opts("chardev"),
                           chardev_init_func, NULL, NULL)) {
         exit(1);
@@ -4137,7 +4174,8 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (qemu_opts_foreach(qemu_find_opts("object"),
-                          object_create, NULL, NULL)) {
+                          object_create,
+                          object_create_delayed, NULL)) {
         exit(1);
     }
 
-- 
2.1.4

  parent reply	other threads:[~2015-06-19 17:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19 17:24 [Qemu-devel] [PULL v2 00/14] QOM devices patch queue 2015-06-19 Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 01/14] qom: strdup() target property name on object_property_add_alias() Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 02/14] qdev: Free property names after registering gpio aliases Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 03/14] tests: Use qtest_add_data_func() consistently Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 04/14] scripts: Add support for path as argument of qom-tree Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 05/14] backends: Fix typename of 'policy' enum property in hostmem obj Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 06/14] doc: Document user creatable object types in help text Andreas Färber
2015-06-19 17:24 ` Andreas Färber [this message]
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 08/14] qom: Add helper function for getting user objects root Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 09/14] qom: Add object_new_with_props() / object_new_withpropv() helpers Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 10/14] qom: Make enum string tables const-correct Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 11/14] qom: Add an object_property_add_enum() helper function Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 12/14] qom: Don't pass string table to object_get_enum() function Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 13/14] qdev: Deprecated qdev_init() is finally unused, drop Andreas Färber
2015-06-19 17:24 ` [Qemu-devel] [PULL v3 14/14] qdev: Un-deprecate qdev_init_nofail() Andreas Färber
2015-06-22 13:42 ` [Qemu-devel] [PULL v2 00/14] QOM devices patch queue 2015-06-19 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=1434734687-5578-8-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).