[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/25] qga: conditionalize schema for commands requiring getifaddr
From: |
Konstantin Kostiuk |
Subject: |
[PULL 10/25] qga: conditionalize schema for commands requiring getifaddrs |
Date: |
Mon, 22 Jul 2024 10:01:07 +0300 |
From: Daniel P. Berrangé <berrange@redhat.com>
Rather than creating stubs for every comamnd that just return
QERR_UNSUPPORTED, use 'if' conditions in the QAPI schema to
fully exclude generation of the network interface command on
POSIX platforms lacking getifaddrs().
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-11-berrange@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
---
qga/commands-posix.c | 13 -------------
qga/qapi-schema.json | 15 ++++++++++-----
2 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 559d71ffae..09d08ee2ca 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1142,14 +1142,6 @@ error:
return NULL;
}
-#else
-
-GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
-{
- error_setg(errp, QERR_UNSUPPORTED);
- return NULL;
-}
-
#endif /* HAVE_GETIFADDRS */
#if !defined(CONFIG_FSFREEZE)
@@ -1222,11 +1214,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum,
Error **errp)
/* add unsupported commands to the list of blocked RPCs */
GList *ga_command_init_blockedrpcs(GList *blockedrpcs)
{
-#if !defined(HAVE_GETIFADDRS)
- blockedrpcs = g_list_append(blockedrpcs,
- g_strdup("guest-network-get-interfaces"));
-#endif
-
#if !defined(CONFIG_FSFREEZE)
{
const char *list[] = {
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 38483652ac..79ed4f0e21 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -654,7 +654,8 @@
# Since: 1.1
##
{ 'enum': 'GuestIpAddressType',
- 'data': [ 'ipv4', 'ipv6' ] }
+ 'data': [ 'ipv4', 'ipv6' ],
+ 'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
##
# @GuestIpAddress:
@@ -670,7 +671,8 @@
{ 'struct': 'GuestIpAddress',
'data': {'ip-address': 'str',
'ip-address-type': 'GuestIpAddressType',
- 'prefix': 'int'} }
+ 'prefix': 'int'},
+ 'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
##
# @GuestNetworkInterfaceStat:
@@ -702,7 +704,8 @@
'tx-packets': 'uint64',
'tx-errs': 'uint64',
'tx-dropped': 'uint64'
- } }
+ },
+ 'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
##
# @GuestNetworkInterface:
@@ -722,7 +725,8 @@
'data': {'name': 'str',
'*hardware-address': 'str',
'*ip-addresses': ['GuestIpAddress'],
- '*statistics': 'GuestNetworkInterfaceStat' } }
+ '*statistics': 'GuestNetworkInterfaceStat' },
+ 'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
##
# @guest-network-get-interfaces:
@@ -734,7 +738,8 @@
# Since: 1.1
##
{ 'command': 'guest-network-get-interfaces',
- 'returns': ['GuestNetworkInterface'] }
+ 'returns': ['GuestNetworkInterface'],
+ 'if': { 'any': ['CONFIG_WIN32', 'HAVE_GETIFADDRS'] } }
##
# @GuestLogicalProcessor:
--
2.45.2
- [PULL 15/25] qga: conditionalize schema for commands requiring libudev, (continued)
- [PULL 15/25] qga: conditionalize schema for commands requiring libudev, Konstantin Kostiuk, 2024/07/22
- [PULL 12/25] qga: conditionalize schema for commands only supported on Windows, Konstantin Kostiuk, 2024/07/22
- [PULL 08/25] qga: conditionalize schema for commands unsupported on Windows, Konstantin Kostiuk, 2024/07/22
- [PULL 21/25] qga: allow configuration file path via the cli, Konstantin Kostiuk, 2024/07/22
- [PULL 17/25] qga: conditionalize schema for commands not supported on other UNIX, Konstantin Kostiuk, 2024/07/22
- [PULL 22/25] qga: centralize logic for disabling/enabling commands, Konstantin Kostiuk, 2024/07/22
- [PULL 09/25] qga: conditionalize schema for commands unsupported on non-Linux POSIX, Konstantin Kostiuk, 2024/07/22
- [PULL 13/25] qga: conditionalize schema for commands requiring fsfreeze, Konstantin Kostiuk, 2024/07/22
- [PULL 16/25] qga: conditionalize schema for commands requiring utmpx, Konstantin Kostiuk, 2024/07/22
- [PULL 20/25] qga: remove pointless 'blockrpcs_key' variable, Konstantin Kostiuk, 2024/07/22
- [PULL 10/25] qga: conditionalize schema for commands requiring getifaddrs,
Konstantin Kostiuk <=
- [PULL 14/25] qga: conditionalize schema for commands requiring fstrim, Konstantin Kostiuk, 2024/07/22
- [PULL 18/25] qga: don't disable fsfreeze commands if vss_init fails, Konstantin Kostiuk, 2024/07/22
- [PULL 25/25] qga/linux: Add new api 'guest-network-get-route', Konstantin Kostiuk, 2024/07/22
- [PULL 24/25] guest-agent: document allow-rpcs in config file section, Konstantin Kostiuk, 2024/07/22
- [PULL 19/25] qga: move declare of QGAConfig struct to top of file, Konstantin Kostiuk, 2024/07/22
- [PULL 23/25] qga/commands-posix: Make ga_wait_child() return boolean, Konstantin Kostiuk, 2024/07/22
- Re: [PULL 00/25] Misc QEMU-GA patches 2024-07-22, Richard Henderson, 2024/07/22