[libvirt] QMP stubs: how to return "not implemented" errors?

Eduardo Habkost ehabkost at redhat.com
Mon Oct 3 19:04:42 UTC 2016


Hi,

When adding new QMP commands that are implemented by
arch-specific code, we have been adding stubs that report
QERR_UNSUPPORTED (see stubs/arch-query-cpu-model-expansion.c for
an example).

But we are using GenericError for that, and this prevents clients
from reliably checking if the command is really implemented by
the QEMU binary.

What should be the right solution for this? Some of the options I
have considered are:

1) Using CommandNotFound as the error class in the stubs. This
   sounds wrong because the command exists (it is present in
   query-commands and in the QAPI schema).
2) Creating a CommandNotImplemented error class. Simple to do,
   but it would require clients to make two separate checks,
   before concluding that the command is available (checking
   query-commands or query-qmp-schema, and then checking for
   CommandNotImplemented errors).
3.1) Removing the command from query-commands and from the QAPI
   schema on binaries that don't implement the command.
   Needlessly complex?
3.2) Removing the unimplemented command from query-commands only
   (by calling qmp_disable_command()), but keeping it on the QAPI
   schema. I am not sure it's OK to do that. If it is, this
   sounds like the simplest solution.

Any ideas?

-- 
Eduardo




More information about the libvir-list mailing list