From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiOat-00059f-Vy for qemu-devel@nongnu.org; Tue, 22 Mar 2016 11:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiOas-0000Hb-SF for qemu-devel@nongnu.org; Tue, 22 Mar 2016 11:51:43 -0400 Date: Tue, 22 Mar 2016 15:51:28 +0000 From: "Daniel P. Berrange" Message-ID: <20160322155128.GJ25450@redhat.com> References: <1457635927-23045-1-git-send-email-berrange@redhat.com> <1457636396-24983-1-git-send-email-berrange@redhat.com> <1457636396-24983-3-git-send-email-berrange@redhat.com> <56F0835C.2020703@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56F0835C.2020703@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 03/10] qom: support arbitrary non-scalar properties with -object Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Paolo Bonzini , Max Reitz , Andreas =?utf-8?Q?F=C3=A4rber?= On Mon, Mar 21, 2016 at 05:27:24PM -0600, Eric Blake wrote: > On 03/10/2016 11:59 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 > > This is a design limitation of the way the OptsVisitor > > is written. It simply iterates over the QemuOpts values > > as a flat list. The support for lists is enabled by > > allowing the same key to be repeated in the opts string. > >=20 > > It is not practical to extend the OptsVisitor to support > > more complex data structures while also maintaining > > the existing list handling behaviour that is relied upon > > by other areas of QEMU. >=20 > Zolt=C3=A1n K=C5=91v=C3=A1g=C3=B3 tried earlier with his GSoC patches f= or the audio > subsystem last year, but those got stalled waiting for qapi enhancement= s > to go in. But I think your approach is indeed a bit nicer (rather than > making the warty OptsVisitor even wartier, just avoid it). My first attempt did indeed modify OptsVisitor, but I quickly abandoned it since it ended up being quite complex code to make it fit in with the pre-existing hack to supports lists of scalars in OptsVisitor. The QmpInputVisitor approach is cleaner and simpler overall > > 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 > >=20 > > This is also wired up to work for the 'object_add' command > > in the HMP monitor with the same syntax. > >=20 > > (hmp) object_add demo,id=3Ddemo0,\ > > foo.0.bar=3Done,foo.0.wizz=3D1,\ > > foo.1.bar=3Dtwo,foo.1.wizz=3D2 >=20 > Maybe mention that the indentation is not actually present in the real > command lines typed. Heh, yeah > > @@ -120,6 +120,7 @@ Object *user_creatable_add_type(const char *type,= const char *id, > > obj =3D object_new(type); > > if (qdict) { > > for (e =3D qdict_first(qdict); e; e =3D qdict_next(qdict, e)= ) { > > + > > object_property_set(obj, v, e->key, &local_err); > > if (local_err) { > > goto out; >=20 > Spurious hunk? Indeed Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|