From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWoXw-0000Fm-DK for qemu-devel@nongnu.org; Fri, 19 Feb 2016 12:08:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWoXs-0000oG-GA for qemu-devel@nongnu.org; Fri, 19 Feb 2016 12:08:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWoXs-0000o4-8Z for qemu-devel@nongnu.org; Fri, 19 Feb 2016 12:08:44 -0500 Date: Fri, 19 Feb 2016 17:08:39 +0000 From: "Daniel P. Berrange" Message-ID: <20160219170839.GF12919@redhat.com> References: <1455900463-16007-1-git-send-email-berrange@redhat.com> <1455900463-16007-2-git-send-email-berrange@redhat.com> <56C74A53.20608@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56C74A53.20608@redhat.com> Subject: Re: [Qemu-devel] [PATCH v1 01/10] qdict: implement a qdict_crumple method for un-flattening a dict Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Paolo Bonzini , qemu-devel@nongnu.org, Andreas =?utf-8?Q?F=C3=A4rber?= , Markus Armbruster On Fri, Feb 19, 2016 at 10:01:07AM -0700, Eric Blake wrote: > On 02/19/2016 09:47 AM, Daniel P. Berrange wrote: > > The qdict_flatten() method will take a dict whose elements are > > further nested dicts/lists and flatten them by concatenating > > keys. > > > > The qdict_crumple() method aims todo the reverse, taking a flat > > s/todo/to do/ > > > qdict, and turning it into a set of nested dicts/lists. It will > > apply nesting based on the key name, with a '.' indicating a > > new level in the hierarchy. If the keys in the nested structure > > are all numeric, it will create a list, otherwise it will create > > a dict. > > > > Interesting idea. I haven't closely reviewed the patch yet, but do have > a comment on the commit message: > > > > > If the key is intended to contain a literal '.', then it must > > be escaped as '..'. ie a flat dict > > Hmm. We forbid the use of '.' inside QAPI key names in most places, but > have an exception that downstream extensions use '.'. So, I guess the > only place you'd really use this is trying to target a > downstream-extension key name: I originally put code into object_property_add() to forbid use of a '.' in a property name, but quickly found we have alot of such usage already :-( On a x86_64 default machine I get: Property sse4.1 on class qemu64-x86_64-cpu Property sse4.2 on class qemu64-x86_64-cpu Property pc.ram[*] on class container Property pc.ram[0] on class container Property pc.bios[*] on class container Property pc.bios[0] on class container Property pc.rom[*] on class container Property pc.rom[0] on class container Property fwcfg.dma[*] on class fw_cfg_io Property fwcfg.dma[0] on class fw_cfg_io Property pci.0 on class i440FX-pcihost Property isa.0 on class PIIX3 Property vga.vram[*] on class VGA Property vga.vram[0] on class VGA Property vga.mmio[*] on class container Property vga.mmio[0] on class container Property vga.rom[*] on class VGA Property vga.rom[0] on class VGA Property e1000.rom[*] on class e1000 Property e1000.rom[0] on class e1000 Property ide.0 on class piix3-ide Property ide.1 on class piix3-ide Now none of those are implementing the UserCreatable interface right now, so wouldn't be a problem for -object usage, but I felt if we allow '.' in property names for devices, we ought to make sure the code deals with it everything. So it seems forbiding '.' in property names won't fly :-( Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|