All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] RFC: do we need ordered dict?
@ 2016-05-23 10:14 Wei, Jiangang
  2016-05-23 15:29 ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: Wei, Jiangang @ 2016-05-23 10:14 UTC (permalink / raw)
  Cc: qemu-devel

Hi all,

I found a problem about the output of 'query-version'

As the qmp-command.hx said, it shoud be 
-> { "execute": "query-version" }
<- {
      "return":{
         "qemu":{
            "major":0,
            "minor":11,
            "micro":5
         },
         "package":""
      }
   }

Actually, It's as following,
-> { "execute": "query-version" }
<- {
      "return":{
         "qemu":{
            "micro":50,
            "minor":6,
            "major":2
         },
         "package":""
      }
   }

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.

Thanks,
wei




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] RFC: do we need ordered dict?
  2016-05-23 10:14 [Qemu-devel] RFC: do we need ordered dict? Wei, Jiangang
@ 2016-05-23 15:29 ` Eric Blake
  2016-05-31  9:28   ` Daniel P. Berrange
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2016-05-23 15:29 UTC (permalink / raw)
  To: Wei, Jiangang; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] RFC: do we need ordered dict?
  2016-05-23 15:29 ` Eric Blake
@ 2016-05-31  9:28   ` Daniel P. Berrange
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel P. Berrange @ 2016-05-31  9:28 UTC (permalink / raw)
  To: Eric Blake; +Cc: Wei, Jiangang, qemu-devel

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 :|

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-31  9:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-23 10:14 [Qemu-devel] RFC: do we need ordered dict? Wei, Jiangang
2016-05-23 15:29 ` Eric Blake
2016-05-31  9:28   ` Daniel P. Berrange

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.