From nobody Thu May 2 02:47:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515601961472165.31505983544503; Wed, 10 Jan 2018 08:32:41 -0800 (PST) Received: from localhost ([::1]:52348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZJIu-0006VW-7G for importer@patchew.org; Wed, 10 Jan 2018 11:32:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZJHN-0005rs-Su for qemu-devel@nongnu.org; Wed, 10 Jan 2018 11:31:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZJHJ-00020n-B7 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 11:31:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZJHJ-000208-1v for qemu-devel@nongnu.org; Wed, 10 Jan 2018 11:31:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A31DC098D18 for ; Wed, 10 Jan 2018 16:31:00 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-81.ams2.redhat.com [10.36.117.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E125D1C1; Wed, 10 Jan 2018 16:30:56 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang Date: Wed, 10 Jan 2018 17:30:55 +0100 Message-Id: <1515601855-24457-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 10 Jan 2018 16:31:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] net: Remove the deprecated way of dumping network packets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" "-net dump" has been marked as deprecated since QEMU v2.10, since it only works with the deprecated 'vlan' parameter. Network dumping should be done with "-object filter-dump" nowadays instead. So let's finally get rid of "-net dump" now. Signed-off-by: Thomas Huth --- net/dump.c | 102 ++--------------------------------------------------= ---- net/net.c | 9 +---- qapi/net.json | 27 +++------------ qemu-doc.texi | 6 ---- qemu-options.hx | 8 ----- 5 files changed, 7 insertions(+), 145 deletions(-) diff --git a/net/dump.c b/net/dump.c index 15df9a4..f16c354 100644 --- a/net/dump.c +++ b/net/dump.c @@ -109,7 +109,7 @@ static int net_dump_state_init(DumpState *s, const char= *filename, =20 fd =3D open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644); if (fd < 0) { - error_setg_errno(errp, errno, "-net dump: can't open %s", filename= ); + error_setg_errno(errp, errno, "net dump: can't open %s", filename); return -1; } =20 @@ -122,7 +122,7 @@ static int net_dump_state_init(DumpState *s, const char= *filename, hdr.linktype =3D 1; =20 if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) { - error_setg_errno(errp, errno, "-net dump write error"); + error_setg_errno(errp, errno, "net dump write error"); close(fd); return -1; } @@ -136,104 +136,6 @@ static int net_dump_state_init(DumpState *s, const ch= ar *filename, return 0; } =20 -/* Dumping via VLAN netclient */ - -struct DumpNetClient { - NetClientState nc; - DumpState ds; -}; -typedef struct DumpNetClient DumpNetClient; - -static ssize_t dumpclient_receive(NetClientState *nc, const uint8_t *buf, - size_t size) -{ - DumpNetClient *dc =3D DO_UPCAST(DumpNetClient, nc, nc); - struct iovec iov =3D { - .iov_base =3D (void *)buf, - .iov_len =3D size - }; - - return dump_receive_iov(&dc->ds, &iov, 1); -} - -static ssize_t dumpclient_receive_iov(NetClientState *nc, - const struct iovec *iov, int cnt) -{ - DumpNetClient *dc =3D DO_UPCAST(DumpNetClient, nc, nc); - - return dump_receive_iov(&dc->ds, iov, cnt); -} - -static void dumpclient_cleanup(NetClientState *nc) -{ - DumpNetClient *dc =3D DO_UPCAST(DumpNetClient, nc, nc); - - dump_cleanup(&dc->ds); -} - -static NetClientInfo net_dump_info =3D { - .type =3D NET_CLIENT_DRIVER_DUMP, - .size =3D sizeof(DumpNetClient), - .receive =3D dumpclient_receive, - .receive_iov =3D dumpclient_receive_iov, - .cleanup =3D dumpclient_cleanup, -}; - -int net_init_dump(const Netdev *netdev, const char *name, - NetClientState *peer, Error **errp) -{ - int len, rc; - const char *file; - char def_file[128]; - const NetdevDumpOptions *dump; - NetClientState *nc; - DumpNetClient *dnc; - - assert(netdev->type =3D=3D NET_CLIENT_DRIVER_DUMP); - dump =3D &netdev->u.dump; - - assert(peer); - - error_report("'-net dump' is deprecated. " - "Please use '-object filter-dump' instead."); - - if (dump->has_file) { - file =3D dump->file; - } else { - int id; - int ret; - - ret =3D net_hub_id_for_client(peer, &id); - assert(ret =3D=3D 0); /* peer must be on a hub */ - - snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id); - file =3D def_file; - } - - if (dump->has_len) { - if (dump->len > INT_MAX) { - error_setg(errp, "invalid length: %"PRIu64, dump->len); - return -1; - } - len =3D dump->len; - } else { - len =3D 65536; - } - - nc =3D qemu_new_net_client(&net_dump_info, peer, "dump", name); - snprintf(nc->info_str, sizeof(nc->info_str), - "dump to %s (len=3D%d)", file, len); - - dnc =3D DO_UPCAST(DumpNetClient, nc, nc); - rc =3D net_dump_state_init(&dnc->ds, file, len, errp); - if (rc) { - qemu_del_net_client(nc); - } - return rc; -} - -/* Dumping via filter */ - #define TYPE_FILTER_DUMP "filter-dump" =20 #define FILTER_DUMP(obj) \ diff --git a/net/net.c b/net/net.c index 2b81c93..df12c14 100644 --- a/net/net.c +++ b/net/net.c @@ -60,7 +60,6 @@ static QTAILQ_HEAD(, NetClientState) net_clients; const char *host_net_devices[] =3D { "tap", "socket", - "dump", #ifdef CONFIG_NET_BRIDGE "bridge", #endif @@ -964,7 +963,6 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIV= ER__MAX])( #ifdef CONFIG_NETMAP [NET_CLIENT_DRIVER_NETMAP] =3D net_init_netmap, #endif - [NET_CLIENT_DRIVER_DUMP] =3D net_init_dump, #ifdef CONFIG_NET_BRIDGE [NET_CLIENT_DRIVER_BRIDGE] =3D net_init_bridge, #endif @@ -990,8 +988,7 @@ static int net_client_init1(const void *object, bool is= _netdev, Error **errp) netdev =3D object; name =3D netdev->id; =20 - if (netdev->type =3D=3D NET_CLIENT_DRIVER_DUMP || - netdev->type =3D=3D NET_CLIENT_DRIVER_NIC || + if (netdev->type =3D=3D NET_CLIENT_DRIVER_NIC || !net_client_init_fun[netdev->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); @@ -1033,10 +1030,6 @@ static int net_client_init1(const void *object, bool= is_netdev, Error **errp) legacy.type =3D NET_CLIENT_DRIVER_VDE; legacy.u.vde =3D opts->u.vde; break; - case NET_LEGACY_OPTIONS_TYPE_DUMP: - legacy.type =3D NET_CLIENT_DRIVER_DUMP; - legacy.u.dump =3D opts->u.dump; - break; case NET_LEGACY_OPTIONS_TYPE_BRIDGE: legacy.type =3D NET_CLIENT_DRIVER_BRIDGE; legacy.u.bridge =3D opts->u.bridge; diff --git a/qapi/net.json b/qapi/net.json index 1238ba5..15ca2ed 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -39,8 +39,8 @@ # # Add a network backend. # -# @type: the type of network backend. Current valid values are 'user', 't= ap', -# 'vde', 'socket', 'dump' and 'bridge' +# @type: the type of network backend. Current valid values are for example +# 'user', 'tap', 'vde', 'socket', 'hubport' and 'bridge' # # @id: the name of the new network backend # @@ -372,23 +372,6 @@ '*mode': 'uint16' } } =20 ## -# @NetdevDumpOptions: -# -# Dump VLAN network traffic to a file. -# -# @len: per-packet size limit (64k default). Understands [TGMKkb] -# suffixes. -# -# @file: dump file path (default is qemu-vlan0.pcap) -# -# Since: 1.2 -## -{ 'struct': 'NetdevDumpOptions', - 'data': { - '*len': 'size', - '*file': 'str' } } - -## # @NetdevBridgeOptions: # # Connect a host TAP network interface to a host bridge device. @@ -468,7 +451,7 @@ # Since: 2.7 ## { 'enum': 'NetClientDriver', - 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump= ', + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user' ] } =20 ## @@ -495,7 +478,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', @@ -530,7 +512,7 @@ ## { 'enum': 'NetLegacyOptionsType', 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'dump', 'bridge', 'netmap', 'vhost-user'] } + 'bridge', 'netmap', 'vhost-user'] } =20 ## # @NetLegacyOptions: @@ -550,7 +532,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions' } } diff --git a/qemu-doc.texi b/qemu-doc.texi index 9d01598..aeaf440 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2699,12 +2699,6 @@ that can be specified with the ``-device'' parameter. The drive addr argument is replaced by the the addr argument that can be specified with the ``-device'' parameter. =20 -@subsection -net dump (since 2.10.0) - -The ``--net dump'' argument is now replaced with the -``-object filter-dump'' argument which works in combination -with the modern ``-netdev`` backends instead. - @subsection -usbdevice (since 2.10.0) =20 The ``-usbdevice DEV'' argument is now a synonym for setting diff --git a/qemu-options.hx b/qemu-options.hx index 9ec4af7..130016c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2024,8 +2024,6 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, " configure or create an on-board (or machine default) = NIC and\n" " connect it either to VLAN 'n' or the netdev 'nd' (for= pluggable\n" " NICs please use '-device devtype,netdev=3Dnd' instead= )\n" - "-net dump[,vlan=3Dn][,file=3Df][,len=3Dn]\n" - " dump traffic on vlan 'n' to file 'f' (max n bytes per= packet)\n" "-net none use it alone to have zero network devices. If no -net= option\n" " is provided, the default is '-net nic -net user'\n" "-net [" @@ -2473,12 +2471,6 @@ qemu -m 512 -object memory-backend-file,id=3Dmem,siz= e=3D512M,mem-path=3D/hugetlbfs,sha -device virtio-net-pci,netdev=3Dnet0 @end example =20 -@item -net dump[,vlan=3D@var{n}][,file=3D@var{file}][,len=3D@var{len}] -Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.= pcap} by default). -At most @var{len} bytes (64k by default) per packet are stored. The file f= ormat is -libpcap, so it can be analyzed with tools such as tcpdump or Wireshark. -Note: For devices created with '-netdev', use '-object filter-dump,...' in= stead. - @item -net none Indicate that no network devices should be configured. It is used to override the default configuration (@option{-net nic -net user}) which --=20 1.8.3.1