On Wed, Jun 09, 2021 at 08:49:55PM +0200, Philippe Mathieu-Daudé wrote: > When the management layer queries a binary built using --disable-tpm > for TPM devices, it gets confused by getting empty responses: > ... > > To make it clearer by returning an error: > - Make the TPM QAPI schema conditional > - Adapt the HMP command > - Remove stubs which became unnecessary > > The management layer now gets a 'CommandNotFound' error: > > { "execute": "query-tpm" } > { > "error": { > "class": "CommandNotFound", > "desc": "The command query-tpm has not been found" > } > } > > Suggested-by: Marc-André Lureau <marcandre.lur...@redhat.com> > Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> > --- > qapi/tpm.json | 9 ++++++--- > monitor/hmp-cmds.c | 4 ++++ > stubs/tpm.c | 16 ---------------- > 3 files changed, 10 insertions(+), 19 deletions(-)
Yes, looks nicer. > > diff --git a/qapi/tpm.json b/qapi/tpm.json > index 6a10c9ed8d2..09332e6f996 100644 > --- a/qapi/tpm.json > +++ b/qapi/tpm.json > @@ -33,7 +33,8 @@ > # <- { "return": [ "tpm-tis", "tpm-crb", "tpm-spapr" ] } > # > ## > -{ 'command': 'query-tpm-models', 'returns': ['TpmModel'] } > +{ 'command': 'query-tpm-models', 'returns': ['TpmModel'], > + 'if': 'defined(CONFIG_TPM)' } May need a rebase if the series to make 'if' language-agnostic lands first (in fact, that would probably result in a build-time semantic conflict rather than a patch-application-time merge conflict), but that's not enough to prevent me from giving: Reviewed-by: Eric Blake <ebl...@redhat.com -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org