From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj7BW-0005AP-Ji for qemu-devel@nongnu.org; Fri, 17 Apr 2015 10:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yj7BS-0003C8-9a for qemu-devel@nongnu.org; Fri, 17 Apr 2015 10:23:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj7BS-0003C4-4h for qemu-devel@nongnu.org; Fri, 17 Apr 2015 10:23:54 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D24497D for ; Fri, 17 Apr 2015 14:23:53 +0000 (UTC) From: "Daniel P. Berrange" Date: Fri, 17 Apr 2015 15:22:06 +0100 Message-Id: <1429280557-8887-4-git-send-email-berrange@redhat.com> In-Reply-To: <1429280557-8887-1-git-send-email-berrange@redhat.com> References: <1429280557-8887-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v1 RFC 03/34] qom: create objects in two phases List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Gerd Hoffmann , Stefan Hajnoczi 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 in the first phase, and only delay those which have a dependency on the chardevs. Hopefully the set which need delaying will remain small. Signed-off-by: Daniel P. Berrange --- vl.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 74c2681..8aac4ee 100644 --- a/vl.c +++ b/vl.c @@ -2591,6 +2591,22 @@ static int machine_set_property(const char *name, const char *value, return 0; } + +static bool object_create_phase1(const char *type) +{ + /* rng-egd requires that -chardev is processed first, + * so we must delay it until phase2 */ + if (g_str_equal(type, "rng-egd")) { + return false; + } + return true; +} + +static bool object_create_phase2(const char *type) +{ + return !object_create_phase1(type); +} + static int object_create(QemuOpts *opts, void *opaque) { Error *err = NULL; @@ -2599,6 +2615,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); @@ -2613,6 +2630,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); @@ -4008,6 +4028,12 @@ int main(int argc, char **argv, char **envp) socket_init(); + if (qemu_opts_foreach(qemu_find_opts("object"), + object_create, + object_create_phase1, 0) != 0) { + exit(1); + } + if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0) exit(1); #ifdef CONFIG_VIRTFS @@ -4027,7 +4053,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_phase2, 0) != 0) { exit(1); } -- 2.1.0