[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 1/5] qapi: net: Add query-netdev command
From: |
Eric Blake |
Subject: |
Re: [PATCH v6 1/5] qapi: net: Add query-netdev command |
Date: |
Tue, 2 Mar 2021 13:10:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 |
On 3/2/21 12:02 PM, Alexey Kirillov wrote:
> The query-netdev command is used to get the configuration of the current
> network device backends (netdevs).
> This is the QMP analog of the HMP command "info network" but only for netdevs
> (i.e. excluding NIC and hubports).
>
> The query-netdev command returns an array of objects of the NetdevInfo type,
> which are an extension of Netdev type. It means that response can be used for
> netdev-add after small modification. This can be useful for recreate the same
> netdev configuration.
>
> Information about the network device is filled in when it is created or
> modified and is available through the NetClientState->stored_config.
>
> Signed-off-by: Alexey Kirillov <lekiravi@yandex-team.ru>
> Acked-by: Markus Armbruster <armbru@redhat.com>
> ---
> +++ b/net/net.c
>
> +NetdevInfoList *qmp_query_netdev(Error **errp)
> +{
> + NetdevInfoList *list = NULL;
> + NetClientState *nc;
> +
> + QTAILQ_FOREACH(nc, &net_clients, next) {
> + /*
> + * Only look at netdevs (backend network devices), not for each queue
> + * or NIC / hubport
> + */
> + if (nc->stored_config) {
> + NetdevInfoList *node = g_new0(NetdevInfoList, 1);
Please use QAPI_LIST_PREPEND instead of open-coding it.
> +
> + node->value = QAPI_CLONE(NetdevInfo, nc->stored_config);
> + g_free(node->value->id); /* Need to dealloc default empty id */
> + node->value->id = g_strdup(nc->name);
> +
> + node->value->has_peer_id = nc->peer != NULL;
> + if (node->value->has_peer_id) {
> + node->value->peer_id = g_strdup(nc->peer->name);
> + }
> +
> + node->next = list;
> + list = node;
> + }
> + }
> +
> +++ b/net/slirp.c
> @@ -345,6 +345,14 @@ static SaveVMHandlers savevm_slirp_state = {
> .load_state = net_slirp_state_load,
> };
>
> +#define APPEND_STRINGLIST(tail, new_val) \
> + do { \
> + *(tail) = g_new0(StringList, 1); \
> + (*(tail))->value = g_new0(String, 1); \
> + (*(tail))->value->str = g_strdup((new_val)); \
> + (tail) = &((*(tail))->next); \
> + } while (0)
Please use QAPI_LIST_APPEND instead of re-coding it.
> +++ b/qapi/net.json
> @@ -714,3 +714,83 @@
> ##
> { 'event': 'FAILOVER_NEGOTIATED',
> 'data': {'device-id': 'str'} }
> +
> +##
> +# @NetBackend:
> +#
> +# Available netdev backend drivers.
> +#
> +# Since: 6.0
> +##
> +{ 'enum': 'NetBackend',
> + 'data': [ 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'bridge', 'netmap',
> + 'vhost-user', 'vhost-vdpa' ] }
Is it worth alphabetizing this list?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PATCH v6 0/5] Introducing QMP query-netdev command, Alexey Kirillov, 2021/03/02
- [PATCH v6 1/5] qapi: net: Add query-netdev command, Alexey Kirillov, 2021/03/02
- Re: [PATCH v6 1/5] qapi: net: Add query-netdev command,
Eric Blake <=
- [PATCH v6 2/5] tests: Add tests for query-netdev command, Alexey Kirillov, 2021/03/02
- [PATCH v6 3/5] net: Move NetClientState.info_str to dynamic allocations, Alexey Kirillov, 2021/03/02
- [PATCH v6 4/5] hmp: Use QAPI NetdevInfo in hmp_info_network, Alexey Kirillov, 2021/03/02
- [PATCH v6 5/5] net: Do not fill legacy info_str for backends, Alexey Kirillov, 2021/03/02