From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNXp6-0006TT-0i for qemu-devel@nongnu.org; Thu, 14 Jul 2016 00:00:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNXp1-0000uf-6Q for qemu-devel@nongnu.org; Thu, 14 Jul 2016 00:00:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNXp0-0000ub-Tz for qemu-devel@nongnu.org; Thu, 14 Jul 2016 00:00:23 -0400 References: <1467724312-9378-1-git-send-email-berrange@redhat.com> <1467724312-9378-5-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <57870E55.1020205@redhat.com> Date: Wed, 13 Jul 2016 22:00:21 -0600 MIME-Version: 1.0 In-Reply-To: <1467724312-9378-5-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="U5b41WJkXrArdJS1SDfTHBhXX9oV0ANiC" Subject: Re: [Qemu-devel] [PATCH v7 4/7] qom: support arbitrary non-scalar properties with -object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Markus Armbruster , Max Reitz , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Paolo Bonzini , =?UTF-8?Q?Andreas_F=c3=a4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --U5b41WJkXrArdJS1SDfTHBhXX9oV0ANiC From: Eric Blake To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Markus Armbruster , Max Reitz , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Paolo Bonzini , =?UTF-8?Q?Andreas_F=c3=a4rber?= Message-ID: <57870E55.1020205@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 4/7] qom: support arbitrary non-scalar properties with -object References: <1467724312-9378-1-git-send-email-berrange@redhat.com> <1467724312-9378-5-git-send-email-berrange@redhat.com> In-Reply-To: <1467724312-9378-5-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/05/2016 07:11 AM, Daniel P. Berrange wrote: > The current -object command line syntax only allows for > creation of objects with scalar properties, or a list > with a fixed scalar element type. Objects which have > properties that are represented as structs in the QAPI > schema cannot be created using -object. >=20 > Thus -object can now support non-scalar properties, > for example the QMP object >=20 > { > "execute": "object-add", > "arguments": { > "qom-type": "demo", > "id": "demo0", > "parameters": { > "foo": [ > { "bar": "one", "wizz": "1" }, > { "bar": "two", "wizz": "2" } > ] > } > } > } >=20 > Would be creatable via the CLI now using >=20 > $QEMU \ > -object demo,id=3Ddemo0,\ > foo.0.bar=3Done,foo.0.wizz=3D1,\ > foo.1.bar=3Dtwo,foo.1.wizz=3D2 Overall, I like it. >=20 > Notice that this syntax is intentionally compatible > with that currently used by block drivers. And this gives me hope that someday we may replace blockdev-add from QemuOpts munging to direct QAPI type handling. Maybe :) But certainly not for 2.7. > @@ -1721,20 +1721,12 @@ void hmp_netdev_del(Monitor *mon, const QDict *= qdict) > void hmp_object_add(Monitor *mon, const QDict *qdict) > { > Error *err =3D NULL; > - QemuOpts *opts; > - OptsVisitor *ov; > + QmpInputVisitor *qiv; Will need rebasing now that some of my qapi cleanups have landed in master, and also depending on whether my adoption of your patch 3/7 in my 'qapi subset F' series also lands first, since I tweaked your string input visitor interface slightly. But the idea is right on track. > Object *obj =3D NULL; > =20 > - opts =3D qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &er= r); > - if (err) { > - hmp_handle_error(mon, &err); > - return; > - } > - > - ov =3D opts_visitor_new(opts); > - obj =3D user_creatable_add(qdict, opts_get_visitor(ov), &err); > - opts_visitor_cleanup(ov); > - qemu_opts_del(opts); > + qiv =3D qmp_string_input_visitor_new((QObject *)qdict, true); While this cast happens to work (because QDict currently has QObject as its first member), it is not necessarily safe to future layout changes, and you should probably be using QOBJECT(qdict) instead. > + obj =3D user_creatable_add(qdict, qmp_input_get_visitor(qiv), &err= ); > + qmp_input_visitor_cleanup(qiv); That looks so much simpler, even if it does need rebasing! --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --U5b41WJkXrArdJS1SDfTHBhXX9oV0ANiC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXhw5VAAoJEKeha0olJ0NqiHoH/iQJC/1VXq4n/N/KA97FEDeO /eOsQNvA/cq1HjYmHyLneE86NtPB3BnTzQMBh9WaN0QCtrvIE9wU17DOpmCMSgm/ xBoQttXzC4Pi1tzjKRdoGvPGeOa5J4SXW4TwGfUDKY9ioGaoHz2JH0T546ZaBBBC KF1p/T8wQx/77c56aCjohHACPFOMB9jPLin/KhYbSMzpqSCelK3ZT5R/ghIy7KuG ovca/OXuV3iFuXrU5zXPWHIeY7/HlkIJQ2BlItWogfNrtju1GKAIR+mzKGG9Gpe9 Wx0Y4f/54oZV3hT8hkGvw2G+GBWhBCt/ksKuz9XJvkZ9X2f1RoqHS36u/NATvxo= =mjEy -----END PGP SIGNATURE----- --U5b41WJkXrArdJS1SDfTHBhXX9oV0ANiC--