Skip to contentSkip to conversation

RFC: do we need ordered dict?

Qemu-devel Wei, Jiangang 3 participants 3 messages May 23, 2016 – May 31, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 16 lines · Jiangang

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":""
      }
Quoted 2 lines

}

JSON has no inherent ordering of keys in a dictionary, so I see nothing that needs to be changed here.

Quoted 7 lines

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.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 28 lines · Eric Blake
Quoted 16 lines · Jiangang

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":""
      }
Quoted 2 lines

}

JSON has no inherent ordering of keys in a dictionary, so I see nothing that needs to be changed here.

Quoted 5 lines

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).

Quoted 7 lines
Quoted 2 lines

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

Signature · 4 lines
|: 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 :|