From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqjP6-0007ix-2j for qemu-devel@nongnu.org; Fri, 08 May 2015 10:37:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqjP0-0001qK-BF for qemu-devel@nongnu.org; Fri, 08 May 2015 10:37:28 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34952 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqjOz-0001q6-V9 for qemu-devel@nongnu.org; Fri, 08 May 2015 10:37:22 -0400 Message-ID: <554CCA21.8000100@suse.de> Date: Fri, 08 May 2015 16:37:21 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1430476206-26034-1-git-send-email-berrange@redhat.com> <1430476206-26034-4-git-send-email-berrange@redhat.com> In-Reply-To: <1430476206-26034-4-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 3/7] qom: create objects in two phases List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Paolo Bonzini Hi, Can we *please* find a better subject for this? To me, creating QOM objects in two phases is about instance_init vs. realize, and thus I was pretty upset that Paolo dared to apply this without asking me first. Am 01.05.2015 um 12:30 schrieb Daniel P. Berrange: > 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 > in the first phase, and only delay those which have a dependency on > the chardevs. Hopefully the set which need delaying will remain > small. >=20 > Signed-off-by: Daniel P. Berrange > --- > vl.c | 40 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) >=20 > diff --git a/vl.c b/vl.c > index 74c2681..ee2f70a 100644 > --- a/vl.c > +++ b/vl.c > @@ -2591,6 +2591,33 @@ static int machine_set_property(const char *name= , const char *value, > return 0; > } > =20 > + > +/** Accidental documentation comment? > + * 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; > +} > + > + > +/** Ditto? > + * 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 =3D NULL; > @@ -2599,6 +2626,7 @@ static int object_create(QemuOpts *opts, void *op= aque) > void *dummy =3D NULL; > OptsVisitor *ov; > QDict *pdict; > + bool (*type_predicate)(const char *) =3D opaque; > =20 > ov =3D opts_visitor_new(opts); > pdict =3D qemu_opts_to_qdict(opts, NULL); > @@ -2613,6 +2641,9 @@ static int object_create(QemuOpts *opts, void *op= aque) > if (err) { > goto out; > } > + if (!type_predicate(type)) { > + goto out; > + } > =20 > qdict_del(pdict, "id"); > visit_type_str(opts_get_visitor(ov), &id, "id", &err); > @@ -4008,6 +4039,12 @@ int main(int argc, char **argv, char **envp) > =20 > socket_init(); > =20 > + if (qemu_opts_foreach(qemu_find_opts("object"), > + object_create, > + object_create_initial, 0) !=3D 0) { > + exit(1); > + } > + > if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func= , NULL, 1) !=3D 0) > exit(1); > #ifdef CONFIG_VIRTFS > @@ -4027,7 +4064,8 @@ int main(int argc, char **argv, char **envp) > } > =20 > if (qemu_opts_foreach(qemu_find_opts("object"), > - object_create, NULL, 0) !=3D 0) { > + object_create, > + object_create_delayed, 0) !=3D 0) { > exit(1); > } > =20 Otherwise looks okay and there's a pattern emerging of "not qom:". Regards, Andreas --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Felix Imend=F6rffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG N=FCrnberg)