From nobody Fri Apr 19 20:06:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617875129; cv=none; d=zohomail.com; s=zohoarc; b=J3j5JZ5PjZK5OgscwzfgwPEcqvIsWXOUq6DEjYhbmo306H9VIRDMLb423NAQUe+jXuEuIJGeDHkRS64D1AuwLJtInm1s8uhaJRivXExia8/aJ+/zHQHPLUSpvYho/rbI584Cze2ItFhSVXCo3SaMvI4WRdw0z2gMIaoH8rMaU1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617875129; h=Content-Type: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=Bti/Cf7MLGKtgaFTY0iVNxyqMjqliGAJ5CFhCNXzr8s=; b=QnBUnqiXE3sRLYc3pWW8LMw447riwVqRbEiediN+Tso+HZs1nmG7dDCZo/H6wXFPiOLIDz2Tvi7eLPvasY0vP3WUXTLkhDSr6gqiMt7fKRofZsqTKB5NqFKalrff3CdjkW0pu+aKjxVLSjxhbNA9Qfat7GHWJjqZBF7jRPW5D3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1617875129429622.8260982501208; Thu, 8 Apr 2021 02:45:29 -0700 (PDT) Received: from localhost ([::1]:60918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lURE6-0003Ov-AE for importer@patchew.org; Thu, 08 Apr 2021 05:45:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURB9-0001jY-Gl for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURB7-0006Xj-Ak for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-Jg8pZ92XOQO-RM3JIpkgMA-1; Thu, 08 Apr 2021 05:42:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAA03800D53; Thu, 8 Apr 2021 09:42:17 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-61.pek2.redhat.com [10.72.13.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3601010013C1; Thu, 8 Apr 2021 09:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617874940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Bti/Cf7MLGKtgaFTY0iVNxyqMjqliGAJ5CFhCNXzr8s=; b=QH7qxC2Z0PROO1wZsPrzz64jVL+VdDdOqajTGOnFAd+CgjCwyTGsv4jRoeLDtXWRGQRt0L SWmAEOpzhdus9cTf9ArxfKWX8E0RMil4F3uNc5gp6pHmcElzkwbHiX6kHOUNlMV6/1bBui Tx+913tLiw6HpK/Y9CRfmoyKV44c+Vc= X-MC-Unique: Jg8pZ92XOQO-RM3JIpkgMA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 1/6] Revert "net: Do not fill legacy info_str for backends" Date: Thu, 8 Apr 2021 17:42:06 +0800 Message-Id: <1617874931-4437-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1617874931-4437-1-git-send-email-jasowang@redhat.com> References: <1617874931-4437-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Several issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commit f2e8319d456724c3d8514d943dc4607e2f08e88a. Signed-off-by: Jason Wang --- net/l2tpv3.c | 2 ++ net/slirp.c | 3 +++ net/socket.c | 28 ++++++++++++++++++++++++++++ net/tap-win32.c | 2 ++ net/tap.c | 9 +++++++++ net/vde.c | 2 ++ net/vhost-user.c | 1 + net/vhost-vdpa.c | 1 + 8 files changed, 48 insertions(+) diff --git a/net/l2tpv3.c b/net/l2tpv3.c index b7e1d84..96611cb 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -729,6 +729,8 @@ int net_init_l2tpv3(const Netdev *netdev, =20 QAPI_CLONE_MEMBERS(NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); + + s->nc.info_str =3D g_strdup_printf("l2tpv3: connected"); return 0; outerr: qemu_del_net_client(nc); diff --git a/net/slirp.c b/net/slirp.c index a9fdc7a..67f0f1d 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -674,6 +674,9 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, stored->tftp_server_name =3D g_strdup(tftp_server_name); } =20 + nc->info_str =3D g_strdup_printf("net=3D%s,restrict=3D%s", inet_ntoa(n= et), + 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 c0de10c..9817234 100644 --- a/net/socket.c +++ b/net/socket.c @@ -180,6 +180,8 @@ 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; + g_free(s->nc.info_str); + s->nc.info_str =3D g_new0(char, 1); =20 return; } @@ -399,10 +401,16 @@ static NetSocketState *net_socket_fd_init_dgram(NetCl= ientState *peer, stored->mcast =3D g_strdup(mcast); =20 s->dgram_dst =3D saddr; + nc->info_str =3D g_strdup_printf("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; } + + nc->info_str =3D g_strdup_printf("socket: fd=3D%d %s", + fd, SocketAddressType_str(sa_type)); } =20 return s; @@ -437,6 +445,8 @@ static NetSocketState *net_socket_fd_init_stream(NetCli= entState *peer, =20 nc =3D qemu_new_net_client(&net_socket_info, peer, model, name); =20 + nc->info_str =3D g_strdup_printf("socket: fd=3D%d", fd); + s =3D DO_UPCAST(NetSocketState, nc, nc); =20 s->fd =3D fd; @@ -518,6 +528,11 @@ static void net_socket_accept(void *opaque) =20 stored->has_fd =3D true; stored->fd =3D g_strdup_printf("%d", fd); + + g_free(s->nc.info_str); + s->nc.info_str =3D g_strdup_printf("socket: connection from %s:%d", + inet_ntoa(saddr.sin_addr), + ntohs(saddr.sin_port)); } =20 static int net_socket_listen_init(NetClientState *peer, @@ -632,6 +647,10 @@ static int net_socket_connect_init(NetClientState *pee= r, stored->has_connect =3D true; stored->connect =3D g_strdup(host_str); =20 + g_free(s->nc.info_str); + s->nc.info_str =3D g_strdup_printf("socket: connect to %s:%d", + inet_ntoa(saddr.sin_addr), + ntohs(saddr.sin_port)); return 0; } =20 @@ -688,7 +707,12 @@ static int net_socket_mcast_init(NetClientState *peer, stored->localaddr =3D g_strdup(localaddr_str); } =20 + g_free(s->nc.info_str); + s->nc.info_str =3D g_strdup_printf("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, @@ -749,6 +773,10 @@ static int net_socket_udp_init(NetClientState *peer, stored->has_udp =3D true; stored->udp =3D g_strdup(rhost); =20 + g_free(s->nc.info_str); + s->nc.info_str =3D g_strdup_printf("socket: udp=3D%s:%d", + inet_ntoa(raddr.sin_addr), + ntohs(raddr.sin_port)); return 0; } =20 diff --git a/net/tap-win32.c b/net/tap-win32.c index d7c2a87..959266c 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -797,6 +797,8 @@ static int tap_win32_init(NetClientState *peer, const c= har *model, stored->has_ifname =3D true; stored->ifname =3D g_strdup(ifname); =20 + s->nc.info_str =3D g_strdup_printf("tap: ifname=3D%s", ifname); + s->handle =3D handle; =20 qemu_add_wait_object(s->handle->tap_semaphore, tap_win32_send, s); diff --git a/net/tap.c b/net/tap.c index d6d8456..522ce7e 100644 --- a/net/tap.c +++ b/net/tap.c @@ -635,6 +635,8 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, stored->helper =3D g_strdup(helper); } =20 + s->nc.info_str =3D g_strdup_printf("helper=3D%s,br=3D%s", helper, br); + return 0; } =20 @@ -720,6 +722,8 @@ 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); } + + s->nc.info_str =3D g_strdup_printf("fd=3D%d", fd); } else if (tap->has_helper) { if (!stored->has_helper) { stored->has_helper =3D true; @@ -731,6 +735,8 @@ 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); } + + s->nc.info_str =3D g_strdup_printf("helper=3D%s", tap->helper); } else { if (ifname && !stored->has_ifname) { stored->has_ifname =3D true; @@ -747,6 +753,9 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, stored->downscript =3D g_strdup(downscript); } =20 + s->nc.info_str =3D g_strdup_printf("ifname=3D%s,script=3D%s,downsc= ript=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 64bdb93..67de6eb 100644 --- a/net/vde.c +++ b/net/vde.c @@ -100,6 +100,8 @@ static int net_vde_init(NetClientState *peer, const cha= r *model, =20 nc =3D qemu_new_net_client(&net_vde_info, peer, model, name); =20 + nc->info_str =3D g_strdup_printf("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 e443c4b..49c9a74 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -327,6 +327,7 @@ 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); + nc->info_str =3D g_strdup_printf("vhost-user%d to %s", i, chr->lab= el); nc->queue_index =3D i; if (!nc0) { nc0 =3D nc; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 5a28bbc..423d717 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -200,6 +200,7 @@ static int net_vhost_vdpa_init(NetClientState *peer, co= nst char *device, stored->has_queues =3D true; stored->queues =3D 1; /* TODO: change when support multiqueue */ =20 + nc->info_str =3D g_strdup_printf(TYPE_VHOST_VDPA); nc->queue_index =3D 0; s =3D DO_UPCAST(VhostVDPAState, nc, nc); vdpa_device_fd =3D qemu_open_old(vhostdev, O_RDWR); --=20 2.7.4 From nobody Fri Apr 19 20:06:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617875161; cv=none; d=zohomail.com; s=zohoarc; b=abVWgrofMvItlVSp2RFeXL6mPyAAXwI14OkvMvNhkRIjB9aTIjXX6o/x1hr628vo4eY+wKphCKWImHl61CBwug18hrPzLuPFbTLlDDcMlpDETa4ulLAEMItPML0JK+MbXPCZfgCyy9PookLj9kzSC0y0UKwjcORuS9ojAW25dEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617875161; h=Content-Type: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=ZkuS0UgennDd/ogrm0obBLVGSjKWr+lGmi/zHrM45ZY=; b=lzoZdpKxCPGuuFEcamlPJelXatk0s9tyGj/tIEARfal9z0DTvXZh0tTC1cTu+sZOuWB8RUel2OYMYH/LqfeHhebtGR3fuYMj7WHGnpUAX+foqqXDyRPKEfbVQZev6sRrg469N7ZarxcQZPYJstWW5OPMwd7cM0Vv87olsmx6KVk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1617875161452966.4264980039209; Thu, 8 Apr 2021 02:46:01 -0700 (PDT) Received: from localhost ([::1]:33070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUREe-0003YO-BV for importer@patchew.org; Thu, 08 Apr 2021 05:46:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBC-0001qV-LZ for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBA-0006Zv-E3 for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-600-M4rqIh_tO_iRnzbYKSvbWA-1; Thu, 08 Apr 2021 05:42:20 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5FA81006C80; Thu, 8 Apr 2021 09:42:19 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-61.pek2.redhat.com [10.72.13.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6729410013C1; Thu, 8 Apr 2021 09:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617874943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ZkuS0UgennDd/ogrm0obBLVGSjKWr+lGmi/zHrM45ZY=; b=WvC1rLD5zF3S7I86DFQyYhNEeCUhFkFBCx45JdBK6d76A4H1RQFd+HjImxNbAuqBrnSiGb GSIE1+yA1n4inAGV7F2IWoTVh9SxBxVUNpZ+0YZqzXNF2Zz1UTFYDhFtOEbreDoW2xtQpR /zE5T6WPtP5xeCktbyvgMFsX7j1o7NA= X-MC-Unique: M4rqIh_tO_iRnzbYKSvbWA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 2/6] Revert "hmp: Use QAPI NetdevInfo in hmp_info_network" Date: Thu, 8 Apr 2021 17:42:07 +0800 Message-Id: <1617874931-4437-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1617874931-4437-1-git-send-email-jasowang@redhat.com> References: <1617874931-4437-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Several issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commit a0724776c5a98a08fc946bb5a4ad16410ca64c0e. Signed-off-by: Jason Wang --- include/qapi/hmp-output-visitor.h | 30 ------ net/net.c | 31 +----- qapi/hmp-output-visitor.c | 193 ----------------------------------= ---- qapi/meson.build | 1 - 4 files changed, 1 insertion(+), 254 deletions(-) delete mode 100644 include/qapi/hmp-output-visitor.h delete mode 100644 qapi/hmp-output-visitor.c diff --git a/include/qapi/hmp-output-visitor.h b/include/qapi/hmp-output-vi= sitor.h deleted file mode 100644 index 541e400..0000000 --- a/include/qapi/hmp-output-visitor.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * HMP string output Visitor - * - * Copyright Yandex N.V., 2021 - * - * 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. - * - */ - -#ifndef HMP_OUTPUT_VISITOR_H -#define HMP_OUTPUT_VISITOR_H - -#include "qapi/visitor.h" - -typedef struct HMPOutputVisitor HMPOutputVisitor; - -/** - * Create a HMP string output visitor for @obj - * - * Flattens dicts/structures, only shows arrays borders. - * - * Errors are not expected to happen. - * - * The caller is responsible for freeing the visitor with - * visit_free(). - */ -Visitor *hmp_output_visitor_new(char **result); - -#endif diff --git a/net/net.c b/net/net.c index 725a4e1..277da71 100644 --- a/net/net.c +++ b/net/net.c @@ -55,7 +55,6 @@ #include "sysemu/sysemu.h" #include "net/filter.h" #include "qapi/string-output-visitor.h" -#include "qapi/hmp-output-visitor.h" =20 /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32) @@ -1222,42 +1221,14 @@ static void netfilter_print_info(Monitor *mon, NetF= ilterState *nf) monitor_printf(mon, "\n"); } =20 -static char *generate_info_str(NetClientState *nc) -{ - NetdevInfo *ni =3D nc->stored_config; - char *ret_out =3D NULL; - Visitor *v; - - /* Use legacy field info_str for NIC and hubports */ - if ((nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) || - (nc->info->type =3D=3D NET_CLIENT_DRIVER_HUBPORT)) { - return g_strdup(nc->info_str ? nc->info_str : ""); - } - - if (!ni) { - return g_malloc0(1); - } - - v =3D hmp_output_visitor_new(&ret_out); - if (visit_type_NetdevInfo(v, "", &ni, NULL)) { - visit_complete(v, &ret_out); - } - visit_free(v); - - return ret_out; -} - void print_net_client(Monitor *mon, NetClientState *nc) { NetFilterState *nf; - char *info_str =3D generate_info_str(nc); =20 monitor_printf(mon, "%s: index=3D%d,type=3D%s,%s\n", nc->name, nc->queue_index, NetClientDriver_str(nc->info->type), - info_str); - g_free(info_str); - + nc->info_str ? nc->info_str : ""); if (!QTAILQ_EMPTY(&nc->filters)) { monitor_printf(mon, "filters:\n"); } diff --git a/qapi/hmp-output-visitor.c b/qapi/hmp-output-visitor.c deleted file mode 100644 index 8036605..0000000 --- a/qapi/hmp-output-visitor.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * HMP string output Visitor - * - * Copyright Yandex N.V., 2021 - * - * 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 "qemu/cutils.h" -#include "qapi/hmp-output-visitor.h" -#include "qapi/visitor-impl.h" - -struct HMPOutputVisitor { - Visitor visitor; - char **result; - GString *buffer; - bool is_continue; -}; - -static HMPOutputVisitor *to_hov(Visitor *v) -{ - return container_of(v, HMPOutputVisitor, visitor); -} - -static void hmp_output_append_formatted(Visitor *v, const char *fmt, ...) -{ - HMPOutputVisitor *ov =3D to_hov(v); - va_list args; - - if (ov->is_continue) { - g_string_append(ov->buffer, ","); - } else { - ov->is_continue =3D true; - } - - va_start(args, fmt); - g_string_append_vprintf(ov->buffer, fmt, args); - va_end(args); -} - -static void hmp_output_skip_comma(Visitor *v) -{ - HMPOutputVisitor *ov =3D to_hov(v); - - ov->is_continue =3D false; -} - -static bool hmp_output_start_struct(Visitor *v, const char *name, - void **obj, size_t unused, Error **err= p) -{ - return true; -} - -static void hmp_output_end_struct(Visitor *v, void **obj) {} - -static bool hmp_output_start_list(Visitor *v, const char *name, - GenericList **listp, size_t size, - Error **errp) -{ - hmp_output_append_formatted(v, "%s=3D[", name); - /* First element in array without comma before it */ - hmp_output_skip_comma(v); - - return true; -} - -static GenericList *hmp_output_next_list(Visitor *v, GenericList *tail, - size_t size) -{ - return tail->next; -} - -static void hmp_output_end_list(Visitor *v, void **obj) -{ - /* Don't need comma after last array element */ - hmp_output_skip_comma(v); - hmp_output_append_formatted(v, "]"); -} - -static bool hmp_output_type_int64(Visitor *v, const char *name, - int64_t *obj, Error **errp) -{ - hmp_output_append_formatted(v, "%s=3D%" PRId64, name, *obj); - - return true; -} - -static bool hmp_output_type_uint64(Visitor *v, const char *name, - uint64_t *obj, Error **errp) -{ - hmp_output_append_formatted(v, "%s=3D%" PRIu64, name, *obj); - - return true; -} - -static bool hmp_output_type_bool(Visitor *v, const char *name, bool *obj, - Error **errp) -{ - hmp_output_append_formatted(v, "%s=3D%s", name, *obj ? "true" : "false= "); - - return true; -} - -static bool hmp_output_type_str(Visitor *v, const char *name, char **obj, - Error **errp) -{ - /* Skip already printed or unused fields */ - if (!*obj || g_str_equal(name, "id") || g_str_equal(name, "type")) { - return true; - } - - /* Do not print stub name for StringList elements */ - if (g_str_equal(name, "str")) { - hmp_output_append_formatted(v, "%s", *obj); - } else { - hmp_output_append_formatted(v, "%s=3D%s", name, *obj); - } - - return true; -} - -static bool hmp_output_type_number(Visitor *v, const char *name, - double *obj, Error **errp) -{ - hmp_output_append_formatted(v, "%s=3D%.17g", name, *obj); - - return true; -} - -/* TODO: remove this function? */ -static bool hmp_output_type_any(Visitor *v, const char *name, - QObject **obj, Error **errp) -{ - return true; -} - -static bool hmp_output_type_null(Visitor *v, const char *name, - QNull **obj, Error **errp) -{ - hmp_output_append_formatted(v, "%s=3DNULL", name); - - return true; -} - -static void hmp_output_complete(Visitor *v, void *opaque) -{ - HMPOutputVisitor *ov =3D to_hov(v); - - *ov->result =3D g_string_free(ov->buffer, false); - ov->buffer =3D NULL; -} - -static void hmp_output_free(Visitor *v) -{ - HMPOutputVisitor *ov =3D to_hov(v); - - if (ov->buffer) { - g_string_free(ov->buffer, true); - } - g_free(v); -} - -Visitor *hmp_output_visitor_new(char **result) -{ - HMPOutputVisitor *v; - - v =3D g_malloc0(sizeof(*v)); - - v->visitor.type =3D VISITOR_OUTPUT; - v->visitor.start_struct =3D hmp_output_start_struct; - v->visitor.end_struct =3D hmp_output_end_struct; - v->visitor.start_list =3D hmp_output_start_list; - v->visitor.next_list =3D hmp_output_next_list; - v->visitor.end_list =3D hmp_output_end_list; - v->visitor.type_int64 =3D hmp_output_type_int64; - v->visitor.type_uint64 =3D hmp_output_type_uint64; - v->visitor.type_bool =3D hmp_output_type_bool; - v->visitor.type_str =3D hmp_output_type_str; - v->visitor.type_number =3D hmp_output_type_number; - v->visitor.type_any =3D hmp_output_type_any; - v->visitor.type_null =3D hmp_output_type_null; - v->visitor.complete =3D hmp_output_complete; - v->visitor.free =3D hmp_output_free; - - v->result =3D result; - v->buffer =3D g_string_new(""); - v->is_continue =3D false; - - return &v->visitor; -} diff --git a/qapi/meson.build b/qapi/meson.build index 0d20226..376f4ce 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -8,7 +8,6 @@ util_ss.add(files( 'qobject-output-visitor.c', 'string-input-visitor.c', 'string-output-visitor.c', - 'hmp-output-visitor.c', )) if have_system or have_tools util_ss.add(files( --=20 2.7.4 From nobody Fri Apr 19 20:06:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617875404; cv=none; d=zohomail.com; s=zohoarc; b=aZkStZS6hHjV6abkxvLT2idRFKMBpMQHSBT3QQeADewtJW4Xhzqtv5Mpq8zJUZE8zqBF3I9ACfv5azYGRQryCMT6DES79TLGP+XIrBCc4UlTfz6LBFhjT6aGolnzKHJWiCz+b9qjlqiVZfN9ckK5HGIImX1kYT4F3ANAi9AbCT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617875404; h=Content-Type: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=4w5Nihputc01h4L8FNWeyVOONPQOb+c28qA1Q7JKw18=; b=N1ocyLHnhfFJXUszB7vICKu83geiyGLfNofxpo4fgBa/MISeug+bSepUXruyKD4b36I906SIyLi8PPBWJVM1eBfXq3wEiqckFsAyRMiFDbxrCmiMybqkI55MBKVNCGDcwsZVCjPRRaOJxheP0xnv1+U3V3/gehpYUsXabHVAQbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1617875404617832.3872776620809; Thu, 8 Apr 2021 02:50:04 -0700 (PDT) Received: from localhost ([::1]:48594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lURIZ-0001Sq-Ck for importer@patchew.org; Thu, 08 Apr 2021 05:50:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBD-0001rZ-6Y for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBA-0006Zz-U3 for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-_ttg86qxN6WreRD7PqWuJA-1; Thu, 08 Apr 2021 05:42:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE0D6801983; Thu, 8 Apr 2021 09:42:21 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-61.pek2.redhat.com [10.72.13.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51AA910013C1; Thu, 8 Apr 2021 09:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617874944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=4w5Nihputc01h4L8FNWeyVOONPQOb+c28qA1Q7JKw18=; b=KS4IPp2fB89FDN8mbXActRKB+At6nPkn9tLyPL+q4V3QFbwNCpwOfSKKMWaLL/arWJ6SV3 cU8Up40IhAMN9wArvTq5/A09KmkEEpPG05Ec5U5aNSsNFmS9/5GtWSKOT4V1lz3a8bAghy xb3QTzcXAaCbW8S6jKTwtHinEBgj4qY= X-MC-Unique: _ttg86qxN6WreRD7PqWuJA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 3/6] Revert "net: Move NetClientState.info_str to dynamic allocations" Date: Thu, 8 Apr 2021 17:42:08 +0800 Message-Id: <1617874931-4437-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1617874931-4437-1-git-send-email-jasowang@redhat.com> References: <1617874931-4437-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Several issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commit commit 59b5437eb732d6b103a9bc279c3482c834d1eff9. Signed-off-by: Jason Wang --- hw/net/xen_nic.c | 5 +++-- include/net/net.h | 2 +- net/l2tpv3.c | 3 ++- net/net.c | 14 ++++++-------- net/slirp.c | 5 +++-- net/socket.c | 43 +++++++++++++++++++------------------------ net/tap-win32.c | 3 ++- net/tap.c | 13 ++++++++----- net/vde.c | 3 ++- net/vhost-user.c | 3 ++- net/vhost-vdpa.c | 2 +- 11 files changed, 49 insertions(+), 47 deletions(-) diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 8431808..5c815b4 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -296,8 +296,9 @@ static int net_init(struct XenLegacyDevice *xendev) netdev->nic =3D qemu_new_nic(&net_xen_info, &netdev->conf, "xen", NULL, netdev); =20 - qemu_get_queue(netdev->nic)->info_str =3D g_strdup_printf( - "nic: xenbus vif macaddr=3D%s", netdev->mac); + snprintf(qemu_get_queue(netdev->nic)->info_str, + sizeof(qemu_get_queue(netdev->nic)->info_str), + "nic: xenbus vif macaddr=3D%s", netdev->mac); =20 /* fill info */ xenstore_write_be_int(&netdev->xendev, "feature-rx-copy", 1); diff --git a/include/net/net.h b/include/net/net.h index 3559f3c..e5ba61c 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -94,7 +94,7 @@ struct NetClientState { NetQueue *incoming_queue; char *model; char *name; - char *info_str; + char info_str[256]; NetdevInfo *stored_config; unsigned receive_disabled : 1; NetClientDestructor *destructor; diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 96611cb..8aa0a3e 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -730,7 +730,8 @@ int net_init_l2tpv3(const Netdev *netdev, QAPI_CLONE_MEMBERS(NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); =20 - s->nc.info_str =3D g_strdup_printf("l2tpv3: connected"); + 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 277da71..9a2a6ab 100644 --- a/net/net.c +++ b/net/net.c @@ -129,12 +129,11 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr) =20 void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]) { - g_free(nc->info_str); - nc->info_str =3D g_strdup_printf( - "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]); + 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}; @@ -353,7 +352,6 @@ static void qemu_free_net_client(NetClientState *nc) } g_free(nc->name); g_free(nc->model); - g_free(nc->info_str); qapi_free_NetdevInfo(nc->stored_config); if (nc->destructor) { nc->destructor(nc); @@ -1228,7 +1226,7 @@ void print_net_client(Monitor *mon, NetClientState *n= c) 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 ? nc->info_str : ""); + nc->info_str); if (!QTAILQ_EMPTY(&nc->filters)) { monitor_printf(mon, "filters:\n"); } diff --git a/net/slirp.c b/net/slirp.c index 67f0f1d..b3b9798 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -674,8 +674,9 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, stored->tftp_server_name =3D g_strdup(tftp_server_name); } =20 - nc->info_str =3D g_strdup_printf("net=3D%s,restrict=3D%s", inet_ntoa(n= et), - restricted ? "on" : "off"); + snprintf(nc->info_str, sizeof(nc->info_str), + "net=3D%s,restrict=3D%s", inet_ntoa(net), + restricted ? "on" : "off"); =20 s =3D DO_UPCAST(SlirpState, nc, nc); =20 diff --git a/net/socket.c b/net/socket.c index 9817234..1614523 100644 --- a/net/socket.c +++ b/net/socket.c @@ -180,8 +180,7 @@ 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; - g_free(s->nc.info_str); - s->nc.info_str =3D g_new0(char, 1); + memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); =20 return; } @@ -401,16 +400,16 @@ static NetSocketState *net_socket_fd_init_dgram(NetCl= ientState *peer, stored->mcast =3D g_strdup(mcast); =20 s->dgram_dst =3D saddr; - nc->info_str =3D g_strdup_printf("socket: fd=3D%d (cloned mcast=3D= %s:%d)", - fd, inet_ntoa(saddr.sin_addr), - ntohs(saddr.sin_port)); + 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; } =20 - nc->info_str =3D g_strdup_printf("socket: fd=3D%d %s", - fd, SocketAddressType_str(sa_type)); + snprintf(nc->info_str, sizeof(nc->info_str), + "socket: fd=3D%d %s", fd, SocketAddressType_str(sa_type)); } =20 return s; @@ -445,7 +444,7 @@ static NetSocketState *net_socket_fd_init_stream(NetCli= entState *peer, =20 nc =3D qemu_new_net_client(&net_socket_info, peer, model, name); =20 - nc->info_str =3D g_strdup_printf("socket: fd=3D%d", fd); + snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=3D%d", fd); =20 s =3D DO_UPCAST(NetSocketState, nc, nc); =20 @@ -529,10 +528,9 @@ static void net_socket_accept(void *opaque) stored->has_fd =3D true; stored->fd =3D g_strdup_printf("%d", fd); =20 - g_free(s->nc.info_str); - s->nc.info_str =3D g_strdup_printf("socket: connection from %s:%d", - inet_ntoa(saddr.sin_addr), - ntohs(saddr.sin_port)); + 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, @@ -647,10 +645,9 @@ static int net_socket_connect_init(NetClientState *pee= r, stored->has_connect =3D true; stored->connect =3D g_strdup(host_str); =20 - g_free(s->nc.info_str); - s->nc.info_str =3D g_strdup_printf("socket: connect to %s:%d", - inet_ntoa(saddr.sin_addr), - ntohs(saddr.sin_port)); + 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 @@ -707,10 +704,9 @@ static int net_socket_mcast_init(NetClientState *peer, stored->localaddr =3D g_strdup(localaddr_str); } =20 - g_free(s->nc.info_str); - s->nc.info_str =3D g_strdup_printf("socket: mcast=3D%s:%d", - inet_ntoa(saddr.sin_addr), - ntohs(saddr.sin_port)); + 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 } @@ -773,10 +769,9 @@ static int net_socket_udp_init(NetClientState *peer, stored->has_udp =3D true; stored->udp =3D g_strdup(rhost); =20 - g_free(s->nc.info_str); - s->nc.info_str =3D g_strdup_printf("socket: udp=3D%s:%d", - inet_ntoa(raddr.sin_addr), - ntohs(raddr.sin_port)); + 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-win32.c b/net/tap-win32.c index 959266c..2a2ba4f 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -797,7 +797,8 @@ static int tap_win32_init(NetClientState *peer, const c= har *model, stored->has_ifname =3D true; stored->ifname =3D g_strdup(ifname); =20 - s->nc.info_str =3D g_strdup_printf("tap: ifname=3D%s", ifname); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), + "tap: ifname=3D%s", ifname); =20 s->handle =3D handle; =20 diff --git a/net/tap.c b/net/tap.c index 522ce7e..3589519 100644 --- a/net/tap.c +++ b/net/tap.c @@ -635,7 +635,8 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, stored->helper =3D g_strdup(helper); } =20 - s->nc.info_str =3D g_strdup_printf("helper=3D%s,br=3D%s", helper, br); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=3D%s,br=3D%s"= , helper, + br); =20 return 0; } @@ -723,7 +724,7 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, g_free(tmp_s); } =20 - s->nc.info_str =3D g_strdup_printf("fd=3D%d", fd); + 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; @@ -736,7 +737,8 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, g_strdup(DEFAULT_BRIDGE_INTERFACE); } =20 - s->nc.info_str =3D g_strdup_printf("helper=3D%s", tap->helper); + 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; @@ -753,8 +755,9 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, stored->downscript =3D g_strdup(downscript); } =20 - s->nc.info_str =3D g_strdup_printf("ifname=3D%s,script=3D%s,downsc= ript=3D%s", - ifname, script, downscript); + snprintf(s->nc.info_str, sizeof(s->nc.info_str), + "ifname=3D%s,script=3D%s,downscript=3D%s", ifname, script, + downscript); =20 if (strcmp(downscript, "no") !=3D 0) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscr= ipt); diff --git a/net/vde.c b/net/vde.c index 67de6eb..b0b8800 100644 --- a/net/vde.c +++ b/net/vde.c @@ -100,7 +100,8 @@ static int net_vde_init(NetClientState *peer, const cha= r *model, =20 nc =3D qemu_new_net_client(&net_vde_info, peer, model, name); =20 - nc->info_str =3D g_strdup_printf("sock=3D%s,fd=3D%d", sock, vde_datafd= (vde)); + snprintf(nc->info_str, sizeof(nc->info_str), "sock=3D%s,fd=3D%d", + sock, vde_datafd(vde)); =20 s =3D DO_UPCAST(VDEState, nc, nc); =20 diff --git a/net/vhost-user.c b/net/vhost-user.c index 49c9a74..5b7056b 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -327,7 +327,8 @@ 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); - nc->info_str =3D g_strdup_printf("vhost-user%d to %s", i, chr->lab= el); + 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; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 423d717..8c27ea0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -200,7 +200,7 @@ static int net_vhost_vdpa_init(NetClientState *peer, co= nst char *device, stored->has_queues =3D true; stored->queues =3D 1; /* TODO: change when support multiqueue */ =20 - nc->info_str =3D g_strdup_printf(TYPE_VHOST_VDPA); + snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); nc->queue_index =3D 0; s =3D DO_UPCAST(VhostVDPAState, nc, nc); vdpa_device_fd =3D qemu_open_old(vhostdev, O_RDWR); --=20 2.7.4 From nobody Fri Apr 19 20:06:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617875290; cv=none; d=zohomail.com; s=zohoarc; b=b3Jp6LOhiCkyp7U/VKpDSOctkoSuNjGF7OyYZkEtWX0/iPXiGrBJlF4BHUjy9nQxXxxWBu4cC8wbDylObEhrEou+RgwA0cdRF+gKm3OBatWtjRC3W5US20B3YLUIBTv7BHXRr1MZTArUglJlbe4IUbLcyHfRHWn6VYrPIah5kys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617875290; h=Content-Type: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=C8EwJKgctnpz6ecqz/s6LFGA0Jopo1duO2WPMRoenNE=; b=YGXDt8jmXUB+uvfkzr90r/z7U5W5MMce8krdtkl9GKsw8AWmurfdHnJG8NVTQqXgR8Js49WMhnHYMlYjrzyGSumAsEVOPpKl3XPoPJQH/hbOfJ1T/HySb9WYZw9ZCwlWnRBW9lcMEF2MnGX/zV+SCg2vlUlW6qqrbwm9244/yKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1617875290166168.16160626690578; Thu, 8 Apr 2021 02:48:10 -0700 (PDT) Received: from localhost ([::1]:41582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lURGj-00073s-4q for importer@patchew.org; Thu, 08 Apr 2021 05:48:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBJ-00027x-9d for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBC-0006br-T8 for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-BWG3Eey1M2uL9tfV74gdSA-1; Thu, 08 Apr 2021 05:42:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94289107ACE3; Thu, 8 Apr 2021 09:42:23 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-61.pek2.redhat.com [10.72.13.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3880D10013C1; Thu, 8 Apr 2021 09:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617874946; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=C8EwJKgctnpz6ecqz/s6LFGA0Jopo1duO2WPMRoenNE=; b=TyNjXQ68ZSqrMsHfSJRtiL+vI59ieVi0i8+ZZLmmRdyB21tC445OtBSoQTyCILU0Ts1U8Z sgfePSFFPkf81BqYSiIYlqZIwjxz7MSx9+jOF0lRXw9w7LZ/BbIIk9LhavyfD/h+W7rfTo 59AEv5ilGYd6TXnOi635YRR/7HG7KCw= X-MC-Unique: BWG3Eey1M2uL9tfV74gdSA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 4/6] Revert "tests: Add tests for query-netdev command" Date: Thu, 8 Apr 2021 17:42:09 +0800 Message-Id: <1617874931-4437-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1617874931-4437-1-git-send-email-jasowang@redhat.com> References: <1617874931-4437-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Several issues has been reported for query-netdev series. Consider it's late in the rc, this reverts commit 3c3b656885473ef0d699290ba966177f17839aa5. Signed-off-by: Jason Wang --- tests/qtest/meson.build | 3 - tests/qtest/test-query-netdev.c | 120 ------------------------------------= ---- 2 files changed, 123 deletions(-) delete mode 100644 tests/qtest/test-query-netdev.c diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 902cfef..420cd99 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -33,9 +33,6 @@ qtests_generic =3D \ if config_host.has_key('CONFIG_MODULES') qtests_generic +=3D [ 'modules-test' ] endif -if slirp.found() - qtests_generic +=3D [ 'test-query-netdev' ] -endif =20 qtests_pci =3D \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) += \ diff --git a/tests/qtest/test-query-netdev.c b/tests/qtest/test-query-netde= v.c deleted file mode 100644 index 1118537..0000000 --- a/tests/qtest/test-query-netdev.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * QTest testcase for the query-netdev - * - * 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 "libqos/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_netdev_no_error(QTestState *qts, size_t netdevs_coun= t) -{ - QObject *resp; - QList *netdevs; - - resp =3D wait_command(qts, "{'execute': 'query-netdev'}"); - - 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_netdev(void) -{ - const char *arch =3D qtest_get_arch(); - QObject *resp; - QTestState *state; - - /* Choosing machine for platforms without default one */ - 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 if (g_str_equal(arch, "avr")) { - state =3D qtest_init( - "-nodefaults " - "-M mega2560 " - "-netdev user,id=3Dslirp0"); - } else if (g_str_equal(arch, "rx")) { - state =3D qtest_init( - "-nodefaults " - "-M gdbsim-r5f562n8 " - "-netdev user,id=3Dslirp0"); - } else { - state =3D qtest_init( - "-nodefaults " - "-netdev user,id=3Dslirp0"); - } - g_assert(state); - - qmp_query_netdev_no_error(state, 1); - - resp =3D wait_command(state, - "{'execute': 'netdev_add', 'arguments': {" - " 'id': 'slirp1'," - " 'type': 'user'}}"); - qobject_unref(resp); - - qmp_query_netdev_no_error(state, 2); - - resp =3D wait_command(state, - "{'execute': 'netdev_del', 'arguments': {" - " 'id': 'slirp1'}}"); - qobject_unref(resp); - - qmp_query_netdev_no_error(state, 1); - - 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_netdev", test_query_netdev); - - ret =3D g_test_run(); - - return ret; -} --=20 2.7.4 From nobody Fri Apr 19 20:06:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617875411; cv=none; d=zohomail.com; s=zohoarc; b=ccs4bQpt87d6aetjw54mp+eXLO1CqxKB+mEt4/DHKVNtZgUjUEDaUBbdo8L1BRO1sTjBakhjOfsZbqSwLv0tJVlEtNewZ0TMJTkL1Y2rP6SdH/rZs40qfQD+yHh7Gfw2Rrar+0dDeYiID7ToEvR+1PKXtdfaUbxUdqNvX+Jkmm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617875411; h=Content-Type: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=aolsdgFAIZLaAJ4FrGpZLGxPE7CymDqopF003FNXkMw=; b=h3nL178OeTLfJubYuR+MkGbIVKIQP0uvzZD3n1NI4XaumrEWIjVQBlxTyiDuMoun1fDdiJZAPMgUb7tIrIPGu+oc0WgCGrtjBc9n5xaPXCfG7szKZYL5ZWim0P2AOAXjPKh2n25XNo6T2/SOsomE+S+gZMLJnfOFw5i77frmfBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1617875411003926.940827259899; Thu, 8 Apr 2021 02:50:11 -0700 (PDT) Received: from localhost ([::1]:48980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lURIf-0001cK-T0 for importer@patchew.org; Thu, 08 Apr 2021 05:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBR-0002Rz-6s for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBF-0006ds-Ar for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-GTbFoQ7BNZSWajwlN-IRtA-1; Thu, 08 Apr 2021 05:42:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C48823F09; Thu, 8 Apr 2021 09:42:25 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-61.pek2.redhat.com [10.72.13.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2109D10013C1; Thu, 8 Apr 2021 09:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617874948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=aolsdgFAIZLaAJ4FrGpZLGxPE7CymDqopF003FNXkMw=; b=g3LJKF5BOfvE85zQQxYncOAdPPCP2FXjGkWtHHYr+ssy37WyedoLMxa5q5jX/NRtUydQkZ FgoCMHe225hOuxP2n8t4yMxvWcy7z9zPdmWpZJlFp9dYRm/mwDZGgj/2tTKMGlkeFnuZFE 0VFtqxF9AdiMDnYuJs6wTOUOA8Yatcs= X-MC-Unique: GTbFoQ7BNZSWajwlN-IRtA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 5/6] Revert "qapi: net: Add query-netdev command" Date: Thu, 8 Apr 2021 17:42:10 +0800 Message-Id: <1617874931-4437-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1617874931-4437-1-git-send-email-jasowang@redhat.com> References: <1617874931-4437-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Several issues has been reported for query-netdev series. Consider it's late in the rc, this reverts commit d32ad10a14d46dfe9304e3ed5858a11dcd5c71a0. Signed-off-by: Jason Wang --- include/net/net.h | 3 -- net/l2tpv3.c | 7 ---- net/net.c | 30 +------------- net/netmap.c | 7 ---- net/slirp.c | 122 --------------------------------------------------= ---- net/socket.c | 71 ------------------------------- net/tap-win32.c | 9 ---- net/tap.c | 103 +++------------------------------------------ net/vde.c | 22 ---------- net/vhost-user.c | 18 ++------ net/vhost-vdpa.c | 14 ------- qapi/net.json | 80 ----------------------------------- 12 files changed, 9 insertions(+), 477 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index e5ba61c..eff2451 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -5,8 +5,6 @@ #include "qapi/qapi-types-net.h" #include "net/queue.h" #include "hw/qdev-properties-system.h" -#include "qapi/clone-visitor.h" -#include "qapi/qapi-visit-net.h" =20 #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X" #define MAC_ARG(x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \ @@ -95,7 +93,6 @@ 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/l2tpv3.c b/net/l2tpv3.c index 8aa0a3e..e4d4218 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -723,13 +723,6 @@ 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_BACKEND_L2TPV3; - - QAPI_CLONE_MEMBERS(NetdevL2TPv3Options, - &nc->stored_config->u.l2tpv3, l2tpv3); - 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 9a2a6ab..edf9b95 100644 --- a/net/net.c +++ b/net/net.c @@ -36,6 +36,7 @@ #include "monitor/monitor.h" #include "qemu/help_option.h" #include "qapi/qapi-commands-net.h" +#include "qapi/qapi-visit-net.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" @@ -352,7 +353,6 @@ 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); } @@ -1289,34 +1289,6 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name,= const char *name, return filter_list; } =20 -NetdevInfoList *qmp_query_netdev(Error **errp) -{ - NetdevInfoList *list =3D NULL; - NetClientState *nc; - - QTAILQ_FOREACH(nc, &net_clients, next) { - /* - * Only look at netdevs (backend network devices), not for each qu= eue - * or NIC / hubport - */ - if (nc->stored_config) { - NetdevInfo *element =3D QAPI_CLONE(NetdevInfo, nc->stored_conf= ig); - - g_free(element->id); /* Need to dealloc empty id after clone */ - element->id =3D g_strdup(nc->name); - - element->has_peer_id =3D nc->peer !=3D NULL; - if (element->has_peer_id) { - element->peer_id =3D g_strdup(nc->peer->name); - } - - QAPI_LIST_PREPEND(list, element); - } - } - - 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 ad59d4a..350f097 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -427,13 +427,6 @@ 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_BACKEND_NETMAP; - - QAPI_CLONE_MEMBERS(NetdevNetmapOptions, - &nc->stored_config->u.netmap, netmap_opts); - return 0; } =20 diff --git a/net/slirp.c b/net/slirp.c index b3b9798..a01a0fc 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -387,9 +387,6 @@ 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"); @@ -565,115 +562,6 @@ 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_BACKEND_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++) { - String *element =3D g_new0(String, 1); - - element->str =3D g_strdup(dnssearch[i]); - QAPI_LIST_APPEND(stored_list, element); - } - } - - 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"); @@ -703,25 +591,15 @@ 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) { - String *element =3D g_new0(String, 1); - - element->str =3D g_strdup(config->str); if (config->flags & SLIRP_CFG_HOSTFWD) { if (slirp_hostfwd(s, config->str, errp) < 0) { goto error; } - stored->has_hostfwd =3D true; - QAPI_LIST_APPEND(stored_hostfwd, element); } else { if (slirp_guestfwd(s, config->str, errp) < 0) { goto error; } - stored->has_guestfwd =3D true; - QAPI_LIST_APPEND(stored_guestfwd, element); } } #ifndef _WIN32 diff --git a/net/socket.c b/net/socket.c index 1614523..15b410e 100644 --- a/net/socket.c +++ b/net/socket.c @@ -342,7 +342,6 @@ 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) { @@ -386,19 +385,8 @@ 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_BACKEND_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)", @@ -440,7 +428,6 @@ 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 @@ -460,15 +447,6 @@ 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_BACKEND_SOCKET; - stored =3D &nc->stored_config->u.socket; - - stored->has_fd =3D true; - stored->fd =3D g_strdup_printf("%d", fd); - return s; } =20 @@ -505,7 +483,6 @@ static void net_socket_accept(void *opaque) struct sockaddr_in saddr; socklen_t len; int fd; - NetdevSocketOptions *stored; =20 for(;;) { len =3D sizeof(saddr); @@ -521,13 +498,6 @@ 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)); @@ -543,7 +513,6 @@ 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; @@ -580,15 +549,6 @@ 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_BACKEND_SOCKET; - stored =3D &nc->stored_config->u.socket; - - stored->has_listen =3D true; - stored->listen =3D g_strdup(host_str); - return 0; } =20 @@ -601,7 +561,6 @@ 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; @@ -639,12 +598,6 @@ 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)); @@ -662,7 +615,6 @@ 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; @@ -691,19 +643,6 @@ 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)); @@ -721,7 +660,6 @@ 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; @@ -760,15 +698,6 @@ 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 2a2ba4f..fb92b55 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -778,7 +778,6 @@ 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); @@ -789,14 +788,6 @@ 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_BACKEND_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 3589519..dd42ac6 100644 --- a/net/tap.c +++ b/net/tap.c @@ -600,7 +600,6 @@ 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; @@ -620,21 +619,6 @@ int net_init_bridge(const Netdev *netdev, const char *= name, } 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_BACKEND_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 @@ -682,13 +666,11 @@ 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, NetdevInfo **common_sto= red, - Error **errp) + int vnet_hdr, int fd, 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) { @@ -696,65 +678,12 @@ 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_BACKEND_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); @@ -770,20 +699,9 @@ 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; @@ -823,15 +741,6 @@ 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) { @@ -884,7 +793,6 @@ int net_init_tap(const Netdev *netdev, const char *name, const char *vhostfdname; char ifname[128]; int ret =3D 0; - NetdevInfo *common_stored =3D NULL; /* will store configuration */ =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -931,7 +839,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, &common_stored, &err); + vhostfdname, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); close(fd); @@ -994,7 +902,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, &common_stored, &err); + vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); ret =3D -1; @@ -1037,7 +945,7 @@ free_fail: =20 net_init_tap_one(tap, peer, "bridge", name, ifname, script, downscript, vhostfdname, - vnet_hdr, fd, &common_stored, &err); + vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); close(fd); @@ -1083,8 +991,7 @@ 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, - &common_stored, &err); + vhostfdname, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); close(fd); diff --git a/net/vde.c b/net/vde.c index b0b8800..99189cc 100644 --- a/net/vde.c +++ b/net/vde.c @@ -84,7 +84,6 @@ 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, @@ -109,27 +108,6 @@ 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_BACKEND_VDE; - stored =3D &nc->stored_config->u.vde; - - if (sock) { - stored->has_sock =3D true; - stored->sock =3D g_strdup(sock); - } - - stored->has_port =3D true; - stored->port =3D port; - - if (group) { - stored->has_group =3D true; - stored->group =3D g_strdup(group); - } - - 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 5b7056b..ffbd94d 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -311,15 +311,14 @@ 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, const char *chardev, - Chardev *chr, int queues) + const char *name, 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); @@ -356,16 +355,6 @@ 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_BACKEND_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: @@ -457,6 +446,5 @@ int net_init_vhost_user(const Netdev *netdev, const cha= r *name, return -1; } =20 - return net_vhost_user_init(peer, "vhost_user", name, - vhost_user_opts->chardev, chr, queues); + return net_vhost_user_init(peer, "vhost_user", name, chr, queues); } diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 8c27ea0..fe659ec 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -184,22 +184,8 @@ static int net_vhost_vdpa_init(NetClientState *peer, c= onst char *device, VhostVDPAState *s; int vdpa_device_fd =3D -1; int ret =3D 0; - NetdevVhostVDPAOptions *stored; - assert(name); nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); - - /* Store startup parameters */ - nc->stored_config =3D g_new0(NetdevInfo, 1); - nc->stored_config->type =3D NET_BACKEND_VHOST_VDPA; - stored =3D &nc->stored_config->u.vhost_vdpa; - - stored->has_vhostdev =3D true; - stored->vhostdev =3D g_strdup(vhostdev); - - stored->has_queues =3D true; - stored->queues =3D 1; /* TODO: change when support multiqueue */ - snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); nc->queue_index =3D 0; s =3D DO_UPCAST(VhostVDPAState, nc, nc); diff --git a/qapi/net.json b/qapi/net.json index b86d053..af3f5b0 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -694,83 +694,3 @@ ## { 'event': 'FAILOVER_NEGOTIATED', 'data': {'device-id': 'str'} } - -## -# @NetBackend: -# -# Available netdev backend drivers. -# -# Since: 6.0 -## -{ 'enum': 'NetBackend', - 'data': [ 'bridge', 'l2tpv3', 'netmap', 'socket', 'tap', 'user', 'vde', - 'vhost-user', 'vhost-vdpa' ] } - -## -# @NetdevInfo: -# -# Configuration of a network backend device (netdev). -# -# @id: Device identifier. -# -# @type: Specify the driver used for interpreting remaining arguments. -# -# @peer-id: The connected frontend network device name (absent if no front= end -# is connected). -# -# Since: 6.0 -## -{ 'union': 'NetdevInfo', - 'base': { 'id': 'str', - 'type': 'NetBackend', - '*peer-id': 'str' }, - 'discriminator': 'type', - 'data': { - 'bridge': 'NetdevBridgeOptions', - 'l2tpv3': 'NetdevL2TPv3Options', - 'netmap': 'NetdevNetmapOptions', - 'socket': 'NetdevSocketOptions', - 'tap': 'NetdevTapOptions', - 'user': 'NetdevUserOptions', - 'vde': 'NetdevVdeOptions', - 'vhost-user': 'NetdevVhostUserOptions', - 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } - -## -# @query-netdev: -# -# Get a list of @NetdevInfo for all virtual network backend devices (netde= vs). -# -# Returns: a list of @NetdevInfo describing each netdev. -# -# Since: 6.0 -# -# Example: -# -# -> { "execute": "query-netdev" } -# <- { "return": [ -# { -# "ipv6": true, -# "ipv4": true, -# "host": "10.0.2.2", -# "ipv6-dns": "fec0::3", -# "ipv6-prefix": "fec0::", -# "net": "10.0.2.0/255.255.255.0", -# "ipv6-host": "fec0::2", -# "type": "user", -# "peer-id": "net0", -# "dns": "10.0.2.3", -# "hostfwd": [ -# { -# "str": "tcp::20004-:22" -# } -# ], -# "ipv6-prefixlen": 64, -# "id": "netdev0", -# "restrict": false -# } -# ] -# } -# -## -{ 'command': 'query-netdev', 'returns': ['NetdevInfo'] } --=20 2.7.4 From nobody Fri Apr 19 20:06:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617875277; cv=none; d=zohomail.com; s=zohoarc; b=Xp/Mv9RRHdL1Wvrc2CTwWSIDwF6xGzaR5BYAMIdXhoPY/mee46RURFEzjxi5ecyz1bQqryaYLBsoxiMkyTk5htqFYMvZmVdseOwjltK+sfkML6DT8DAbcUWB2uH0v/+qNe81sNMhzceaHLQqF34DhL9+8EKgcKN7s9JbmAbCRTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617875277; h=Content-Type: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=g9wLeVhAmi7YFvv8w5bNwWrNKJYxTRwIV8410P0iNJA=; b=lvv83PMSKd16/EpXikbCwl+8Y/Lm7rMT+GZrJUYL65lJAwM7/H1Q9qMyLDwTS3AQhu9OxM4S9A2/LN27JoBhZKpK09aHQsX0imHtgQQvfGNWCPZiNFT94VHVpSMpwelOeVru8p+ONbR8RtVYFvL9fiYjjGjABYztABGIfTmPEv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass 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 1617875277422645.2382685697542; Thu, 8 Apr 2021 02:47:57 -0700 (PDT) Received: from localhost ([::1]:41212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lURGV-0006ux-DY for importer@patchew.org; Thu, 08 Apr 2021 05:47:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBK-0002Bo-SC for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lURBG-0006f5-Ru for qemu-devel@nongnu.org; Thu, 08 Apr 2021 05:42:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-b93KfVuJPcqDWJ6k5P0LLQ-1; Thu, 08 Apr 2021 05:42:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACF813F09; Thu, 8 Apr 2021 09:42:27 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-13-61.pek2.redhat.com [10.72.13.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5226510013C1; Thu, 8 Apr 2021 09:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617874950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=g9wLeVhAmi7YFvv8w5bNwWrNKJYxTRwIV8410P0iNJA=; b=A/w9H7VIQkbauik6rLth+sNR9s1dHOvBvxAyrNWnPUf+1dWRj5ZJ3BlDrnmS+nbZJXNoa0 q5H+riA/MHt7JTe/9XlPvB0aqzFA6XoTWHtdI3EhHu7IFcvlxHvD6/f6xpGaLVKF9ak4f1 HHp8oUOXqRZ+dQwpCTPuyg9DrCHz3Qs= X-MC-Unique: b93KfVuJPcqDWJ6k5P0LLQ-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 6/6] tap-win32: correctly recycle buffers Date: Thu, 8 Apr 2021 17:42:11 +0800 Message-Id: <1617874931-4437-7-git-send-email-jasowang@redhat.com> In-Reply-To: <1617874931-4437-1-git-send-email-jasowang@redhat.com> References: <1617874931-4437-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 969e50b61a28 ("net: Pad short frames to minimum size before sending from SLiRP/TAP") tries to pad frames but try to recyle the local array that is used for padding to tap thread. This patch fixes this by recyling the original buffer. Fixes: 969e50b61a28 ("net: Pad short frames to minimum size before sending = from SLiRP/TAP") Tested-by: Howard Spoelstra Tested-by: Bin Meng Reviewed-by: Bin Meng Signed-off-by: Jason Wang --- net/tap-win32.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/tap-win32.c b/net/tap-win32.c index fb92b55..897bd18 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -686,7 +686,7 @@ static ssize_t tap_receive(NetClientState *nc, const ui= nt8_t *buf, size_t size) static void tap_win32_send(void *opaque) { TAPState *s =3D opaque; - uint8_t *buf; + uint8_t *buf, *orig_buf; int max_size =3D 4096; int size; uint8_t min_pkt[ETH_ZLEN]; @@ -694,6 +694,8 @@ static void tap_win32_send(void *opaque) =20 size =3D tap_win32_read(s->handle, &buf, max_size); if (size > 0) { + orig_buf =3D buf; + if (!s->nc.peer->do_not_pad) { if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) { buf =3D min_pkt; @@ -702,7 +704,7 @@ static void tap_win32_send(void *opaque) } =20 qemu_send_packet(&s->nc, buf, size); - tap_win32_free_buffer(s->handle, buf); + tap_win32_free_buffer(s->handle, orig_buf); } } =20 --=20 2.7.4