From nobody Sun May 19 20:13:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1583327329; cv=none; d=zohomail.com; s=zohoarc; b=MSXmB65SDT4x7Eik9NV7u4PMczzC84tVjLhsZ2yurdz5WWzSnjJ/YEktDZJFMs6bZvr6OGBNyca3pKps9wnFSKuw65c2AT6uXEY6yZIN0tiVz9zEpkA/guRlQKVoxtIIYUwVS1FfWtSYAB9KYJFtmjncEOjR9W3QMdYGu72k228= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583327329; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gUepq0ZgfyyamhXn5xaZHf5pGfLg8uSIGoLVfjf22Mg=; b=TW1GEj9K+LldKvNLPCFFI6n76kdbC0mzbqkpEjN+Hs8EQ+3/nApzX5PEb4OkeSzaWuUyCJQH2+09VPYwQGU2NeSL/mYU3IzK1LoztcbfDHsAhbXpbNj/AU32G7S5q1GwMCwZKs4B482V2Rrhacr02od10NQVcBjNDJ/C6cY5ips= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583327329170111.82674652107266; Wed, 4 Mar 2020 05:08:49 -0800 (PST) Received: from localhost ([::1]:34056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9TlY-0004if-39 for importer@patchew.org; Wed, 04 Mar 2020 08:08:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37218) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9TkK-0002pR-4O for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9TkG-0001CZ-MK for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:32 -0500 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]:43222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9Tk9-0000t5-Cm; Wed, 04 Mar 2020 08:07:21 -0500 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 9A8E92E15E0; Wed, 4 Mar 2020 16:07:18 +0300 (MSK) Received: from sas1-9998cec34266.qloud-c.yandex.net (sas1-9998cec34266.qloud-c.yandex.net [2a02:6b8:c14:3a0e:0:640:9998:cec3]) by mxbackcorp2j.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id 2fG6wQovH6-7FJKVJLY; Wed, 04 Mar 2020 16:07:18 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:b4f7:3f29:4fea:8822]) by sas1-9998cec34266.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ujb0Gsh6CR-7EWOBUZD; Wed, 04 Mar 2020 16:07:15 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1583327238; bh=gUepq0ZgfyyamhXn5xaZHf5pGfLg8uSIGoLVfjf22Mg=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=okkyz1ijj5yer/sIh6PWpSqyfst9t0zVfS311Li2S3XsGYMR9tm1SDzuYCmhfpgcH p5yA8/hu2PWv4PF8O8Sb5fqWHdVg9/fqnYCZfzDLK8pTEX5gV/IrWTIIkTQxvRE2iM kJgr++NIDWri+8sM7lu0g1O6DqTNEBHc7zGA64wE= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexey Kirillov To: Eric Blake , Thomas Huth , Markus Armbruster Subject: [PATCH v2 1/4] qapi: net: Add query-netdevs command Date: Wed, 4 Mar 2020 16:06:53 +0300 Message-Id: <20200304130656.16859-2-lekiravi@yandex-team.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304130656.16859-1-lekiravi@yandex-team.ru> References: <20200304130656.16859-1-lekiravi@yandex-team.ru> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:6b8:0:1a2d::193 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , qemu-devel@nongnu.org, Vincenzo Maffione , Gerd Hoffmann , "Edgar E. Iglesias" , Sven Schnelle , Rob Herring , Stefano Stabellini , Paul Durrant , Joel Stanley , Anthony Perard , Samuel Thibault , Aleksandar Rikalo , David Gibson , Laurent Vivier , Jiri Pirko , yc-core@yandex-team.ru, Stefan Weil , Alistair Francis , Beniamino Galvani , qemu-arm@nongnu.org, Peter Chubb , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , xen-devel@lists.xenproject.org, Giuseppe Lettieri , Luigi Rizzo , Richard Henderson , Andrew Jeffery , Michael Walle , qemu-ppc@nongnu.org, Aleksandar Markovic , Alexey Kirillov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a qmp command that provides information about currently attached network devices and their configuration. Signed-off-by: Alexey Kirillov --- include/net/net.h | 1 + net/hub.c | 8 +++ net/l2tpv3.c | 19 +++++++ net/net.c | 91 +++++++++++++++++++++++++++++++++ net/netmap.c | 13 +++++ net/slirp.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++ net/socket.c | 71 ++++++++++++++++++++++++++ net/tap-win32.c | 9 ++++ net/tap.c | 103 +++++++++++++++++++++++++++++++++++-- net/vde.c | 26 ++++++++++ net/vhost-user.c | 18 +++++-- qapi/net.json | 89 ++++++++++++++++++++++++++++++++ 12 files changed, 566 insertions(+), 8 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index e175ba9677..2c8956c0b3 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -92,6 +92,7 @@ struct NetClientState { char *model; char *name; char info_str[256]; + NetdevInfo *stored_config; unsigned receive_disabled : 1; NetClientDestructor *destructor; unsigned int queue_index; diff --git a/net/hub.c b/net/hub.c index 5795a678ed..37995b5517 100644 --- a/net/hub.c +++ b/net/hub.c @@ -148,6 +148,7 @@ static NetHubPort *net_hub_port_new(NetHub *hub, const = char *name, NetHubPort *port; int id =3D hub->num_ports++; char default_name[128]; + NetdevHubPortOptions *stored; =20 if (!name) { snprintf(default_name, sizeof(default_name), @@ -160,6 +161,13 @@ static NetHubPort *net_hub_port_new(NetHub *hub, const= char *name, port->id =3D id; port->hub =3D hub; =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_HUBPORT; + stored =3D &nc->stored_config->u.hubport; + + stored->hubid =3D hub->id; + QLIST_INSERT_HEAD(&hub->ports, port, next); =20 return port; diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 55fea17c0f..f4e45e7b28 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -535,6 +535,7 @@ int net_init_l2tpv3(const Netdev *netdev, struct addrinfo hints; struct addrinfo *result =3D NULL; char *srcport, *dstport; + NetdevL2TPv3Options *stored; =20 nc =3D qemu_new_net_client(&net_l2tpv3_info, peer, "l2tpv3", name); =20 @@ -726,6 +727,24 @@ int net_init_l2tpv3(const Netdev *netdev, =20 l2tpv3_read_poll(s, true); =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_L2TPV3; + stored =3D &nc->stored_config->u.l2tpv3; + + memcpy(stored, l2tpv3, sizeof(NetdevL2TPv3Options)); + + stored->src =3D g_strdup(l2tpv3->src); + stored->dst =3D g_strdup(l2tpv3->dst); + + if (l2tpv3->has_srcport) { + stored->srcport =3D g_strdup(l2tpv3->srcport); + } + + if (l2tpv3->has_dstport) { + stored->dstport =3D g_strdup(l2tpv3->dstport); + } + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "l2tpv3: connected"); return 0; diff --git a/net/net.c b/net/net.c index 9e93c3f8a1..01e0548295 100644 --- a/net/net.c +++ b/net/net.c @@ -54,6 +54,7 @@ #include "sysemu/sysemu.h" #include "net/filter.h" #include "qapi/string-output-visitor.h" +#include "qapi/clone-visitor.h" =20 /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32) @@ -128,6 +129,12 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr) =20 void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]) { + g_assert(nc->stored_config); + + g_free(nc->stored_config->u.nic.macaddr); + nc->stored_config->u.nic.macaddr =3D g_strdup_printf(MAC_FMT, + MAC_ARG(macaddr)); + snprintf(nc->info_str, sizeof(nc->info_str), "model=3D%s,macaddr=3D%02x:%02x:%02x:%02x:%02x:%02x", nc->model, @@ -283,6 +290,7 @@ NICState *qemu_new_nic(NetClientInfo *info, NetClientState **peers =3D conf->peers.ncs; NICState *nic; int i, queues =3D MAX(1, conf->peers.queues); + NetLegacyNicOptions *stored; =20 assert(info->type =3D=3D NET_CLIENT_DRIVER_NIC); assert(info->size >=3D sizeof(NICState)); @@ -298,6 +306,27 @@ NICState *qemu_new_nic(NetClientInfo *info, nic->ncs[i].queue_index =3D i; } =20 + /* Store startup parameters */ + nic->ncs[0].stored_config =3D g_new0(NetdevInfo, 1); + nic->ncs[0].stored_config->type =3D NET_CLIENT_DRIVER_NIC; + stored =3D &nic->ncs[0].stored_config->u.nic; + + /* Read-only in runtime */ + nic->ncs[0].stored_config->has_perm_mac =3D true; + nic->ncs[0].stored_config->perm_mac =3D g_strdup_printf(MAC_FMT, + MAC_ARG(conf->macaddr.a)); + + if (peers[0]) { + stored->has_netdev =3D true; + stored->netdev =3D g_strdup(peers[0]->name); + } + + stored->has_macaddr =3D true; + stored->macaddr =3D g_strdup_printf(MAC_FMT, MAC_ARG(conf->macaddr.a)); + + stored->has_model =3D true; + stored->model =3D g_strdup(model); + return nic; } =20 @@ -344,6 +373,7 @@ static void qemu_free_net_client(NetClientState *nc) } g_free(nc->name); g_free(nc->model); + qapi_free_NetdevInfo(nc->stored_config); if (nc->destructor) { nc->destructor(nc); } @@ -1320,6 +1350,67 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name,= const char *name, return filter_list; } =20 +NetdevInfoList *qmp_query_netdevs(Error **errp) +{ + NetdevInfoList *list =3D NULL; + NetClientState *nc; + + QTAILQ_FOREACH(nc, &net_clients, next) { + /* Only look at netdevs, not for each queue */ + if (nc->stored_config) { + NetdevInfoList *node =3D g_new0(NetdevInfoList, 1); + + node->value =3D QAPI_CLONE(NetdevInfo, nc->stored_config); + g_free(node->value->id); /* Need to dealloc default empty id */ + node->value->id =3D g_strdup(nc->name); + + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { + NICState *state =3D qemu_get_nic(nc); + assert(state); + + /* NIC have explicit number of queues */ + assert(state->conf); + node->value->queues_count =3D state->conf->peers.queues; + } else { + /* Not a NIC, but can have queues */ + NetClientState *nc_iterable; + + QTAILQ_FOREACH(nc_iterable, &net_clients, next) { + if (strcmp(nc_iterable->name, nc->name) =3D=3D 0) { + node->value->queues_count++; + } + } + } + + node->value->has_peer =3D nc->peer !=3D NULL; + if (node->value->has_peer) { + node->value->peer =3D g_strdup(nc->peer->name); + } + + node->value->has_hub =3D + net_hub_id_for_client(nc, (int *)&node->value->hub) =3D=3D= 0; + + /* + * Copy the current hubport peer id to connected netdev id, + * because it could have been changed at runtime + */ + if (nc->info->type =3D=3D NET_CLIENT_DRIVER_HUBPORT) { + if (node->value->has_peer) { + g_free(node->value->u.hubport.netdev); + + node->value->u.hubport.has_netdev =3D true; + node->value->u.hubport.netdev =3D g_strdup(nc->peer->n= ame); + } + } + + node->next =3D list; + list =3D node; + } + } + + return list; +} + void hmp_info_network(Monitor *mon, const QDict *qdict) { NetClientState *nc, *peer; diff --git a/net/netmap.c b/net/netmap.c index 350f097f91..71feacb92c 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -411,6 +411,7 @@ int net_init_netmap(const Netdev *netdev, NetClientState *nc; Error *err =3D NULL; NetmapState *s; + NetdevNetmapOptions *stored; =20 nmd =3D netmap_open(netmap_opts, &err); if (err) { @@ -427,6 +428,18 @@ int net_init_netmap(const Netdev *netdev, pstrcpy(s->ifname, sizeof(s->ifname), netmap_opts->ifname); netmap_read_poll(s, true); /* Initially only poll for reads. */ =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_NETMAP; + stored =3D &nc->stored_config->u.netmap; + + stored->ifname =3D g_strdup(netmap_opts->ifname); + + if (netmap_opts->has_devname) { + stored->has_devname =3D true; + stored->devname =3D g_strdup(netmap_opts->devname); + } + return 0; } =20 diff --git a/net/slirp.c b/net/slirp.c index c4334ee876..fb5b87ebed 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -346,6 +346,14 @@ static SaveVMHandlers savevm_slirp_state =3D { .load_state =3D net_slirp_state_load, }; =20 +#define APPEND_STRINGLIST(tail, new_val) \ + do { \ + *(tail) =3D g_new0(StringList, 1); \ + (*(tail))->value =3D g_new0(String, 1); \ + (*(tail))->value->str =3D g_strdup((new_val)); \ + (tail) =3D &((*(tail))->next); \ + } while (0) + static int net_slirp_init(NetClientState *peer, const char *model, const char *name, int restricted, bool ipv4, const char *vnetwork, const char *vho= st, @@ -378,6 +386,9 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, int shift; char *end; struct slirp_config_str *config; + NetdevUserOptions *stored; + StringList **stored_hostfwd; + StringList **stored_guestfwd; =20 if (!ipv4 && (vnetwork || vhost || vnameserver)) { error_setg(errp, "IPv4 disabled but netmask/host/dns provided"); @@ -553,6 +564,112 @@ static int net_slirp_init(NetClientState *peer, const= char *model, =20 nc =3D qemu_new_net_client(&net_slirp_info, peer, model, name); =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_USER; + stored =3D &nc->stored_config->u.user; + + if (vhostname) { + stored->has_hostname =3D true; + stored->hostname =3D g_strdup(vhostname); + } + + stored->has_q_restrict =3D true; + stored->q_restrict =3D restricted; + + stored->has_ipv4 =3D true; + stored->ipv4 =3D ipv4; + + stored->has_ipv6 =3D true; + stored->ipv6 =3D ipv6; + + if (ipv4) { + uint8_t *net_bytes =3D (uint8_t *)&net; + uint8_t *mask_bytes =3D (uint8_t *)&mask; + + stored->has_net =3D true; + stored->net =3D g_strdup_printf("%d.%d.%d.%d/%d.%d.%d.%d", + net_bytes[0], net_bytes[1], + net_bytes[2], net_bytes[3], + mask_bytes[0], mask_bytes[1], + mask_bytes[2], mask_bytes[3]); + + stored->has_host =3D true; + stored->host =3D g_strdup(inet_ntoa(host)); + } + + if (tftp_export) { + stored->has_tftp =3D true; + stored->tftp =3D g_strdup(tftp_export); + } + + if (bootfile) { + stored->has_bootfile =3D true; + stored->bootfile =3D g_strdup(bootfile); + } + + if (vdhcp_start) { + stored->has_dhcpstart =3D true; + stored->dhcpstart =3D g_strdup(vdhcp_start); + } + + if (ipv4) { + stored->has_dns =3D true; + stored->dns =3D g_strdup(inet_ntoa(dns)); + } + + if (dnssearch) { + stored->has_dnssearch =3D true; + StringList **stored_list =3D &stored->dnssearch; + + for (int i =3D 0; dnssearch[i]; i++) { + APPEND_STRINGLIST(stored_list, dnssearch[i]); + } + } + + if (vdomainname) { + stored->has_domainname =3D true; + stored->domainname =3D g_strdup(vdomainname); + } + + if (ipv6) { + char addrstr[INET6_ADDRSTRLEN]; + const char *res; + + stored->has_ipv6_prefix =3D true; + stored->ipv6_prefix =3D g_strdup(vprefix6); + + stored->has_ipv6_prefixlen =3D true; + stored->ipv6_prefixlen =3D vprefix6_len; + + res =3D inet_ntop(AF_INET6, &ip6_host, + addrstr, sizeof(addrstr)); + + stored->has_ipv6_host =3D true; + stored->ipv6_host =3D g_strdup(res); + + res =3D inet_ntop(AF_INET6, &ip6_dns, + addrstr, sizeof(addrstr)); + + stored->has_ipv6_dns =3D true; + stored->ipv6_dns =3D g_strdup(res); + } + + if (smb_export) { + stored->has_smb =3D true; + stored->smb =3D g_strdup(smb_export); + } + + if (vsmbserver) { + stored->has_smbserver =3D true; + stored->smbserver =3D g_strdup(vsmbserver); + } + + if (tftp_server_name) { + stored->has_tftp_server_name =3D true; + stored->tftp_server_name =3D g_strdup(tftp_server_name); + } + snprintf(nc->info_str, sizeof(nc->info_str), "net=3D%s,restrict=3D%s", inet_ntoa(net), restricted ? "on" : "off"); @@ -582,14 +699,23 @@ static int net_slirp_init(NetClientState *peer, const= char *model, s->poll_notifier.notify =3D net_slirp_poll_notify; main_loop_poll_add_notifier(&s->poll_notifier); =20 + stored_hostfwd =3D &stored->hostfwd; + stored_guestfwd =3D &stored->guestfwd; + for (config =3D slirp_configs; config; config =3D config->next) { if (config->flags & SLIRP_CFG_HOSTFWD) { if (slirp_hostfwd(s, config->str, errp) < 0) { goto error; + } else { + stored->has_hostfwd =3D true; + APPEND_STRINGLIST(stored_hostfwd, config->str); } } else { if (slirp_guestfwd(s, config->str, errp) < 0) { goto error; + } else { + stored->has_guestfwd =3D true; + APPEND_STRINGLIST(stored_guestfwd, config->str); } } } diff --git a/net/socket.c b/net/socket.c index c92354049b..2d2d5419ca 100644 --- a/net/socket.c +++ b/net/socket.c @@ -342,6 +342,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClie= ntState *peer, NetSocketState *s; SocketAddress *sa; SocketAddressType sa_type; + NetdevSocketOptions *stored; =20 sa =3D socket_local_address(fd, errp); if (!sa) { @@ -385,8 +386,19 @@ static NetSocketState *net_socket_fd_init_dgram(NetCli= entState *peer, net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); net_socket_read_poll(s, true); =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_SOCKET; + stored =3D &nc->stored_config->u.socket; + + stored->has_fd =3D true; + stored->fd =3D g_strdup_printf("%d", fd); + /* mcast: save bound address as dst */ if (is_connected && mcast !=3D NULL) { + stored->has_mcast =3D true; + stored->mcast =3D g_strdup(mcast); + s->dgram_dst =3D saddr; snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=3D%d (cloned mcast=3D%s:%d)", @@ -428,6 +440,7 @@ static NetSocketState *net_socket_fd_init_stream(NetCli= entState *peer, { NetClientState *nc; NetSocketState *s; + NetdevSocketOptions *stored; =20 nc =3D qemu_new_net_client(&net_socket_info, peer, model, name); =20 @@ -447,6 +460,15 @@ static NetSocketState *net_socket_fd_init_stream(NetCl= ientState *peer, } else { qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s); } + + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_SOCKET; + stored =3D &nc->stored_config->u.socket; + + stored->has_fd =3D true; + stored->fd =3D g_strdup_printf("%d", fd); + return s; } =20 @@ -483,6 +505,7 @@ static void net_socket_accept(void *opaque) struct sockaddr_in saddr; socklen_t len; int fd; + NetdevSocketOptions *stored; =20 for(;;) { len =3D sizeof(saddr); @@ -498,6 +521,13 @@ static void net_socket_accept(void *opaque) s->fd =3D fd; s->nc.link_down =3D false; net_socket_connect(s); + + /* Store additional startup parameters (extend net_socket_listen_init)= */ + stored =3D &s->nc.stored_config->u.socket; + + stored->has_fd =3D true; + stored->fd =3D g_strdup_printf("%d", fd); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "socket: connection from %s:%d", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); @@ -513,6 +543,7 @@ static int net_socket_listen_init(NetClientState *peer, NetSocketState *s; struct sockaddr_in saddr; int fd, ret; + NetdevSocketOptions *stored; =20 if (parse_host_port(&saddr, host_str, errp) < 0) { return -1; @@ -549,6 +580,15 @@ static int net_socket_listen_init(NetClientState *peer, net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); =20 qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s); + + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_SOCKET; + stored =3D &nc->stored_config->u.socket; + + stored->has_listen =3D true; + stored->listen =3D g_strdup(host_str); + return 0; } =20 @@ -561,6 +601,7 @@ static int net_socket_connect_init(NetClientState *peer, NetSocketState *s; int fd, connected, ret; struct sockaddr_in saddr; + NetdevSocketOptions *stored; =20 if (parse_host_port(&saddr, host_str, errp) < 0) { return -1; @@ -598,6 +639,12 @@ static int net_socket_connect_init(NetClientState *pee= r, return -1; } =20 + /* Store additional startup parameters (extend net_socket_fd_init) */ + stored =3D &s->nc.stored_config->u.socket; + + stored->has_connect =3D true; + stored->connect =3D g_strdup(host_str); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "socket: connect to %s:%d", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); @@ -615,6 +662,7 @@ static int net_socket_mcast_init(NetClientState *peer, int fd; struct sockaddr_in saddr; struct in_addr localaddr, *param_localaddr; + NetdevSocketOptions *stored; =20 if (parse_host_port(&saddr, host_str, errp) < 0) { return -1; @@ -643,6 +691,19 @@ static int net_socket_mcast_init(NetClientState *peer, =20 s->dgram_dst =3D saddr; =20 + /* Store additional startup parameters (extend net_socket_fd_init) */ + stored =3D &s->nc.stored_config->u.socket; + + if (!stored->has_mcast) { + stored->has_mcast =3D true; + stored->mcast =3D g_strdup(host_str); + } + + if (localaddr_str) { + stored->has_localaddr =3D true; + stored->localaddr =3D g_strdup(localaddr_str); + } + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "socket: mcast=3D%s:%d", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); @@ -660,6 +721,7 @@ static int net_socket_udp_init(NetClientState *peer, NetSocketState *s; int fd, ret; struct sockaddr_in laddr, raddr; + NetdevSocketOptions *stored; =20 if (parse_host_port(&laddr, lhost, errp) < 0) { return -1; @@ -698,6 +760,15 @@ static int net_socket_udp_init(NetClientState *peer, =20 s->dgram_dst =3D raddr; =20 + /* Store additional startup parameters (extend net_socket_fd_init) */ + stored =3D &s->nc.stored_config->u.socket; + + stored->has_localaddr =3D true; + stored->localaddr =3D g_strdup(lhost); + + stored->has_udp =3D true; + stored->udp =3D g_strdup(rhost); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "socket: udp=3D%s:%d", inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port)); diff --git a/net/tap-win32.c b/net/tap-win32.c index 2b5dcda36e..20ba0b1dc8 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -768,6 +768,7 @@ static int tap_win32_init(NetClientState *peer, const c= har *model, NetClientState *nc; TAPState *s; tap_win32_overlapped_t *handle; + NetdevTapOptions *stored; =20 if (tap_win32_open(&handle, ifname) < 0) { printf("tap: Could not open '%s'\n", ifname); @@ -778,6 +779,14 @@ static int tap_win32_init(NetClientState *peer, const = char *model, =20 s =3D DO_UPCAST(TAPState, nc, nc); =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_TAP; + stored =3D &nc->stored_config->u.tap; + + stored->has_ifname =3D true; + stored->ifname =3D g_strdup(ifname); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "tap: ifname=3D%s", ifname); =20 diff --git a/net/tap.c b/net/tap.c index 6207f61f84..f40f378c2a 100644 --- a/net/tap.c +++ b/net/tap.c @@ -584,6 +584,7 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, const char *helper, *br; TAPState *s; int fd, vnet_hdr; + NetdevBridgeOptions *stored; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE); bridge =3D &netdev->u.bridge; @@ -600,6 +601,21 @@ int net_init_bridge(const Netdev *netdev, const char *= name, vnet_hdr =3D tap_probe_vnet_hdr(fd); s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); =20 + /* Store startup parameters */ + s->nc.stored_config =3D g_new0(NetdevInfo, 1); + s->nc.stored_config->type =3D NET_CLIENT_DRIVER_BRIDGE; + stored =3D &s->nc.stored_config->u.bridge; + + if (br) { + stored->has_br =3D true; + stored->br =3D g_strdup(br); + } + + if (helper) { + stored->has_helper =3D true; + stored->helper =3D g_strdup(helper); + } + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s,br=3D%s"= , helper, br); =20 @@ -647,11 +663,13 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdna= me, - int vnet_hdr, int fd, Error **errp) + int vnet_hdr, int fd, NetdevInfo **common_sto= red, + Error **errp) { Error *err =3D NULL; TAPState *s =3D net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; + NetdevTapOptions *stored; =20 tap_set_sndbuf(s->fd, tap, &err); if (err) { @@ -659,12 +677,65 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, return; } =20 + /* Store startup parameters */ + if (!*common_stored) { + *common_stored =3D g_new0(NetdevInfo, 1); + (*common_stored)->type =3D NET_CLIENT_DRIVER_TAP; + s->nc.stored_config =3D *common_stored; + } + stored =3D &(*common_stored)->u.tap; + + if (tap->has_sndbuf && !stored->has_sndbuf) { + stored->has_sndbuf =3D true; + stored->sndbuf =3D tap->sndbuf; + } + + if (vnet_hdr && !stored->has_vnet_hdr) { + stored->has_vnet_hdr =3D true; + stored->vnet_hdr =3D true; + } + if (tap->has_fd || tap->has_fds) { + if (!stored->has_fds) { + stored->has_fds =3D true; + stored->fds =3D g_strdup_printf("%d", fd); + } else { + char *tmp_s =3D stored->fds; + stored->fds =3D g_strdup_printf("%s:%d", stored->fds, fd); + g_free(tmp_s); + } + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=3D%d", fd); } else if (tap->has_helper) { + if (!stored->has_helper) { + stored->has_helper =3D true; + stored->helper =3D g_strdup(tap->helper); + } + + if (!stored->has_br) { + stored->has_br =3D true; + stored->br =3D tap->has_br ? g_strdup(tap->br) : + g_strdup(DEFAULT_BRIDGE_INTERFACE); + } + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s", tap->helper); } else { + if (ifname && !stored->has_ifname) { + stored->has_ifname =3D true; + stored->ifname =3D g_strdup(ifname); + } + + if (script && !stored->has_script) { + stored->has_script =3D true; + stored->script =3D g_strdup(script); + } + + if (downscript && !stored->has_downscript) { + stored->has_downscript =3D true; + stored->downscript =3D g_strdup(downscript); + } + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "ifname=3D%s,script=3D%s,downscript=3D%s", ifname, script, downscript); @@ -680,9 +751,20 @@ static void net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { VhostNetOptions options; =20 + stored->has_vhost =3D true; + stored->vhost =3D true; + + if (tap->has_vhostforce && tap->vhostforce) { + stored->has_vhostforce =3D true; + stored->vhostforce =3D true; + } + options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; options.net_backend =3D &s->nc; if (tap->has_poll_us) { + stored->has_poll_us =3D true; + stored->poll_us =3D tap->poll_us; + options.busyloop_timeout =3D tap->poll_us; } else { options.busyloop_timeout =3D 0; @@ -715,6 +797,15 @@ static void net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, } options.opaque =3D (void *)(uintptr_t)vhostfd; =20 + if (!stored->has_vhostfds) { + stored->has_vhostfds =3D true; + stored->vhostfds =3D g_strdup_printf("%d", vhostfd); + } else { + char *tmp_s =3D stored->vhostfds; + stored->vhostfds =3D g_strdup_printf("%s:%d", stored->fds, vho= stfd); + g_free(tmp_s); + } + s->vhost_net =3D vhost_net_init(&options); if (!s->vhost_net) { if (tap->has_vhostforce && tap->vhostforce) { @@ -766,6 +857,7 @@ int net_init_tap(const Netdev *netdev, const char *name, Error *err =3D NULL; const char *vhostfdname; char ifname[128]; + NetdevInfo *common_stored =3D NULL; /* will store configuration */ =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -801,7 +893,7 @@ int net_init_tap(const Netdev *netdev, const char *name, =20 net_init_tap_one(tap, peer, "tap", name, NULL, script, downscript, - vhostfdname, vnet_hdr, fd, &err); + vhostfdname, vnet_hdr, fd, &common_stored, &err); if (err) { error_propagate(errp, err); return -1; @@ -857,7 +949,7 @@ int net_init_tap(const Netdev *netdev, const char *name, net_init_tap_one(tap, peer, "tap", name, ifname, script, downscript, tap->has_vhostfds ? vhost_fds[i] : NULL, - vnet_hdr, fd, &err); + vnet_hdr, fd, &common_stored, &err); if (err) { error_propagate(errp, err); ret =3D -1; @@ -896,7 +988,7 @@ free_fail: =20 net_init_tap_one(tap, peer, "bridge", name, ifname, script, downscript, vhostfdname, - vnet_hdr, fd, &err); + vnet_hdr, fd, &common_stored, &err); if (err) { error_propagate(errp, err); close(fd); @@ -935,7 +1027,8 @@ free_fail: net_init_tap_one(tap, peer, "tap", name, ifname, i >=3D 1 ? "no" : script, i >=3D 1 ? "no" : downscript, - vhostfdname, vnet_hdr, fd, &err); + vhostfdname, vnet_hdr, fd, + &common_stored, &err); if (err) { error_propagate(errp, err); close(fd); diff --git a/net/vde.c b/net/vde.c index 99189cccb6..c0ab2bb65c 100644 --- a/net/vde.c +++ b/net/vde.c @@ -84,6 +84,7 @@ static int net_vde_init(NetClientState *peer, const char = *model, VDECONN *vde; char *init_group =3D (char *)group; char *init_sock =3D (char *)sock; + NetdevVdeOptions *stored; =20 struct vde_open_args args =3D { .port =3D port, @@ -108,6 +109,31 @@ static int net_vde_init(NetClientState *peer, const ch= ar *model, =20 qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s); =20 + /* Store startup parameters */ + nc->stored_config =3D g_new0(NetdevInfo, 1); + nc->stored_config->type =3D NET_CLIENT_DRIVER_VDE; + stored =3D &nc->stored_config->u.vde; + + if (sock) { + stored->has_sock =3D true; + stored->sock =3D g_strdup(sock); + } + + if (port) { + stored->has_port =3D true; + stored->port =3D port; + } + + if (group) { + stored->has_group =3D true; + stored->group =3D g_strdup(group); + } + + if (mode) { + stored->has_mode =3D true; + stored->mode =3D mode; + } + return 0; } =20 diff --git a/net/vhost-user.c b/net/vhost-user.c index 17532daaf3..aa2dc53179 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -307,14 +307,15 @@ static void net_vhost_user_event(void *opaque, QEMUCh= rEvent event) } =20 static int net_vhost_user_init(NetClientState *peer, const char *device, - const char *name, Chardev *chr, - int queues) + const char *name, const char *chardev, + Chardev *chr, int queues) { Error *err =3D NULL; NetClientState *nc, *nc0 =3D NULL; NetVhostUserState *s =3D NULL; VhostUserState *user; int i; + NetdevVhostUserOptions *stored; =20 assert(name); assert(queues > 0); @@ -351,6 +352,16 @@ static int net_vhost_user_init(NetClientState *peer, c= onst char *device, =20 assert(s->vhost_net); =20 + /* Store startup parameters */ + nc0->stored_config =3D g_new0(NetdevInfo, 1); + nc0->stored_config->type =3D NET_CLIENT_DRIVER_VHOST_USER; + stored =3D &nc0->stored_config->u.vhost_user; + + stored->chardev =3D g_strdup(chardev); + + stored->has_queues =3D true; + stored->queues =3D queues; + return 0; =20 err: @@ -442,5 +453,6 @@ int net_init_vhost_user(const Netdev *netdev, const cha= r *name, return -1; } =20 - return net_vhost_user_init(peer, "vhost_user", name, chr, queues); + return net_vhost_user_init(peer, "vhost_user", name, + vhost_user_opts->chardev, chr, queues); } diff --git a/qapi/net.json b/qapi/net.json index 1cb9a7d782..4f329a1de0 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -750,3 +750,92 @@ ## { 'event': 'FAILOVER_NEGOTIATED', 'data': {'device-id': 'str'} } + +## +# @NetdevInfo: +# +# Configuration of a network device. +# +# @id: Device identifier. +# +# @type: Specify the driver used for interpreting remaining arguments. +# +# @peer: Connected network device. +# +# @queues-count: Number of queues. +# +# @hub: hubid of hub, if connected to. +# +# @perm-mac: Original MAC address. +# +# Since: 5.0 +## +{ 'union': 'NetdevInfo', + 'base': { 'id': 'str', + 'type': 'NetClientDriver', + '*peer': 'str', + 'queues-count': 'int', + '*hub': 'int', + '*perm-mac': 'str' }, + 'discriminator': 'type', + 'data': { + 'nic': 'NetLegacyNicOptions', + 'user': 'NetdevUserOptions', + 'tap': 'NetdevTapOptions', + 'l2tpv3': 'NetdevL2TPv3Options', + 'socket': 'NetdevSocketOptions', + 'vde': 'NetdevVdeOptions', + 'bridge': 'NetdevBridgeOptions', + 'hubport': 'NetdevHubPortOptions', + 'netmap': 'NetdevNetmapOptions', + 'vhost-user': 'NetdevVhostUserOptions' } } + +## +# @query-netdevs: +# +# Get a list of @NetdevInfo for all virtual network devices. +# +# Returns: a list of @NetdevInfo describing each virtual network device. +# +# Since: 5.0 +# +# Example: +# +# -> { "execute": "query-netdevs" } +# <- { "return": [ +# { +# "peer": "netdev0", +# "netdev": "netdev0", +# "perm-mac": "52:54:00:12:34:56" +# "model": "virtio-net-pci", +# "macaddr": "52:54:00:12:34:56", +# "queues-count": 1, +# "type": "nic", +# "id": "net0" +# }, +# { +# "peer": "net0", +# "ipv6": true, +# "ipv4": true, +# "host": "10.0.2.2", +# "queues-count": 1, +# "ipv6-dns": "fec0::3", +# "ipv6-prefix": "fec0::", +# "net": "10.0.2.0/255.255.255.0", +# "ipv6-host": "fec0::2", +# "type": "user", +# "dns": "10.0.2.3", +# "hostfwd": [ +# { +# "str": "tcp::20004-:22" +# } +# ], +# "ipv6-prefixlen": 64, +# "id": "netdev0", +# "restrict": false +# } +# ] +# } +# +## +{ 'command': 'query-netdevs', 'returns': ['NetdevInfo'] } --=20 2.17.1 From nobody Sun May 19 20:13:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1583327321; cv=none; d=zohomail.com; s=zohoarc; b=Ik/a5PwbAVT/O+MTz602xcuTr1LJHwioDY2QfU90z6IrpaygtwLZtwin0h8aQnetqUvOnu4w6XWg1CC0vRqJRpJabLHxuXlHDAK5R1R9n1nNoR/XsLSaJmeEuqz28RNykN+lvqj5lyctk8023JlUoCUPuC8Ij/yoku8z8iv5oW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583327321; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=RzA7COy6OjGENVG5q5PdG3mDLFc4iPpo75ImpI9/idQ=; b=iboebSvlpCRFsh2nU2HCHlu9YWv1Azvk/W7SDwrbd3tzudiDHNrf+ihvIOzY2xqNFIceD+CYcxIwFURW1bvO5kbmoI7j9Z55uj0jepsyNPahTFX15gP9NDGexPydLe+l2b0A/+Off/+Olt1PrWPgKR0CGDrj/yjRrmCLr4lMXcA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583327321542476.29660890693424; Wed, 4 Mar 2020 05:08:41 -0800 (PST) Received: from localhost ([::1]:34052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9TlP-0004U4-4d for importer@patchew.org; Wed, 04 Mar 2020 08:08:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37180) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9TkH-0002mn-SZ for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9TkG-0001CP-K8 for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:29 -0500 Received: from forwardcorp1j.mail.yandex.net ([2a02:6b8:0:1619::183]:40464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9TkD-00012X-Oh; Wed, 04 Mar 2020 08:07:26 -0500 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id E6B6B2E1695; Wed, 4 Mar 2020 16:07:22 +0300 (MSK) Received: from sas1-9998cec34266.qloud-c.yandex.net (sas1-9998cec34266.qloud-c.yandex.net [2a02:6b8:c14:3a0e:0:640:9998:cec3]) by mxbackcorp2j.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id fDcZyQkbLf-7JJKZglc; Wed, 04 Mar 2020 16:07:22 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:b4f7:3f29:4fea:8822]) by sas1-9998cec34266.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ujb0Gsh6CR-7IWOaIsp; Wed, 04 Mar 2020 16:07:19 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1583327242; bh=RzA7COy6OjGENVG5q5PdG3mDLFc4iPpo75ImpI9/idQ=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=InvlNaS+6VR8q2ihOkE87gsAyKN7LhYTRQObXdwhw7Zc39oH3dBVLg1PkzoD/5Iox vh7w995083AolKuaLn3q1GpsyysEnHLG2OLsBtnFS8alONLPesN/dQ7rIZA+K2jHsb JemjMrst8VWPU1Y0q5zVcEzSdnyOG+Osf3rwfgbE= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexey Kirillov To: Eric Blake , Thomas Huth , Markus Armbruster Subject: [PATCH v2 2/4] tests: Add tests for query-netdevs command Date: Wed, 4 Mar 2020 16:06:54 +0300 Message-Id: <20200304130656.16859-3-lekiravi@yandex-team.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304130656.16859-1-lekiravi@yandex-team.ru> References: <20200304130656.16859-1-lekiravi@yandex-team.ru> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:6b8:0:1619::183 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , qemu-devel@nongnu.org, Vincenzo Maffione , Gerd Hoffmann , "Edgar E. Iglesias" , Sven Schnelle , Rob Herring , Stefano Stabellini , Paul Durrant , Joel Stanley , Anthony Perard , Samuel Thibault , Aleksandar Rikalo , David Gibson , Laurent Vivier , Jiri Pirko , yc-core@yandex-team.ru, Stefan Weil , Alistair Francis , Beniamino Galvani , qemu-arm@nongnu.org, Peter Chubb , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , xen-devel@lists.xenproject.org, Giuseppe Lettieri , Luigi Rizzo , Richard Henderson , Andrew Jeffery , Michael Walle , qemu-ppc@nongnu.org, Aleksandar Markovic , Alexey Kirillov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alexey Kirillov --- tests/qtest/Makefile.include | 2 + tests/qtest/test-query-netdevs.c | 120 +++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 tests/qtest/test-query-netdevs.c diff --git a/tests/qtest/Makefile.include b/tests/qtest/Makefile.include index e769c1ad70..6924843ef9 100644 --- a/tests/qtest/Makefile.include +++ b/tests/qtest/Makefile.include @@ -9,6 +9,7 @@ check-qtest-generic-y +=3D qmp-cmd-test check-qtest-generic-y +=3D qom-test check-qtest-generic-$(CONFIG_MODULES) +=3D modules-test check-qtest-generic-y +=3D test-hmp +check-qtest-generic-$(CONFIG_SLIRP) +=3D test-query-netdevs =20 check-qtest-pci-$(CONFIG_RTL8139_PCI) +=3D rtl8139-test check-qtest-pci-$(CONFIG_VGA) +=3D display-vga-test @@ -303,6 +304,7 @@ tests/qtest/tpm-crb-test$(EXESUF): tests/qtest/tpm-crb-= test.o tests/qtest/tpm-em tests/qtest/tpm-tis-swtpm-test$(EXESUF): tests/qtest/tpm-tis-swtpm-test.o = tests/qtest/tpm-emu.o \ tests/qtest/tpm-util.o tests/qtest/tpm-tests.o $(test-io-obj-y) tests/qtest/tpm-tis-test$(EXESUF): tests/qtest/tpm-tis-test.o tests/qtest/= tpm-emu.o $(test-io-obj-y) +tests/qtest/test-query-netdevs$(EXESUF): tests/qtest/test-query-netdevs.o =20 # QTest rules =20 diff --git a/tests/qtest/test-query-netdevs.c b/tests/qtest/test-query-netd= evs.c new file mode 100644 index 0000000000..e077358a50 --- /dev/null +++ b/tests/qtest/test-query-netdevs.c @@ -0,0 +1,120 @@ +/* + * QTest testcase for the query-netdevs + * + * Copyright Yandex N.V., 2019 + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" + +#include "libqtest.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" + +/* + * Events can get in the way of responses we are actually waiting for. + */ +GCC_FMT_ATTR(2, 3) +static QObject *wait_command(QTestState *who, const char *command, ...) +{ + va_list ap; + QDict *response; + QObject *result; + + va_start(ap, command); + qtest_qmp_vsend(who, command, ap); + va_end(ap); + + response =3D qtest_qmp_receive(who); + + result =3D qdict_get(response, "return"); + g_assert(result); + qobject_ref(result); + qobject_unref(response); + + return result; +} + +static void qmp_query_netdevs_no_error(QTestState *qts, + size_t netdevs_count) +{ + QObject *resp; + QList *netdevs; + + resp =3D wait_command(qts, "{'execute': 'query-netdevs'}"); + + netdevs =3D qobject_to(QList, resp); + g_assert(netdevs); + g_assert(qlist_size(netdevs) =3D=3D netdevs_count); + + qobject_unref(resp); +} + +static void test_query_netdevs(void) +{ + const char *arch =3D qtest_get_arch(); + size_t correction =3D 0; + QObject *resp; + QTestState *state; + + /* Archs which still have a netdev despite of -nodefaults */ + if (g_str_equal(arch, "cris") || + g_str_equal(arch, "microblaze") || + g_str_equal(arch, "microblazeel") || + g_str_equal(arch, "sparc")) { + correction =3D 1; + } + + if (g_str_equal(arch, "arm") || + g_str_equal(arch, "aarch64")) { + state =3D qtest_init( + "-nodefaults " + "-M virt " + "-netdev user,id=3Dslirp0"); + } else if (g_str_equal(arch, "tricore")) { + state =3D qtest_init( + "-nodefaults " + "-M tricore_testboard " + "-netdev user,id=3Dslirp0"); + } else { + state =3D qtest_init( + "-nodefaults " + "-netdev user,id=3Dslirp0"); + } + g_assert(state); + + qmp_query_netdevs_no_error(state, 1 + correction); + + resp =3D wait_command(state, + "{'execute': 'netdev_add', 'arguments': {" + " 'id': 'slirp1'," + " 'type': 'user'}}"); + qobject_unref(resp); + + qmp_query_netdevs_no_error(state, 2 + correction); + + resp =3D wait_command(state, + "{'execute': 'netdev_del', 'arguments': {" + " 'id': 'slirp1'}}"); + qobject_unref(resp); + + qmp_query_netdevs_no_error(state, 1 + correction); + + qtest_quit(state); +} + +int main(int argc, char **argv) +{ + int ret =3D 0; + g_test_init(&argc, &argv, NULL); + + qtest_add_func("/net/qapi/query_netdevs", + test_query_netdevs); + + ret =3D g_test_run(); + + return ret; +} --=20 2.17.1 From nobody Sun May 19 20:13:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1583327330; cv=none; d=zohomail.com; s=zohoarc; b=Mh70SqCKJqMDwg3CV53G0Zlc4pOqVi4MT7+X2AeX5mYHzI0M8vdydeaYSXJTgF49QbFMDIj4xMRPkdLVAzVW9Y0tBMmbQPt71KPIHcYaHUCcmnILr6nvBC2OQ9YqmMbvqZ0i1SEHrhs9137LDNXJjo68fUtCPocVlSCISyNOSZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583327330; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=tTDvuiSO8FFJBQlIbfJ4TO8Uc4zxjf0cSMuuGhZLZT0=; b=BT/d9Ukyf6JFDEAr1NtUAmjK0SMyGda0LcxAs6f+knwMAgdcEmxQfnjdqWHk0ZPOCrwTu1DyIiBzurCDru5Ag1oSHXeXsOys+05alKzSW5FBmukPV5ky+qF0Xa9YLqT6nq0dsa++4EhykReBYmVBoo4ogb3PidVQ054lA7qhWek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583327330762176.39314482568238; Wed, 4 Mar 2020 05:08:50 -0800 (PST) Received: from localhost ([::1]:34058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9TlZ-0004rL-Li for importer@patchew.org; Wed, 04 Mar 2020 08:08:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37255) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9TkM-0002sg-RS for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9TkL-0001OF-5q for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:34 -0500 Received: from forwardcorp1p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b6:217]:44946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9TkH-00019i-HZ; Wed, 04 Mar 2020 08:07:29 -0500 Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 13D102E1649; Wed, 4 Mar 2020 16:07:27 +0300 (MSK) Received: from sas1-9998cec34266.qloud-c.yandex.net (sas1-9998cec34266.qloud-c.yandex.net [2a02:6b8:c14:3a0e:0:640:9998:cec3]) by mxbackcorp1g.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id 9Imv48VQsj-7NESTh5B; Wed, 04 Mar 2020 16:07:26 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:b4f7:3f29:4fea:8822]) by sas1-9998cec34266.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ujb0Gsh6CR-7NWOtUTS; Wed, 04 Mar 2020 16:07:23 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1583327247; bh=tTDvuiSO8FFJBQlIbfJ4TO8Uc4zxjf0cSMuuGhZLZT0=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=AIsqSV/iOe/tcW44q8wqeElZn3bbSNMmxNGBUhstrIG49W+B1NH78k/azN61vuBAr 9AX76wjxsiE0L/T7u7G4hh3bLZDdlCmMnw2SE8W4lf0VaM+aa+G9Ylpm70Nz1X/O9a sJwkvMkF9rCSCoGcm1q7v+acvjiUecXTeOnsU4EA= Authentication-Results: mxbackcorp1g.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexey Kirillov To: Eric Blake , Thomas Huth , Markus Armbruster Subject: [PATCH v2 3/4] hmp: Use QMP query-netdevs in hmp_info_network Date: Wed, 4 Mar 2020 16:06:55 +0300 Message-Id: <20200304130656.16859-4-lekiravi@yandex-team.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304130656.16859-1-lekiravi@yandex-team.ru> References: <20200304130656.16859-1-lekiravi@yandex-team.ru> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:6b8:0:1472:2741:0:8b6:217 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , qemu-devel@nongnu.org, Vincenzo Maffione , Gerd Hoffmann , "Edgar E. Iglesias" , Sven Schnelle , Rob Herring , Stefano Stabellini , Paul Durrant , Joel Stanley , Anthony Perard , Samuel Thibault , Aleksandar Rikalo , David Gibson , Laurent Vivier , Jiri Pirko , yc-core@yandex-team.ru, Stefan Weil , Alistair Francis , Beniamino Galvani , qemu-arm@nongnu.org, Peter Chubb , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , xen-devel@lists.xenproject.org, Giuseppe Lettieri , Luigi Rizzo , Richard Henderson , Andrew Jeffery , Michael Walle , qemu-ppc@nongnu.org, Aleksandar Markovic , Alexey Kirillov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Replace legacy field info_str of NetClientState with result of QMP command query-netdevs. Signed-off-by: Alexey Kirillov --- include/net/net.h | 3 +- net/clients.h | 1 + net/hub.c | 4 +- net/hub.h | 2 +- net/net.c | 175 ++++++++++++++++++++++++++++++++++++++++++++-- net/vde.c | 10 +++ 6 files changed, 186 insertions(+), 9 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 2c8956c0b3..9df4680937 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -171,7 +171,8 @@ void qemu_check_nic_model(NICInfo *nd, const char *mode= l); int qemu_find_nic_model(NICInfo *nd, const char * const *models, const char *default_model); =20 -void print_net_client(Monitor *mon, NetClientState *nc); +void print_net_client(Monitor *mon, NetClientState *nc, + NetdevInfoList *ni_list); void hmp_info_network(Monitor *mon, const QDict *qdict); void net_socket_rs_init(SocketReadState *rs, SocketReadStateFinalize *finalize, diff --git a/net/clients.h b/net/clients.h index a6ef267e19..f439933522 100644 --- a/net/clients.h +++ b/net/clients.h @@ -51,6 +51,7 @@ int net_init_l2tpv3(const Netdev *netdev, const char *nam= e, #ifdef CONFIG_VDE int net_init_vde(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); +int net_vde_get_fd(const NetClientState *nc); #endif =20 #ifdef CONFIG_NETMAP diff --git a/net/hub.c b/net/hub.c index 37995b5517..cce970b59d 100644 --- a/net/hub.c +++ b/net/hub.c @@ -252,7 +252,7 @@ NetClientState *net_hub_port_find(int hub_id) /** * Print hub configuration */ -void net_hub_info(Monitor *mon) +void net_hub_info(Monitor *mon, NetdevInfoList *ni_list) { NetHub *hub; NetHubPort *port; @@ -263,7 +263,7 @@ void net_hub_info(Monitor *mon) monitor_printf(mon, " \\ %s", port->nc.name); if (port->nc.peer) { monitor_printf(mon, ": "); - print_net_client(mon, port->nc.peer); + print_net_client(mon, port->nc.peer, ni_list); } else { monitor_printf(mon, "\n"); } diff --git a/net/hub.h b/net/hub.h index 66d3322fac..424658a4a2 100644 --- a/net/hub.h +++ b/net/hub.h @@ -19,7 +19,7 @@ NetClientState *net_hub_add_port(int hub_id, const char *name, NetClientState *hubpeer); NetClientState *net_hub_find_client_by_name(int hub_id, const char *name); -void net_hub_info(Monitor *mon); +void net_hub_info(Monitor *mon, NetdevInfoList *ninfo); void net_hub_check_clients(void); bool net_hub_flush(NetClientState *nc); =20 diff --git a/net/net.c b/net/net.c index 01e0548295..1a8153dbf7 100644 --- a/net/net.c +++ b/net/net.c @@ -1271,14 +1271,176 @@ static void netfilter_print_info(Monitor *mon, Net= FilterState *nf) monitor_printf(mon, "\n"); } =20 -void print_net_client(Monitor *mon, NetClientState *nc) +static NetdevInfo *get_netdev_info(NetdevInfoList *ni_list, char *name) +{ + NetdevInfo *ni; + + while (ni_list) { + ni =3D ni_list->value; + if (g_str_equal(ni->id, name)) { + return ni; + } + ni_list =3D ni_list->next; + } + + return NULL; +} + +static char *generate_info_str(NetdevInfo *ni, NetClientState *nc) +{ + char *info_str; + + if (!ni) { + return g_malloc0(1); + } + + switch (ni->type) { + case NET_CLIENT_DRIVER_NIC: { + info_str =3D g_strdup_printf("model=3D%s,macaddr=3D%s", + ni->u.nic.model, + ni->u.nic.macaddr); + break; + } +#ifdef CONFIG_SLIRP + case NET_CLIENT_DRIVER_USER: { + size_t len =3D strchr(ni->u.user.net, '/') - ni->u.user.net; + char *net =3D g_strndup(ni->u.user.net, len); + + info_str =3D g_strdup_printf("net=3D%s,restrict=3D%s", + net, + ni->u.user.q_restrict ? "on" : "off= "); + g_free(net); + break; + } +#endif /* CONFIG_SLIRP */ + case NET_CLIENT_DRIVER_TAP: { +#ifndef _WIN32 + if (ni->u.tap.has_fds) { + char **fds =3D g_strsplit(ni->u.tap.fds, ":", -1); + + info_str =3D g_strdup_printf("fd=3D%s", fds[nc->queue_inde= x]); + g_strfreev(fds); + } else if (ni->u.tap.has_helper) { + info_str =3D g_strdup_printf("helper=3D%s", ni->u.tap.help= er); + } else { + info_str =3D g_strdup_printf("ifname=3D%s,script=3D%s,down= script=3D%s", + ni->u.tap.ifname, + nc->queue_index =3D=3D 0 ? ni->u.tap.script : "no", + nc->queue_index =3D=3D 0 ? ni->u.tap.downscript : "no"= ); + } +#else + info_str =3D g_strdup_printf("tap: ifname=3D%s", ni->u.tap.ifn= ame); +#endif /* _WIN32 */ + break; + } +#ifdef CONFIG_L2TPV3 + case NET_CLIENT_DRIVER_L2TPV3: { + info_str =3D g_strdup_printf("l2tpv3: connected"); + break; + } +#endif /* CONFIG_L2TPV3 */ + case NET_CLIENT_DRIVER_SOCKET: { + if (ni->u.socket.has_listen) { + if (ni->u.socket.has_fd) { + info_str =3D g_strdup_printf("socket: connection from = %s", + ni->u.socket.listen); + } else { + info_str =3D g_strdup_printf("socket: wait from %s", + ni->u.socket.listen); + } + } else if (ni->u.socket.has_connect && ni->u.socket.has_fd) { + info_str =3D g_strdup_printf("socket: connect to %s", + ni->u.socket.connect); + } else if (ni->u.socket.has_mcast && ni->u.socket.has_fd) { + info_str =3D g_strdup_printf("socket: mcast=3D%s", + ni->u.socket.mcast); + } else if (ni->u.socket.has_udp && ni->u.socket.has_fd) { + info_str =3D g_strdup_printf("socket: udp=3D%s", ni->u.soc= ket.udp); + } else { + g_assert(ni->u.socket.has_fd); + int so_type =3D -1; + int optlen =3D sizeof(so_type); + int fd =3D atoi(ni->u.socket.fd); + + getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type, + (socklen_t *)&optlen); + if (so_type =3D=3D SOCK_STREAM) { + info_str =3D g_strdup_printf("socket: fd=3D%s", + ni->u.socket.fd); + } else { + if (ni->u.socket.has_mcast) { + /* + * This branch is unreachable, according to how it= is in + * net/socket.c at this moment + */ + info_str =3D g_strdup_printf("socket: fd=3D%s " + "(cloned mcast=3D%s)", + ni->u.socket.fd, + ni->u.socket.mcast); + } else { + SocketAddress *sa =3D socket_local_address(fd, NUL= L); + + info_str =3D g_strdup_printf("socket: fd=3D%s %s", + ni->u.socket.fd, + SocketAddressType_str(sa->type)); + qapi_free_SocketAddress(sa); + } + } + } + break; + } +#ifdef CONFIG_VDE + case NET_CLIENT_DRIVER_VDE: { + info_str =3D g_strdup_printf("sock=3D%s,fd=3D%d", + ni->u.vde.sock, + net_vde_get_fd(nc)); + break; + } +#endif /* CONFIG_VDE */ +#ifdef CONFIG_NET_BRIDGE + case NET_CLIENT_DRIVER_BRIDGE: { + info_str =3D g_strdup_printf("helper=3D%s,br=3D%s", + ni->u.bridge.helper, + ni->u.bridge.br); + break; + } +#endif /* CONFIG_NET_BRIDGE */ +#ifdef CONFIG_NETMAP + case NET_CLIENT_DRIVER_NETMAP: { + info_str =3D g_strdup_printf("netmap: ifname=3D%s", + ni->u.netmap.ifname); + break; + } +#endif /* CONFIG_NETMAP */ +#ifdef CONFIG_VHOST_NET_USER + case NET_CLIENT_DRIVER_VHOST_USER: { + info_str =3D g_strdup_printf("vhost-user%d to %s", + nc->queue_index, + ni->u.vhost_user.chardev); + break; + } +#endif /* CONFIG_VHOST_NET_USER */ + default: { + info_str =3D g_malloc0(1); + break; + } + } + + return info_str; +} + +void print_net_client(Monitor *mon, NetClientState *nc, NetdevInfoList *ni= _list) { NetFilterState *nf; + NetdevInfo *ni =3D get_netdev_info(ni_list, nc->name); + char *info_str =3D generate_info_str(ni, nc); =20 monitor_printf(mon, "%s: index=3D%d,type=3D%s,%s\n", nc->name, nc->queue_index, NetClientDriver_str(nc->info->type), - nc->info_str); + info_str); + g_free(info_str); + if (!QTAILQ_EMPTY(&nc->filters)) { monitor_printf(mon, "filters:\n"); } @@ -1415,8 +1577,9 @@ void hmp_info_network(Monitor *mon, const QDict *qdic= t) { NetClientState *nc, *peer; NetClientDriver type; + NetdevInfoList *ni_list =3D qmp_query_netdevs(NULL); =20 - net_hub_info(mon); + net_hub_info(mon, ni_list); =20 QTAILQ_FOREACH(nc, &net_clients, next) { peer =3D nc->peer; @@ -1428,13 +1591,15 @@ void hmp_info_network(Monitor *mon, const QDict *qd= ict) } =20 if (!peer || type =3D=3D NET_CLIENT_DRIVER_NIC) { - print_net_client(mon, nc); + print_net_client(mon, nc, ni_list); } /* else it's a netdev connected to a NIC, printed with the NIC */ if (peer && type =3D=3D NET_CLIENT_DRIVER_NIC) { monitor_printf(mon, " \\ "); - print_net_client(mon, peer); + print_net_client(mon, peer, ni_list); } } + + qapi_free_NetdevInfoList(ni_list); } =20 void colo_notify_filters_event(int event, Error **errp) diff --git a/net/vde.c b/net/vde.c index c0ab2bb65c..c4edf5cba1 100644 --- a/net/vde.c +++ b/net/vde.c @@ -153,3 +153,13 @@ int net_init_vde(const Netdev *netdev, const char *nam= e, =20 return 0; } + +int net_vde_get_fd(const NetClientState *nc) +{ + VDEState *s; + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VDE); + + s =3D DO_UPCAST(VDEState, nc, nc); + + return vde_datafd(s->vde); +} --=20 2.17.1 From nobody Sun May 19 20:13:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1583327405; cv=none; d=zohomail.com; s=zohoarc; b=ktu6XqV/4isFfBYwR5GamjDAU+zvIVY04YlXeRNrXDCgBOWWixo5kCf9wPjHySM3kk1Bsb6wOZBIc0pyqXsjczZxtPSHmhlDkF+teEpQp0HdVLVb2+m1ZoeT6NywRux/SyQ4INMurb8PdpBlAx6tu5WMhFR1/cFgfx1Qq9pJuK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583327405; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=nlxUiX0vPzTyUjbVc3grdclin00oPgm2S/Tp+BITx2w=; b=gojSmAQ2Xt+spHWooDvFght6lVnjs6iDvjhZGGHn+b/VemiVMiQIhQN13d1ZnoFpc6IkHi+VsBHAQvGHZmLQ8Ce0Xu4jdqmlNHZXyLLOCRmoLnzCgV+kVTlYx2AcJczfomJqzmB4GZCGjUCq2FnzSh6FSUHCFOuxp1i9Jt0UEbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583327405334111.0337090576869; Wed, 4 Mar 2020 05:10:05 -0800 (PST) Received: from localhost ([::1]:34118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Tml-0007Hs-Le for importer@patchew.org; Wed, 04 Mar 2020 08:10:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Tkb-0003B8-7u for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9TkW-0001n7-Ny for qemu-devel@nongnu.org; Wed, 04 Mar 2020 08:07:49 -0500 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]:43706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9TkP-0001UW-1u; Wed, 04 Mar 2020 08:07:37 -0500 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id B6DE92E1764; Wed, 4 Mar 2020 16:07:35 +0300 (MSK) Received: from sas1-9998cec34266.qloud-c.yandex.net (sas1-9998cec34266.qloud-c.yandex.net [2a02:6b8:c14:3a0e:0:640:9998:cec3]) by mxbackcorp1o.mail.yandex.net (mxbackcorp/Yandex) with ESMTP id Gfkc1GFItu-7SaiCmmE; Wed, 04 Mar 2020 16:07:35 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:b4f7:3f29:4fea:8822]) by sas1-9998cec34266.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ujb0Gsh6CR-7RWOip7E; Wed, 04 Mar 2020 16:07:27 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1583327255; bh=nlxUiX0vPzTyUjbVc3grdclin00oPgm2S/Tp+BITx2w=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=OOsV/a4j175NykMjjUVdUCu/5E0pLhN7XJaXC2wCwFNIEzJV9AfrVT+jCWcKMMexL qjjfOoetQbMg33IOQRGqDSYKQhcjK2NxA35ybSeTiUyq9L5fEnk5H6vvWFhaQuB0KP bCefIHXhVH5euwuqMECnR3gmYZfPGOTOb7uS00IU= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexey Kirillov To: Eric Blake , Thomas Huth , Markus Armbruster Subject: [PATCH v2 4/4] net: Remove field info_str of NetClientState Date: Wed, 4 Mar 2020 16:06:56 +0300 Message-Id: <20200304130656.16859-5-lekiravi@yandex-team.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304130656.16859-1-lekiravi@yandex-team.ru> References: <20200304130656.16859-1-lekiravi@yandex-team.ru> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:6b8:0:1a2d::193 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dmitry Fleytman , "Michael S. Tsirkin" , Jason Wang , qemu-devel@nongnu.org, Vincenzo Maffione , Gerd Hoffmann , "Edgar E. Iglesias" , Sven Schnelle , Rob Herring , Stefano Stabellini , Paul Durrant , Joel Stanley , Anthony Perard , Samuel Thibault , Aleksandar Rikalo , David Gibson , Laurent Vivier , Jiri Pirko , yc-core@yandex-team.ru, Stefan Weil , Alistair Francis , Beniamino Galvani , qemu-arm@nongnu.org, Peter Chubb , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , xen-devel@lists.xenproject.org, Giuseppe Lettieri , Luigi Rizzo , Richard Henderson , Andrew Jeffery , Michael Walle , qemu-ppc@nongnu.org, Aleksandar Markovic , Alexey Kirillov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Completely remove the info_str field of struct NetClientState because it is no longer required due to the addition of the QMP query-netdevs comma= nd. Signed-off-by: Alexey Kirillov Reviewed-by: Laurent Vivier Tested-by: Laurent Vivier --- hw/net/allwinner_emac.c | 2 +- hw/net/dp8393x.c | 2 +- hw/net/e1000.c | 4 ++-- hw/net/e1000e.c | 2 +- hw/net/e1000e_core.c | 2 +- hw/net/e1000x_common.c | 2 +- hw/net/eepro100.c | 5 +++-- hw/net/etraxfs_eth.c | 2 +- hw/net/fsl_etsec/etsec.c | 2 +- hw/net/ftgmac100.c | 2 +- hw/net/i82596.c | 6 +++--- hw/net/imx_fec.c | 2 +- hw/net/lan9118.c | 4 ++-- hw/net/mcf_fec.c | 2 +- hw/net/milkymist-minimac2.c | 2 +- hw/net/mipsnet.c | 2 +- hw/net/ne2000-isa.c | 2 +- hw/net/ne2000-pci.c | 2 +- hw/net/pcnet.c | 2 +- hw/net/rocker/rocker_fp.c | 4 ++-- hw/net/rtl8139.c | 6 +++--- hw/net/smc91c111.c | 2 +- hw/net/spapr_llan.c | 6 +++--- hw/net/stellaris_enet.c | 2 +- hw/net/sungem.c | 4 ++-- hw/net/sunhme.c | 2 +- hw/net/tulip.c | 2 +- hw/net/virtio-net.c | 8 ++++---- hw/net/vmxnet3.c | 4 ++-- hw/net/xen_nic.c | 4 ---- hw/net/xgmac.c | 2 +- hw/net/xilinx_axienet.c | 2 +- hw/net/xilinx_ethlite.c | 2 +- hw/usb/dev-network.c | 2 +- include/net/net.h | 3 +-- net/l2tpv3.c | 3 --- net/net.c | 8 +------- net/slirp.c | 4 ---- net/socket.c | 24 ------------------------ net/tap.c | 12 ------------ net/vde.c | 4 ---- net/vhost-user.c | 2 -- 42 files changed, 51 insertions(+), 110 deletions(-) diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c index e9bbff8710..6abbdbfd4b 100644 --- a/hw/net/allwinner_emac.c +++ b/hw/net/allwinner_emac.c @@ -454,7 +454,7 @@ static void aw_emac_realize(DeviceState *dev, Error **e= rrp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_aw_emac_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 fifo8_create(&s->rx_fifo, RX_FIFO_SIZE); fifo8_create(&s->tx_fifo[0], TX_FIFO_SIZE); diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 8a3504d962..a6f95b097b 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -982,7 +982,7 @@ static void dp8393x_realize(DeviceState *dev, Error **e= rrp) =20 s->nic =3D qemu_new_nic(&net_dp83932_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 s->watchdog =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s); =20 diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 0b833d5a15..5ae52e37ea 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -1095,7 +1095,7 @@ mac_writereg(E1000State *s, int index, uint32_t val) if (index =3D=3D RA + 1) { macaddr[0] =3D cpu_to_le32(s->mac_reg[RA]); macaddr[1] =3D cpu_to_le32(s->mac_reg[RA + 1]); - qemu_format_nic_info_str(qemu_get_queue(s->nic), (uint8_t *)macadd= r); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), (uint8_t *)macaddr= ); } } =20 @@ -1711,7 +1711,7 @@ static void pci_e1000_realize(PCIDevice *pci_dev, Err= or **errp) d->nic =3D qemu_new_nic(&net_e1000_info, &d->conf, object_get_typename(OBJECT(d)), dev->id, d); =20 - qemu_format_nic_info_str(qemu_get_queue(d->nic), macaddr); + qemu_update_nic_macaddr(qemu_get_queue(d->nic), macaddr); =20 d->autoneg_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, e1000_autoneg_ti= mer, d); d->mit_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, e1000_mit_timer, d); diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index a91dbdca3c..763661227d 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -333,7 +333,7 @@ e1000e_init_net_peer(E1000EState *s, PCIDevice *pci_dev= , uint8_t *macaddr) trace_e1000e_mac_set_permanent(MAC_ARG(macaddr)); memcpy(s->core.permanent_mac, macaddr, sizeof(s->core.permanent_mac)); =20 - qemu_format_nic_info_str(qemu_get_queue(s->nic), macaddr); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), macaddr); =20 /* Setup virtio headers */ if (s->disable_vnet) { diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 94ea34dca5..358e90b40d 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2731,7 +2731,7 @@ e1000e_mac_setmacaddr(E1000ECore *core, int index, ui= nt32_t val) =20 macaddr[0] =3D cpu_to_le32(core->mac[RA]); macaddr[1] =3D cpu_to_le32(core->mac[RA + 1]); - qemu_format_nic_info_str(qemu_get_queue(core->owner_nic), + qemu_update_nic_macaddr(qemu_get_queue(core->owner_nic), (uint8_t *) macaddr); =20 trace_e1000e_mac_set_sw(MAC_ARG(macaddr)); diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c index 717f9df1c9..ad66dd3d55 100644 --- a/hw/net/e1000x_common.c +++ b/hw/net/e1000x_common.c @@ -145,7 +145,7 @@ void e1000x_reset_mac_addr(NICState *nic, uint32_t *mac= _regs, (i < 2) ? mac_addr[i + 4] << (8 * i) : 0; } =20 - qemu_format_nic_info_str(qemu_get_queue(nic), mac_addr); + qemu_update_nic_macaddr(qemu_get_queue(nic), mac_addr); trace_e1000x_mac_indicate(MAC_ARG(mac_addr)); } =20 diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index f6474f0e68..31cb5c007f 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1867,8 +1867,9 @@ static void e100_nic_realize(PCIDevice *pci_dev, Erro= r **errp) s->nic =3D qemu_new_nic(&net_eepro100_info, &s->conf, object_get_typename(OBJECT(pci_dev)), pci_dev->q= dev.id, s); =20 - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); - TRACE(OTHER, logout("%s\n", qemu_get_queue(s->nic)->info_str)); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); + TRACE(OTHER, logout("macaddr=3D%s\n", + qemu_get_queue(s->nic)->stored_config->u.nic.macad= dr)); =20 qemu_register_reset(nic_reset, s); =20 diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c index 27fd069b96..dccdcb9e67 100644 --- a/hw/net/etraxfs_eth.c +++ b/hw/net/etraxfs_eth.c @@ -620,7 +620,7 @@ static void etraxfs_eth_realize(DeviceState *dev, Error= **errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_etraxfs_info, &s->conf, object_get_typename(OBJECT(s)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 s->phy.read =3D tdk_read; s->phy.write =3D tdk_write; diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index 475f3c887a..1de9c2fff3 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -390,7 +390,7 @@ static void etsec_realize(DeviceState *dev, Error **err= p) =20 etsec->nic =3D qemu_new_nic(&net_etsec_info, &etsec->conf, object_get_typename(OBJECT(dev)), dev->id, e= tsec); - qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macad= dr.a); + qemu_update_nic_macaddr(qemu_get_queue(etsec->nic), etsec->conf.macadd= r.a); =20 etsec->ptimer =3D ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DE= FAULT); ptimer_transaction_begin(etsec->ptimer); diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 2f92b65d4e..14286cac81 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -1037,7 +1037,7 @@ static void ftgmac100_realize(DeviceState *dev, Error= **errp) s->nic =3D qemu_new_nic(&net_ftgmac100_info, &s->conf, object_get_typename(OBJECT(dev)), DEVICE(dev)->i= d, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static const VMStateDescription vmstate_ftgmac100 =3D { diff --git a/hw/net/i82596.c b/hw/net/i82596.c index fe9f2390a9..3d62720920 100644 --- a/hw/net/i82596.c +++ b/hw/net/i82596.c @@ -174,8 +174,8 @@ static void set_individual_address(I82596State *s, uint= 32_t addr) m =3D s->conf.macaddr.a; address_space_read(&address_space_memory, addr + 8, MEMTXATTRS_UNSPECIFIED, m, ETH_ALEN); - qemu_format_nic_info_str(nc, m); - trace_i82596_new_mac(nc->info_str); + qemu_update_nic_macaddr(nc, m); + trace_i82596_new_mac(nc->stored_config->u.nic.macaddr); } =20 static void set_multicast_list(I82596State *s, uint32_t addr) @@ -723,7 +723,7 @@ void i82596_common_init(DeviceState *dev, I82596State *= s, NetClientInfo *info) } s->nic =3D qemu_new_nic(info, &s->conf, object_get_typename(OBJECT(dev= )), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 if (USE_TIMER) { s->flush_queue_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 6a124a154a..e8047ec42e 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -1323,7 +1323,7 @@ static void imx_eth_realize(DeviceState *dev, Error *= *errp) object_get_typename(OBJECT(dev)), DEVICE(dev)->id, s); =20 - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static Property imx_eth_properties[] =3D { diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index da7e0bb0e8..0c1bc0f0eb 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -353,7 +353,7 @@ static void lan9118_update(lan9118_state *s) =20 static void lan9118_mac_changed(lan9118_state *s) { - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static void lan9118_reload_eeprom(lan9118_state *s) @@ -1343,7 +1343,7 @@ static void lan9118_realize(DeviceState *dev, Error *= *errp) =20 s->nic =3D qemu_new_nic(&net_lan9118_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); s->eeprom[0] =3D 0xa5; for (i =3D 0; i < 6; i++) { s->eeprom[i + 1] =3D s->conf.macaddr.a[i]; diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c index 9327ac8a30..5690a48829 100644 --- a/hw/net/mcf_fec.c +++ b/hw/net/mcf_fec.c @@ -641,7 +641,7 @@ static void mcf_fec_realize(DeviceState *dev, Error **e= rrp) =20 s->nic =3D qemu_new_nic(&net_mcf_fec_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static void mcf_fec_instance_init(Object *obj) diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c index 1ba01754ee..1852ec124e 100644 --- a/hw/net/milkymist-minimac2.c +++ b/hw/net/milkymist-minimac2.c @@ -485,7 +485,7 @@ static void milkymist_minimac2_realize(DeviceState *dev= , Error **errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_milkymist_minimac2_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static const VMStateDescription vmstate_milkymist_minimac2_mdio =3D { diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c index 0c578c430c..ca2649d4d2 100644 --- a/hw/net/mipsnet.c +++ b/hw/net/mipsnet.c @@ -255,7 +255,7 @@ static void mipsnet_realize(DeviceState *dev, Error **e= rrp) =20 s->nic =3D qemu_new_nic(&net_mipsnet_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static void mipsnet_sysbus_reset(DeviceState *dev) diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c index e744eff153..f4d7791271 100644 --- a/hw/net/ne2000-isa.c +++ b/hw/net/ne2000-isa.c @@ -74,7 +74,7 @@ static void isa_ne2000_realizefn(DeviceState *dev, Error = **errp) =20 s->nic =3D qemu_new_nic(&net_ne2000_isa_info, &s->c, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->c.macaddr.a); } =20 static Property ne2000_isa_properties[] =3D { diff --git a/hw/net/ne2000-pci.c b/hw/net/ne2000-pci.c index e11d67bf75..e8690f47e2 100644 --- a/hw/net/ne2000-pci.c +++ b/hw/net/ne2000-pci.c @@ -72,7 +72,7 @@ static void pci_ne2000_realize(PCIDevice *pci_dev, Error = **errp) s->nic =3D qemu_new_nic(&net_ne2000_info, &s->c, object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->c.macaddr.a); } =20 static void pci_ne2000_exit(PCIDevice *pci_dev) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index f3f18d8598..ecb1fcb332 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -1719,7 +1719,7 @@ void pcnet_common_init(DeviceState *dev, PCNetState *= s, NetClientInfo *info) =20 qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(info, &s->conf, object_get_typename(OBJECT(dev= )), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 /* Initialize the PROM */ =20 diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c index 4aa7da79b8..ddb2191949 100644 --- a/hw/net/rocker/rocker_fp.c +++ b/hw/net/rocker/rocker_fp.c @@ -240,8 +240,8 @@ FpPort *fp_port_alloc(Rocker *r, char *sw_name, =20 port->nic =3D qemu_new_nic(&fp_port_info, &port->conf, sw_name, NULL, port); - qemu_format_nic_info_str(qemu_get_queue(port->nic), - port->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(port->nic), + port->conf.macaddr.a); =20 fp_port_reset(port); =20 diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index ae4739bc09..a3f42ea567 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -1227,7 +1227,7 @@ static void rtl8139_reset(DeviceState *d) =20 /* restore MAC address */ memcpy(s->phys, s->conf.macaddr.a, 6); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->phys); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->phys); =20 /* reset interrupt mask */ s->IntrStatus =3D 0; @@ -2676,7 +2676,7 @@ static void rtl8139_io_writeb(void *opaque, uint8_t a= ddr, uint32_t val) break; case MAC0+5: s->phys[addr - MAC0] =3D val; - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->phys); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->phys); break; case MAC0+6 ... MAC0+7: /* reserved */ @@ -3398,7 +3398,7 @@ static void pci_rtl8139_realize(PCIDevice *dev, Error= **errp) =20 s->nic =3D qemu_new_nic(&net_rtl8139_info, &s->conf, object_get_typename(OBJECT(dev)), d->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 s->cplus_txbuffer =3D NULL; s->cplus_txbuffer_len =3D 0; diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c index e9eb6f6c05..f23746dc33 100644 --- a/hw/net/smc91c111.c +++ b/hw/net/smc91c111.c @@ -782,7 +782,7 @@ static void smc91c111_realize(DeviceState *dev, Error *= *errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_smc91c111_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); /* ??? Save/restore. */ } =20 diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c index 80f5a1dd37..26b11a21a9 100644 --- a/hw/net/spapr_llan.c +++ b/hw/net/spapr_llan.c @@ -314,7 +314,7 @@ static void spapr_vlan_reset(SpaprVioDevice *sdev) =20 memcpy(&dev->nicconf.macaddr.a, &dev->perm_mac.a, sizeof(dev->nicconf.macaddr.a)); - qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macadd= r.a); + qemu_update_nic_macaddr(qemu_get_queue(dev->nic), dev->nicconf.macaddr= .a); } =20 static void spapr_vlan_realize(SpaprVioDevice *sdev, Error **errp) @@ -327,7 +327,7 @@ static void spapr_vlan_realize(SpaprVioDevice *sdev, Er= ror **errp) =20 dev->nic =3D qemu_new_nic(&net_spapr_vlan_info, &dev->nicconf, object_get_typename(OBJECT(sdev)), sdev->qdev.= id, dev); - qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macadd= r.a); + qemu_update_nic_macaddr(qemu_get_queue(dev->nic), dev->nicconf.macaddr= .a); =20 dev->rxp_timer =3D timer_new_us(QEMU_CLOCK_VIRTUAL, spapr_vlan_flush_r= x_queue, dev); @@ -775,7 +775,7 @@ static target_ulong h_change_logical_lan_mac(PowerPCCPU= *cpu, macaddr >>=3D 8; } =20 - qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macadd= r.a); + qemu_update_nic_macaddr(qemu_get_queue(dev->nic), dev->nicconf.macaddr= .a); =20 return H_SUCCESS; } diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c index cb6e2509ea..aec99bc214 100644 --- a/hw/net/stellaris_enet.c +++ b/hw/net/stellaris_enet.c @@ -493,7 +493,7 @@ static void stellaris_enet_realize(DeviceState *dev, Er= ror **errp) =20 s->nic =3D qemu_new_nic(&net_stellaris_enet_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static Property stellaris_enet_properties[] =3D { diff --git a/hw/net/sungem.c b/hw/net/sungem.c index 89da51f7f6..b3f49b23ae 100644 --- a/hw/net/sungem.c +++ b/hw/net/sungem.c @@ -1361,8 +1361,8 @@ static void sungem_realize(PCIDevice *pci_dev, Error = **errp) s->nic =3D qemu_new_nic(&net_sungem_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), - s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), + s->conf.macaddr.a); } =20 static void sungem_reset(DeviceState *dev) diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c index 8863601f6c..2ff2ef1162 100644 --- a/hw/net/sunhme.c +++ b/hw/net/sunhme.c @@ -892,7 +892,7 @@ static void sunhme_realize(PCIDevice *pci_dev, Error **= errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_sunhme_info, &s->conf, object_get_typename(OBJECT(d)), d->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static void sunhme_instance_init(Object *obj) diff --git a/hw/net/tulip.c b/hw/net/tulip.c index cfac2719d3..36ff10c593 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -964,7 +964,7 @@ static void pci_tulip_realize(PCIDevice *pci_dev, Error= **errp) s->nic =3D qemu_new_nic(&net_tulip_info, &s->c, object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->c.macaddr.a); } =20 static void pci_tulip_exit(PCIDevice *pci_dev) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3627bb1717..ea1992bc84 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -152,7 +152,7 @@ static void virtio_net_set_config(VirtIODevice *vdev, c= onst uint8_t *config) !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && memcmp(netcfg.mac, n->mac, ETH_ALEN)) { memcpy(n->mac, netcfg.mac, ETH_ALEN); - qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); + qemu_update_nic_macaddr(qemu_get_queue(n->nic), n->mac); } } =20 @@ -521,7 +521,7 @@ static void virtio_net_reset(VirtIODevice *vdev) n->mac_table.uni_overflow =3D 0; memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN); memcpy(&n->mac[0], &n->nic->conf->macaddr, sizeof(n->mac)); - qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); + qemu_update_nic_macaddr(qemu_get_queue(n->nic), n->mac); memset(n->vlans, 0, MAX_VLAN >> 3); =20 /* Flush any async TX */ @@ -1009,7 +1009,7 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_= t cmd, } s =3D iov_to_buf(iov, iov_cnt, 0, &n->mac, sizeof(n->mac)); assert(s =3D=3D sizeof(n->mac)); - qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); + qemu_update_nic_macaddr(qemu_get_queue(n->nic), n->mac); rxfilter_notify(nc); =20 return VIRTIO_NET_OK; @@ -3056,7 +3056,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) n->host_hdr_len =3D 0; } =20 - qemu_format_nic_info_str(qemu_get_queue(n->nic), n->nic_conf.macaddr.a= ); + qemu_update_nic_macaddr(qemu_get_queue(n->nic), n->nic_conf.macaddr.a); =20 n->vqs[0].tx_waiting =3D 0; n->tx_burst =3D n->net_conf.txburst; diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 6d91cd8309..3c337739d0 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -366,7 +366,7 @@ static void vmxnet3_set_variable_mac(VMXNET3State *s, u= int32_t h, uint32_t l) =20 VMW_CFPRN("Variable MAC: " MAC_FMT, MAC_ARG(s->conf.macaddr.a)); =20 - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static uint64_t vmxnet3_get_mac_low(MACAddr *addr) @@ -2069,7 +2069,7 @@ static void vmxnet3_net_init(VMXNET3State *s) qemu_using_vnet_hdr(qemu_get_queue(s->nic)->peer, 1); } =20 - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static void diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 00a7fdf843..19476fc08c 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -296,10 +296,6 @@ static int net_init(struct XenLegacyDevice *xendev) netdev->nic =3D qemu_new_nic(&net_xen_info, &netdev->conf, "xen", NULL, netdev); =20 - snprintf(qemu_get_queue(netdev->nic)->info_str, - sizeof(qemu_get_queue(netdev->nic)->info_str), - "nic: xenbus vif macaddr=3D%s", netdev->mac); - /* fill info */ xenstore_write_be_int(&netdev->xendev, "feature-rx-copy", 1); xenstore_write_be_int(&netdev->xendev, "feature-rx-flip", 0); diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c index 574dd47b41..f882026930 100644 --- a/hw/net/xgmac.c +++ b/hw/net/xgmac.c @@ -393,7 +393,7 @@ static void xgmac_enet_realize(DeviceState *dev, Error = **errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_xgmac_enet_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 s->regs[XGMAC_ADDR_HIGH(0)] =3D (s->conf.macaddr.a[5] << 8) | s->conf.macaddr.a[4]; diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c index 704788811a..73cc3f2aa8 100644 --- a/hw/net/xilinx_axienet.c +++ b/hw/net/xilinx_axienet.c @@ -975,7 +975,7 @@ static void xilinx_enet_realize(DeviceState *dev, Error= **errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_xilinx_enet_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); =20 tdk_init(&s->TEMAC.phy); mdio_attach(&s->TEMAC.mdio_bus, &s->TEMAC.phy, s->c_phyaddr); diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index cf07e698b3..37692f15e1 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -235,7 +235,7 @@ static void xilinx_ethlite_realize(DeviceState *dev, Er= ror **errp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_xilinx_ethlite_info, &s->conf, object_get_typename(OBJECT(dev)), dev->id, s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); } =20 static void xilinx_ethlite_init(Object *obj) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 9a78ad928b..52e8e6989a 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1362,7 +1362,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic =3D qemu_new_nic(&net_usbnet_info, &s->conf, object_get_typename(OBJECT(s)), s->dev.qdev.id, = s); - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); + qemu_update_nic_macaddr(qemu_get_queue(s->nic), s->conf.macaddr.a); snprintf(s->usbstring_mac, sizeof(s->usbstring_mac), "%02x%02x%02x%02x%02x%02x", 0x40, diff --git a/include/net/net.h b/include/net/net.h index 9df4680937..b4ca9112aa 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -91,7 +91,6 @@ struct NetClientState { NetQueue *incoming_queue; char *model; char *name; - char info_str[256]; NetdevInfo *stored_config; unsigned receive_disabled : 1; NetClientDestructor *destructor; @@ -155,7 +154,7 @@ ssize_t qemu_send_packet_async(NetClientState *nc, cons= t uint8_t *buf, void qemu_purge_queued_packets(NetClientState *nc); void qemu_flush_queued_packets(NetClientState *nc); void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge); -void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); +void qemu_update_nic_macaddr(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); diff --git a/net/l2tpv3.c b/net/l2tpv3.c index f4e45e7b28..8dccdd625e 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -744,9 +744,6 @@ int net_init_l2tpv3(const Netdev *netdev, if (l2tpv3->has_dstport) { stored->dstport =3D g_strdup(l2tpv3->dstport); } - - snprintf(s->nc.info_str, sizeof(s->nc.info_str), - "l2tpv3: connected"); return 0; outerr: qemu_del_net_client(nc); diff --git a/net/net.c b/net/net.c index 1a8153dbf7..88755e5c1c 100644 --- a/net/net.c +++ b/net/net.c @@ -127,19 +127,13 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr) macaddr[3], macaddr[4], macaddr[5]); } =20 -void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]) +void qemu_update_nic_macaddr(NetClientState *nc, uint8_t macaddr[6]) { g_assert(nc->stored_config); =20 g_free(nc->stored_config->u.nic.macaddr); nc->stored_config->u.nic.macaddr =3D g_strdup_printf(MAC_FMT, MAC_ARG(macaddr)); - - snprintf(nc->info_str, sizeof(nc->info_str), - "model=3D%s,macaddr=3D%02x:%02x:%02x:%02x:%02x:%02x", - nc->model, - macaddr[0], macaddr[1], macaddr[2], - macaddr[3], macaddr[4], macaddr[5]); } =20 static int mac_table[256] =3D {0}; diff --git a/net/slirp.c b/net/slirp.c index fb5b87ebed..24a8877ddc 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -670,10 +670,6 @@ static int net_slirp_init(NetClientState *peer, const = char *model, stored->tftp_server_name =3D g_strdup(tftp_server_name); } =20 - snprintf(nc->info_str, sizeof(nc->info_str), - "net=3D%s,restrict=3D%s", inet_ntoa(net), - restricted ? "on" : "off"); - s =3D DO_UPCAST(SlirpState, nc, nc); =20 s->slirp =3D slirp_init(restricted, ipv4, net, mask, host, diff --git a/net/socket.c b/net/socket.c index 2d2d5419ca..1f8801970c 100644 --- a/net/socket.c +++ b/net/socket.c @@ -180,7 +180,6 @@ static void net_socket_send(void *opaque) s->fd =3D -1; net_socket_rs_init(&s->rs, net_socket_rs_finalize, false); s->nc.link_down =3D true; - memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); =20 return; } @@ -400,16 +399,10 @@ static NetSocketState *net_socket_fd_init_dgram(NetCl= ientState *peer, stored->mcast =3D g_strdup(mcast); =20 s->dgram_dst =3D saddr; - snprintf(nc->info_str, sizeof(nc->info_str), - "socket: fd=3D%d (cloned mcast=3D%s:%d)", - fd, inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); } else { if (sa_type =3D=3D SOCKET_ADDRESS_TYPE_UNIX) { s->dgram_dst.sin_family =3D AF_UNIX; } - - snprintf(nc->info_str, sizeof(nc->info_str), - "socket: fd=3D%d %s", fd, SocketAddressType_str(sa_type)); } =20 return s; @@ -443,9 +436,6 @@ static NetSocketState *net_socket_fd_init_stream(NetCli= entState *peer, NetdevSocketOptions *stored; =20 nc =3D qemu_new_net_client(&net_socket_info, peer, model, name); - - snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=3D%d", fd); - s =3D DO_UPCAST(NetSocketState, nc, nc); =20 s->fd =3D fd; @@ -527,10 +517,6 @@ static void net_socket_accept(void *opaque) =20 stored->has_fd =3D true; stored->fd =3D g_strdup_printf("%d", fd); - - snprintf(s->nc.info_str, sizeof(s->nc.info_str), - "socket: connection from %s:%d", - inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); } =20 static int net_socket_listen_init(NetClientState *peer, @@ -645,9 +631,6 @@ static int net_socket_connect_init(NetClientState *peer, stored->has_connect =3D true; stored->connect =3D g_strdup(host_str); =20 - snprintf(s->nc.info_str, sizeof(s->nc.info_str), - "socket: connect to %s:%d", - inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); return 0; } =20 @@ -704,11 +687,7 @@ static int net_socket_mcast_init(NetClientState *peer, stored->localaddr =3D g_strdup(localaddr_str); } =20 - snprintf(s->nc.info_str, sizeof(s->nc.info_str), - "socket: mcast=3D%s:%d", - inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); return 0; - } =20 static int net_socket_udp_init(NetClientState *peer, @@ -769,9 +748,6 @@ static int net_socket_udp_init(NetClientState *peer, stored->has_udp =3D true; stored->udp =3D g_strdup(rhost); =20 - snprintf(s->nc.info_str, sizeof(s->nc.info_str), - "socket: udp=3D%s:%d", - inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port)); return 0; } =20 diff --git a/net/tap.c b/net/tap.c index f40f378c2a..bd5cb6f5cd 100644 --- a/net/tap.c +++ b/net/tap.c @@ -616,9 +616,6 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, stored->helper =3D g_strdup(helper); } =20 - snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s,br=3D%s"= , helper, - br); - return 0; } =20 @@ -704,8 +701,6 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, stored->fds =3D g_strdup_printf("%s:%d", stored->fds, fd); g_free(tmp_s); } - - snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=3D%d", fd); } else if (tap->has_helper) { if (!stored->has_helper) { stored->has_helper =3D true; @@ -717,9 +712,6 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, stored->br =3D tap->has_br ? g_strdup(tap->br) : g_strdup(DEFAULT_BRIDGE_INTERFACE); } - - snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s", - tap->helper); } else { if (ifname && !stored->has_ifname) { stored->has_ifname =3D true; @@ -736,10 +728,6 @@ static void net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, stored->downscript =3D g_strdup(downscript); } =20 - snprintf(s->nc.info_str, sizeof(s->nc.info_str), - "ifname=3D%s,script=3D%s,downscript=3D%s", ifname, script, - downscript); - if (strcmp(downscript, "no") !=3D 0) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscr= ipt); snprintf(s->down_script_arg, sizeof(s->down_script_arg), diff --git a/net/vde.c b/net/vde.c index c4edf5cba1..cdd27eddd7 100644 --- a/net/vde.c +++ b/net/vde.c @@ -99,10 +99,6 @@ static int net_vde_init(NetClientState *peer, const char= *model, } =20 nc =3D qemu_new_net_client(&net_vde_info, peer, model, name); - - snprintf(nc->info_str, sizeof(nc->info_str), "sock=3D%s,fd=3D%d", - sock, vde_datafd(vde)); - s =3D DO_UPCAST(VDEState, nc, nc); =20 s->vde =3D vde; diff --git a/net/vhost-user.c b/net/vhost-user.c index aa2dc53179..dcc60f9c34 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -323,8 +323,6 @@ static int net_vhost_user_init(NetClientState *peer, co= nst char *device, user =3D g_new0(struct VhostUserState, 1); for (i =3D 0; i < queues; i++) { nc =3D qemu_new_net_client(&net_vhost_user_info, peer, device, nam= e); - snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s", - i, chr->label); nc->queue_index =3D i; if (!nc0) { nc0 =3D nc; --=20 2.17.1