John Snow <js...@redhat.com> writes: > On 6/9/21 7:56 AM, Markus Armbruster wrote: >>> The client could cache the information. (Against what kind of an >>> identifier? Can QEMU report some kind of token that uniquely >>> identifies its binary or uniquely identifies the set of QAPI commands >>> it supports?) > >> I proposed something like it to permit QMP clients cache >> query-qmp-schema output. Libvirt didn't want it, so it never got beyond >> the idea stage. >> > > What ideas did you have for a cache key? We don't need to uniquely > identify every instance or even every binary. > > I suppose we could use an md5/sha1 checksum of the QMP introspection output?
commit 39a181581650f4d50f4445bc6276d9716cece050 Author: Markus Armbruster <arm...@redhat.com> Date: Wed Sep 16 13:06:28 2015 +0200 qapi: New QMP command query-qmp-schema for QMP introspection [...] New QMP command query-qmp-schema takes its return value from that variable. Its reply is some 85KiBytes for me right now. Has since grown to ~160KiB. If this turns out to be too much, we have a couple of options: * We can use shorter names in the JSON. Not the QMP style. * Optionally return the sub-schema for commands and events given as arguments. Right now qmp_query_schema() sends the string literal computed by qmp-introspect.py. To compute sub-schema at run time, we'd have to duplicate parts of qapi-introspect.py in C. Unattractive. * Let clients cache the output of query-qmp-schema. It changes only on QEMU upgrades, i.e. rarely. Provide a command query-qmp-schema-hash. Clients can have a cache indexed by hash, and re-query the schema only when they don't have it cached. Even simpler: put the hash in the QMP greeting. Signed-off-by: Markus Armbruster <arm...@redhat.com> Reviewed-by: Eric Blake <ebl...@redhat.com> Note this glosses over what exactly is hashed. Back then, we generated query-qmp-schema's output as a string, so we would have hashed that. Today, we generate a QLitObject. Less trivial to hash. Quite feasible all the same. NB: Commit messages are love letters to your future self :) [...]