[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] RFC: do we need ordered dict?
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] RFC: do we need ordered dict? |
Date: |
Tue, 31 May 2016 10:28:12 +0100 |
User-agent: |
Mutt/1.6.0 (2016-04-01) |
On Mon, May 23, 2016 at 09:29:23AM -0600, Eric Blake wrote:
> On 05/23/2016 04:14 AM, Wei, Jiangang wrote:
> > Hi all,
> >
> > I found a problem about the output of 'query-version'
> >
>
> > Actually, It's as following,
> > -> { "execute": "query-version" }
> > <- {
> > "return":{
> > "qemu":{
> > "micro":50,
> > "minor":6,
> > "major":2
> > },
> > "package":""
> > }
> > }
> >
>
> JSON has no inherent ordering of keys in a dictionary, so I see nothing
> that needs to be changed here.
>
> > The reason is that the member ''qemu" is regarded as Un-ordered dict.
> > and tdb_hash() returns the same bucket(225) for both "micro" and
> > "minor".
> > and The "major" is bigger (481).
> >
> > All of the above metioned introduces the disorder for major , minor and
> > micro.
>
> And if we pick any different hash, the results might be in a different
> order again. But it doesn't make it any less correct, so I don't think
> an ordered dict will help anything, and would instead just cost more
> overhead to write and maintain.
If anything we should be using a hash algorithm that results in a
different hash on every invocation of QEMU, to protect against
malicious users feeding QEMU data which causes pathelogical hash
collisions...
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 :|