summaryrefslogtreecommitdiff
path: root/qapi
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2026-08-28 16:04:16 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2026-08-29 12:07:44 +0400
commitba78ac4ecd717c1c061f487bf571f130f31328e9 (patch)
treec65ece4c5810be616828e13a0b60ce42d4a315cb /qapi
parentfa3cf7a0f564bb862589e3fe9188e202dd01a097 (diff)
downloadqemu-ba78ac4ecd717c1c061f487bf571f130f31328e9.tar.gz
qemu-ba78ac4ecd717c1c061f487bf571f130f31328e9.zip
net: add x-query-network QMP command
Add a structured x-query-network QMP command that returns network configuration as a NetworkInfo struct with pre-grouped hub information and a flat list of non-hub clients. Each hub includes its ports with inlined peer client info, and each client includes attached netfilter details. Refactor hmp_info_network() to consume only the QMP result instead of directly accessing internal net_clients state. This decouples HMP from internal data structures, making it possible to remove HMP support without losing programmatic network introspection. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-19-9227de146347@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r--qapi/net.json122
1 files changed, 122 insertions, 0 deletions
diff --git a/qapi/net.json b/qapi/net.json
index 5d3342fba2..85c78710fe 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -1305,3 +1305,125 @@
'returns': ['UsernetInfo'],
'if': 'CONFIG_SLIRP',
'features': [ 'unstable' ] }
+
+##
+# @NetFilterInfo:
+#
+# Information about a netfilter attached to a network client.
+#
+# @name: filter object name (QOM path component)
+#
+# @type: QOM type name (e.g. "filter-mirror")
+#
+# @info: filter properties as comma-separated key=value pairs
+# (excluding @type)
+#
+# Since: 11.2
+##
+{ 'struct': 'NetFilterInfo',
+ 'data': {
+ 'name': 'str',
+ 'type': 'str',
+ 'info': 'str' } }
+
+##
+# @NetworkClientInfo:
+#
+# Information about a network client.
+#
+# @name: unique network client identifier
+#
+# @queue-index: index of this queue (0 for single-queue clients)
+#
+# @type: network client driver type
+#
+# @info-str: driver-specific formatted information string (e.g.
+# "model=e1000,macaddr=52:54:00:12:34:56")
+#
+# @peer: the connected peer client (always a leaf; the peer's own
+# peer field is never populated)
+#
+# @filters: attached netfilters
+#
+# Since: 11.2
+##
+{ 'struct': 'NetworkClientInfo',
+ 'data': {
+ 'name': 'str',
+ 'queue-index': 'uint32',
+ 'type': 'NetClientDriver',
+ 'info-str': 'str',
+ '*peer': 'NetworkClientInfo',
+ 'filters': ['NetFilterInfo'] } }
+
+##
+# @NetHubPortInfo:
+#
+# Information about a hub port.
+#
+# @name: hub port identifier
+#
+# @peer: the network client connected through this port
+#
+# Since: 11.2
+##
+{ 'struct': 'NetHubPortInfo',
+ 'data': {
+ 'name': 'str',
+ '*peer': 'NetworkClientInfo' } }
+
+##
+# @NetHubInfo:
+#
+# Information about a network hub.
+#
+# @id: hub identifier
+#
+# @ports: list of ports on this hub
+#
+# Since: 11.2
+##
+{ 'struct': 'NetHubInfo',
+ 'data': {
+ 'id': 'int',
+ 'ports': ['NetHubPortInfo'] } }
+
+##
+# @NetworkInfo:
+#
+# Information about the network configuration.
+#
+# @hubs: network hubs and their ports
+#
+# @clients: network clients not associated with a hub
+#
+# Since: 11.2
+##
+{ 'struct': 'NetworkInfo',
+ 'data': {
+ 'hubs': ['NetHubInfo'],
+ 'clients': ['NetworkClientInfo'] } }
+
+##
+# @x-query-network:
+#
+# Query the network configuration including hubs and clients.
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: @NetworkInfo describing hubs and clients.
+#
+# Since: 11.2
+#
+# .. qmp-example::
+#
+# -> { "execute": "x-query-network" }
+# <- { "return": { "clients": [ { "name": "st0",
+# "queue-index": 0, "type": "stream",
+# "info-str": "listening" } ] } }
+##
+{ 'command': 'x-query-network',
+ 'returns': 'NetworkInfo',
+ 'features': [ 'unstable' ] }