From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5t8p-0007jW-RH for qemu-devel@nongnu.org; Fri, 19 Jun 2015 06:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5t8k-0008RN-RU for qemu-devel@nongnu.org; Fri, 19 Jun 2015 06:03:19 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34853 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5t8k-0008Qp-HE for qemu-devel@nongnu.org; Fri, 19 Jun 2015 06:03:14 -0400 Message-ID: <5583E8E1.7090604@suse.de> Date: Fri, 19 Jun 2015 12:03:13 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1432750824-27702-1-git-send-email-afaerber@suse.de> <1432750824-27702-8-git-send-email-afaerber@suse.de> In-Reply-To: <1432750824-27702-8-git-send-email-afaerber@suse.de> Content-Type: multipart/mixed; boundary="------------080102060005060808010105" Subject: Re: [Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Markus Armbruster This is a multi-part message in MIME format. --------------080102060005060808010105 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Am 27.05.2015 um 20:20 schrieb Andreas F=C3=A4rber: > From: "Daniel P. Berrange" >=20 > 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. >=20 > 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. >=20 > Signed-off-by: Daniel P. Berrange > Reviewed-by: Paolo Bonzini > Signed-off-by: Andreas F=C3=A4rber > --- > vl.c | 40 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) Rebasing my queue, I needed the attached changes to make it apply and build. Second pairs of eyes welcome. Regards, Andreas --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Dilip Upmanyu, Graham Norton; = HRB 21284 (AG N=C3=BCrnberg) --------------080102060005060808010105 Content-Type: text/x-patch; name="00.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="00.diff" diff --cc vl.c index 2201e27,b7c7511..0000000 --- a/vl.c +++ b/vl.c @@@ -2671,7 -2601,34 +2671,34 @@@ static int machine_set_property(void *o 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) +static int object_create(void *opaque, QemuOpts *opts, Error **errp) { Error *err = NULL; char *type = NULL; @@@ -4114,14 -4062,16 +4145,20 @@@ int main(int argc, char **argv, char ** socket_init(); + if (qemu_opts_foreach(qemu_find_opts("object"), + object_create, - object_create_initial, 0) != 0) { ++ object_create_initial, NULL)) { + exit(1); + } + - if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0) + if (qemu_opts_foreach(qemu_find_opts("chardev"), + chardev_init_func, NULL, NULL)) { exit(1); + } + #ifdef CONFIG_VIRTFS - if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) { + if (qemu_opts_foreach(qemu_find_opts("fsdev"), + fsdev_init_func, NULL, NULL)) { exit(1); } #endif @@@ -4137,7 -4087,8 +4174,8 @@@ } if (qemu_opts_foreach(qemu_find_opts("object"), - object_create, NULL, NULL)) { + object_create, - object_create_delayed, 0) != 0) { ++ object_create_delayed, NULL)) { exit(1); } --------------080102060005060808010105--