qga: conditionalize schema for commands requiring fstrim
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 12 Jul 2024 13:24:51 +0000 (14:24 +0100)
committerKonstantin Kostiuk <kkostiuk@redhat.com>
Fri, 19 Jul 2024 08:50:35 +0000 (11:50 +0300)
commit21ca6854d8ef8020d605433773fceeecd10b11fd
treed58b1edcd81f44db54fa7cac09d7b8ce4bd64dbb
parent49d8c8e2374e0ed10e8d510760bd993e311cfb1a
qga: conditionalize schema for commands requiring fstrim

Rather than creating stubs for every command that just return
QERR_UNSUPPORTED, use 'if' conditions in the QAPI schema to
fully exclude generation of the filesystem trimming commands
on POSIX platforms lacking required APIs.

The command will be rejected at QMP dispatch time instead,
avoiding reimplementing rejection by blocking the stub commands.
This changes the error message for affected commands from

    {"class": "CommandNotFound", "desc": "Command FOO has been disabled"}

to

    {"class": "CommandNotFound", "desc": "The command FOO has not been found"}

This has the additional benefit that the QGA protocol reference
now documents what conditions enable use of the command.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Message-ID: <20240712132459.3974109-15-berrange@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
qga/commands-posix.c
qga/qapi-schema.json