From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148706561242.62195489760165; Tue, 20 Feb 2018 09:45:06 -0800 (PST) Received: from localhost ([::1]:56855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoByT-0005wN-Ml for importer@patchew.org; Tue, 20 Feb 2018 12:45:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBtz-0002LO-Eo for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBtw-0000Pp-0p for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:27 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39576 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBtv-0000OM-IQ for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFE5340FB639 for ; Tue, 20 Feb 2018 17:40:20 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8061FAE7B6; Tue, 20 Feb 2018 17:40:17 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:39:59 +0100 Message-Id: <1519148406-15006-2-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Feb 2018 17:40:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Feb 2018 17:40:20 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 1/8] net: Move error reporting from net_init_client/netdev to the calling site 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: Paolo Bonzini , Stefan Hajnoczi 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" It looks strange that net_init_client() and net_init_netdev() both take an "Error **errp" parameter, but then do the error reporting with "error_report_err(local_err)" on their own. Let's move the error reporting to the calling site instead to simplify this code a little bit. Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth --- include/net/net.h | 2 +- net/net.c | 29 +++++------------------------ vl.c | 3 ++- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 3fc48e4..bdd4d9f 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -206,7 +206,7 @@ extern const char *legacy_bootp_filename; =20 int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp); int net_client_parse(QemuOptsList *opts_list, const char *str); -int net_init_clients(void); +int net_init_clients(Error **errp); void net_check_clients(void); void net_cleanup(void); void hmp_host_net_add(Monitor *mon, const QDict *qdict); diff --git a/net/net.c b/net/net.c index 7d42925..e213a61 100644 --- a/net/net.c +++ b/net/net.c @@ -1520,46 +1520,27 @@ void net_check_clients(void) =20 static int net_init_client(void *dummy, QemuOpts *opts, Error **errp) { - Error *local_err =3D NULL; - - net_client_init(opts, false, &local_err); - if (local_err) { - error_report_err(local_err); - return -1; - } - - return 0; + return net_client_init(opts, false, errp); } =20 static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp) { - Error *local_err =3D NULL; - int ret; - - ret =3D net_client_init(opts, true, &local_err); - if (local_err) { - error_report_err(local_err); - return -1; - } - - return ret; + return net_client_init(opts, true, errp); } =20 -int net_init_clients(void) +int net_init_clients(Error **errp) { - QemuOptsList *net =3D qemu_find_opts("net"); - net_change_state_entry =3D qemu_add_vm_change_state_handler(net_vm_change_state_handler, NULL= ); =20 QTAILQ_INIT(&net_clients); =20 if (qemu_opts_foreach(qemu_find_opts("netdev"), - net_init_netdev, NULL, NULL)) { + net_init_netdev, NULL, errp)) { return -1; } =20 - if (qemu_opts_foreach(net, net_init_client, NULL, NULL)) { + if (qemu_opts_foreach(qemu_find_opts("net"), net_init_client, NULL, er= rp)) { return -1; } =20 diff --git a/vl.c b/vl.c index 9e7235d..698b681 100644 --- a/vl.c +++ b/vl.c @@ -4476,7 +4476,8 @@ int main(int argc, char **argv, char **envp) =20 colo_info_init(); =20 - if (net_init_clients() < 0) { + if (net_init_clients(&err) < 0) { + error_report_err(err); exit(1); } =20 --=20 1.8.3.1 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148545464707.4617577706474; Tue, 20 Feb 2018 09:42:25 -0800 (PST) Received: from localhost ([::1]:56842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBvq-0003SV-Fz for importer@patchew.org; Tue, 20 Feb 2018 12:42:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBtz-0002LN-EG for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBtx-0000RG-B0 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:27 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45660 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBtw-0000Q9-M4 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:24 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4120C80401C1 for ; Tue, 20 Feb 2018 17:40:24 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D661AE7B6; Tue, 20 Feb 2018 17:40:21 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:00 +0100 Message-Id: <1519148406-15006-3-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 20 Feb 2018 17:40:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 20 Feb 2018 17:40:24 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 2/8] net: List available netdevs with "-netdev help" 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: Paolo Bonzini , Stefan Hajnoczi 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" Other options like "-chardev" or "-device" feature a nice help text with the available devices when being called with "help" or "?". Since it is quite useful, especially if you want to see which network backends have been compiled into the QEMU binary, let's provide such a help text for "-netdev", too. Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth Reviewed-by: Eric Blake --- net/net.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index e213a61..cf07e15 100644 --- a/net/net.c +++ b/net/net.c @@ -1086,6 +1086,38 @@ static int net_client_init1(const void *object, bool= is_netdev, Error **errp) return 0; } =20 +static void show_netdevs(void) +{ + int idx; + const char *available_netdevs[] =3D { + "socket", + "hubport", + "tap", +#ifdef CONFIG_SLIRP + "user", +#endif +#ifdef CONFIG_L2TPV3 + "l2tpv3", +#endif +#ifdef CONFIG_VDE + "vde", +#endif +#ifdef CONFIG_NET_BRIDGE + "bridge", +#endif +#ifdef CONFIG_NETMAP + "netmap", +#endif +#ifdef CONFIG_POSIX + "vhost-user", +#endif + }; + + printf("Available netdev backend types:\n"); + for (idx =3D 0; idx < ARRAY_SIZE(available_netdevs); idx++) { + puts(available_netdevs[idx]); + } +} =20 int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) { @@ -1094,7 +1126,10 @@ int net_client_init(QemuOpts *opts, bool is_netdev, = Error **errp) int ret =3D -1; Visitor *v =3D opts_visitor_new(opts); =20 - { + if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) { + show_netdevs(); + exit(0); + } else { /* Parse convenience option format ip6-net=3Dfec0::0[/64] */ const char *ip6_net =3D qemu_opt_get(opts, "ipv6-net"); =20 --=20 1.8.3.1 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148548775883.1421876478635; Tue, 20 Feb 2018 09:42:28 -0800 (PST) Received: from localhost ([::1]:56844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBvv-0003WT-V5 for importer@patchew.org; Tue, 20 Feb 2018 12:42:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBu1-0002M8-LZ for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBu0-0000U0-Tu for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:29 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51574 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBu0-0000Tm-PQ for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5828D406F970 for ; Tue, 20 Feb 2018 17:40:28 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EB8BAE7B6; Tue, 20 Feb 2018 17:40:24 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:01 +0100 Message-Id: <1519148406-15006-4-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 20 Feb 2018 17:40:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 20 Feb 2018 17:40:28 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 3/8] net: Only show vhost-user in the help text if CONFIG_POSIX is defined 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: Paolo Bonzini , Stefan Hajnoczi 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" According to net/Makefile.objs we only link in the vhost-user code if CONFIG_POSIX has been set. So the help screen should also only show this information if CONFIG_POSIX has been defined. Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth --- qemu-options.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 8ccd5dc..9ae49a0 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1998,8 +1998,10 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " VALE port (created on the fly) called 'name' ('nmname= ' is name of the \n" " netmap device, defaults to '/dev/netmap')\n" #endif +#ifdef CONFIG_POSIX "-netdev vhost-user,id=3Dstr,chardev=3Ddev[,vhostforce=3Don|off]\n" " configure a vhost-user network, backed by a chardev '= dev'\n" +#endif "-netdev hubport,id=3Dstr,hubid=3Dn[,netdev=3Dnd]\n" " configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_A= LL) DEF("net", HAS_ARG, QEMU_OPTION_net, --=20 1.8.3.1 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148885682953.4777156555391; Tue, 20 Feb 2018 09:48:05 -0800 (PST) Received: from localhost ([::1]:56874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoC1J-0008RL-8g for importer@patchew.org; Tue, 20 Feb 2018 12:48:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBu4-0002OR-CS for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBu3-0000W5-IO for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54588 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBu3-0000Vf-Da for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06EEB8D6F0 for ; Tue, 20 Feb 2018 17:40:31 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF405AB587; Tue, 20 Feb 2018 17:40:28 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:02 +0100 Message-Id: <1519148406-15006-5-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 20 Feb 2018 17:40:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 20 Feb 2018 17:40:31 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 4/8] net: Make net_client_init() static 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: Paolo Bonzini , Stefan Hajnoczi 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" The function is only used within net.c, so there's no need that this is a global function. While we're at it, also remove the unused prototype compute_mcast_idx() (the function has been removed in commit d9caeb09b107e91122d10ba4a08a). Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth --- include/net/net.h | 2 -- net/net.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index bdd4d9f..cd1708c 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -204,7 +204,6 @@ extern const char *host_net_devices[]; extern const char *legacy_tftp_prefix; extern const char *legacy_bootp_filename; =20 -int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp); int net_client_parse(QemuOptsList *opts_list, const char *str); int net_init_clients(Error **errp); void net_check_clients(void); @@ -228,7 +227,6 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo = *nd); #define POLYNOMIAL_LE 0xedb88320 uint32_t net_crc32(const uint8_t *p, int len); uint32_t net_crc32_le(const uint8_t *p, int len); -unsigned compute_mcast_idx(const uint8_t *ep); =20 #define vmstate_offset_macaddr(_state, _field) \ vmstate_offset_array(_state, _field.a, uint8_t, \ diff --git a/net/net.c b/net/net.c index cf07e15..dd80f1b 100644 --- a/net/net.c +++ b/net/net.c @@ -1119,7 +1119,7 @@ static void show_netdevs(void) } } =20 -int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) +static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) { void *object =3D NULL; Error *err =3D NULL; --=20 1.8.3.1 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151914870917937.87590590498269; Tue, 20 Feb 2018 09:45:09 -0800 (PST) Received: from localhost ([::1]:56856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoByW-0005z2-Bb for importer@patchew.org; Tue, 20 Feb 2018 12:45:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBuA-0002T8-4b for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBu6-0000YN-S5 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:38 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42330 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBu6-0000Y4-LT for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EA0E40287F9 for ; Tue, 20 Feb 2018 17:40:34 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D56BAB587; Tue, 20 Feb 2018 17:40:31 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:03 +0100 Message-Id: <1519148406-15006-6-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 20 Feb 2018 17:40:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 20 Feb 2018 17:40:34 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 5/8] 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: Paolo Bonzini , Stefan Hajnoczi 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 (or hubs). Network dumping should be done with "-object filter-dump" nowadays instead. Since nobody complained so far about the deprecation message, let's finally get rid of "-net dump" now. Reviewed-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Thomas Huth --- net/dump.c | 102 ++--------------------------------------------------= ---- net/net.c | 9 +---- qapi/net.json | 29 ++++------------ qemu-doc.texi | 6 ---- qemu-options.hx | 8 ----- 5 files changed, 9 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 dd80f1b..cbd553d 100644 --- a/net/net.c +++ b/net/net.c @@ -63,7 +63,6 @@ static QTAILQ_HEAD(, NetClientState) net_clients; const char *host_net_devices[] =3D { "tap", "socket", - "dump", #ifdef CONFIG_NET_BRIDGE "bridge", #endif @@ -967,7 +966,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 @@ -993,8 +991,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"); @@ -1036,10 +1033,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..09af929 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -39,8 +39,10 @@ # # 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. Possible values in version +# 2.11: 'user', 'tap', 'vde', 'socket', 'hubport', 'bridge', +# 'dump', 'l2tpv3', 'netmap', 'vhost-user' +# 2.12: 'dump' dropped # # @id: the name of the new network backend # @@ -372,23 +374,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 +453,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 +480,6 @@ 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', 'bridge': 'NetdevBridgeOptions', 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', @@ -530,7 +514,7 @@ ## { 'enum': 'NetLegacyOptionsType', 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'dump', 'bridge', 'netmap', 'vhost-user'] } + 'bridge', 'netmap', 'vhost-user'] } =20 ## # @NetLegacyOptions: @@ -550,7 +534,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 8e35569..97025c2 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2707,12 +2707,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 9ae49a0..a9249b6 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2009,8 +2009,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 [" @@ -2458,12 +2456,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 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148561963312.38973181871506; Tue, 20 Feb 2018 09:42:41 -0800 (PST) Received: from localhost ([::1]:56845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBw8-0003jn-UP for importer@patchew.org; Tue, 20 Feb 2018 12:42:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBuB-0002UY-PH for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBuA-0000b6-6H for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:39 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44036 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBu9-0000ac-W4 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DAB5EAEA0 for ; Tue, 20 Feb 2018 17:40:37 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7713AE7B6; Tue, 20 Feb 2018 17:40:34 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:04 +0100 Message-Id: <1519148406-15006-7-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 20 Feb 2018 17:40:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 20 Feb 2018 17:40:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 6/8] net: Remove the deprecated 'host_net_add' and 'host_net_remove' HMP commands 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: Paolo Bonzini , Stefan Hajnoczi 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" They are deprecated since QEMU v2.10, and so far nobody complained that these commands are still necessary for any reason - and since you can use 'netdev_add' and 'netdev_remove' instead, there also should not be any real reason. Since they are also standing in the way for the upcoming 'vlan' clean-up, it's now time to remove them. Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth --- hmp-commands.hx | 30 ------------------ hmp.h | 3 -- monitor.c | 61 ------------------------------------ net/net.c | 94 ----------------------------------------------------= ---- qemu-doc.texi | 10 ------ tests/test-hmp.c | 2 -- 6 files changed, 200 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index d26eb41..964eb51 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1291,36 +1291,6 @@ Inject PCIe AER error ETEXI =20 { - .name =3D "host_net_add", - .args_type =3D "device:s,opts:s?", - .params =3D "tap|user|socket|vde|netmap|bridge|vhost-user|dump= [options]", - .help =3D "add host VLAN client (deprecated, use netdev_add = instead)", - .cmd =3D hmp_host_net_add, - .command_completion =3D host_net_add_completion, - }, - -STEXI -@item host_net_add -@findex host_net_add -Add host VLAN client. Deprecated, please use @code{netdev_add} instead. -ETEXI - - { - .name =3D "host_net_remove", - .args_type =3D "vlan_id:i,device:s", - .params =3D "vlan_id name", - .help =3D "remove host VLAN client (deprecated, use netdev_d= el instead)", - .cmd =3D hmp_host_net_remove, - .command_completion =3D host_net_remove_completion, - }, - -STEXI -@item host_net_remove -@findex host_net_remove -Remove host VLAN client. Deprecated, please use @code{netdev_del} instead. -ETEXI - - { .name =3D "netdev_add", .args_type =3D "netdev:O", .params =3D "[user|tap|socket|vde|bridge|hubport|netmap|vhost-= user],id=3Dstr[,prop=3Dvalue][,...]", diff --git a/hmp.h b/hmp.h index 1143db4..b897338 100644 --- a/hmp.h +++ b/hmp.h @@ -132,9 +132,6 @@ void migrate_set_capability_completion(ReadLineState *r= s, int nb_args, const char *str); void migrate_set_parameter_completion(ReadLineState *rs, int nb_args, const char *str); -void host_net_add_completion(ReadLineState *rs, int nb_args, const char *s= tr); -void host_net_remove_completion(ReadLineState *rs, int nb_args, - const char *str); void delvm_completion(ReadLineState *rs, int nb_args, const char *str); void loadvm_completion(ReadLineState *rs, int nb_args, const char *str); void hmp_rocker(Monitor *mon, const QDict *qdict); diff --git a/monitor.c b/monitor.c index 373bb8d..a4f1f28 100644 --- a/monitor.c +++ b/monitor.c @@ -3574,67 +3574,6 @@ void migrate_set_parameter_completion(ReadLineState = *rs, int nb_args, } } =20 -void host_net_add_completion(ReadLineState *rs, int nb_args, const char *s= tr) -{ - int i; - size_t len; - if (nb_args !=3D 2) { - return; - } - len =3D strlen(str); - readline_set_completion_index(rs, len); - for (i =3D 0; host_net_devices[i]; i++) { - if (!strncmp(host_net_devices[i], str, len)) { - readline_add_completion(rs, host_net_devices[i]); - } - } -} - -void host_net_remove_completion(ReadLineState *rs, int nb_args, const char= *str) -{ - NetClientState *ncs[MAX_QUEUE_NUM]; - int count, i, len; - - len =3D strlen(str); - readline_set_completion_index(rs, len); - if (nb_args =3D=3D 2) { - count =3D qemu_find_net_clients_except(NULL, ncs, - NET_CLIENT_DRIVER_NONE, - MAX_QUEUE_NUM); - for (i =3D 0; i < MIN(count, MAX_QUEUE_NUM); i++) { - int id; - char name[16]; - - if (net_hub_id_for_client(ncs[i], &id)) { - continue; - } - snprintf(name, sizeof(name), "%d", id); - if (!strncmp(str, name, len)) { - readline_add_completion(rs, name); - } - } - return; - } else if (nb_args =3D=3D 3) { - count =3D qemu_find_net_clients_except(NULL, ncs, - NET_CLIENT_DRIVER_NIC, - MAX_QUEUE_NUM); - for (i =3D 0; i < MIN(count, MAX_QUEUE_NUM); i++) { - int id; - const char *name; - - if (ncs[i]->info->type =3D=3D NET_CLIENT_DRIVER_HUBPORT || - net_hub_id_for_client(ncs[i], &id)) { - continue; - } - name =3D ncs[i]->name; - if (!strncmp(str, name, len)) { - readline_add_completion(rs, name); - } - } - return; - } -} - static void vm_completion(ReadLineState *rs, const char *str) { size_t len; diff --git a/net/net.c b/net/net.c index cbd553d..2d05808 100644 --- a/net/net.c +++ b/net/net.c @@ -60,25 +60,6 @@ static VMChangeStateEntry *net_change_state_entry; static QTAILQ_HEAD(, NetClientState) net_clients; =20 -const char *host_net_devices[] =3D { - "tap", - "socket", -#ifdef CONFIG_NET_BRIDGE - "bridge", -#endif -#ifdef CONFIG_NETMAP - "netmap", -#endif -#ifdef CONFIG_SLIRP - "user", -#endif -#ifdef CONFIG_VDE - "vde", -#endif - "vhost-user", - NULL, -}; - /***********************************************************/ /* network device redirectors */ =20 @@ -1174,81 +1155,6 @@ static int net_client_init(QemuOpts *opts, bool is_n= etdev, Error **errp) return ret; } =20 - -static int net_host_check_device(const char *device) -{ - int i; - for (i =3D 0; host_net_devices[i]; i++) { - if (!strncmp(host_net_devices[i], device, - strlen(host_net_devices[i]))) { - return 1; - } - } - - return 0; -} - -void hmp_host_net_add(Monitor *mon, const QDict *qdict) -{ - const char *device =3D qdict_get_str(qdict, "device"); - const char *opts_str =3D qdict_get_try_str(qdict, "opts"); - Error *local_err =3D NULL; - QemuOpts *opts; - static bool warned; - - if (!warned && !qtest_enabled()) { - error_report("host_net_add is deprecated, use netdev_add instead"); - warned =3D true; - } - - if (!net_host_check_device(device)) { - monitor_printf(mon, "invalid host network device %s\n", device); - return; - } - - opts =3D qemu_opts_parse_noisily(qemu_find_opts("net"), - opts_str ? opts_str : "", false); - if (!opts) { - return; - } - - qemu_opt_set(opts, "type", device, &error_abort); - - net_client_init(opts, false, &local_err); - if (local_err) { - error_report_err(local_err); - monitor_printf(mon, "adding host network device %s failed\n", devi= ce); - } -} - -void hmp_host_net_remove(Monitor *mon, const QDict *qdict) -{ - NetClientState *nc; - int vlan_id =3D qdict_get_int(qdict, "vlan_id"); - const char *device =3D qdict_get_str(qdict, "device"); - static bool warned; - - if (!warned && !qtest_enabled()) { - error_report("host_net_remove is deprecated, use netdev_del instea= d"); - warned =3D true; - } - - nc =3D net_hub_find_client_by_name(vlan_id, device); - if (!nc) { - error_report("Host network device '%s' on hub '%d' not found", - device, vlan_id); - return; - } - if (nc->info->type =3D=3D NET_CLIENT_DRIVER_NIC) { - error_report("invalid host network device '%s'", device); - return; - } - - qemu_del_net_client(nc->peer); - qemu_del_net_client(nc); - qemu_opts_del(qemu_opts_find(qemu_find_opts("net"), device)); -} - void netdev_add(QemuOpts *opts, Error **errp) { net_client_init(opts, true, errp); diff --git a/qemu-doc.texi b/qemu-doc.texi index 97025c2..36acfc9 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2756,16 +2756,6 @@ by the ``convert -l snapshot_param'' argument instea= d. "autoload" parameter is now ignored. All bitmaps are automatically loaded from qcow2 images. =20 -@section System emulator human monitor commands - -@subsection host_net_add (since 2.10.0) - -The ``host_net_add'' command is replaced by the ``netdev_add'' command. - -@subsection host_net_remove (since 2.10.0) - -The ``host_net_remove'' command is replaced by the ``netdev_del'' command. - @section System emulator devices =20 @subsection ivshmem (since 2.6.0) diff --git a/tests/test-hmp.c b/tests/test-hmp.c index 5b7e447..5352c9c 100644 --- a/tests/test-hmp.c +++ b/tests/test-hmp.c @@ -37,10 +37,8 @@ static const char *hmp_cmds[] =3D { "dump-guest-memory /dev/null 0 4096", "dump-guest-memory /dev/null", "gdbserver", - "host_net_add user id=3Dnet0", "hostfwd_add tcp::43210-:43210", "hostfwd_remove tcp::43210-:43210", - "host_net_remove 0 net0", "i /w 0", "log all", "log none", --=20 1.8.3.1 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148715000529.2153802523595; Tue, 20 Feb 2018 09:45:15 -0800 (PST) Received: from localhost ([::1]:56857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoByc-00062z-4y for importer@patchew.org; Tue, 20 Feb 2018 12:45:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBuE-0002Wg-By for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBuC-0000dm-Up for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:42 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39596 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBuC-0000dT-PD for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53FEC4023EDE for ; Tue, 20 Feb 2018 17:40:40 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id F098BAB587; Tue, 20 Feb 2018 17:40:37 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:05 +0100 Message-Id: <1519148406-15006-8-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Feb 2018 17:40:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Feb 2018 17:40:40 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 7/8] net: Add a new convenience option "--nic" to configure default/on-board NICs 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: Paolo Bonzini , Stefan Hajnoczi 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" The legacy "-net" option can be quite confusing for the users since most people do not expect to get a "vlan" hub between their emulated guest hardware and the host backend. But so far, we are also not able to get rid of "-net" completely, since it is the only way to configure on-board NICs that can not be instantiated via "-device" yet. It's also a little bit shorter to type "-net nic -net tap" instead of "-device xyz,netdev=3Dn1 -netdev tap,id=3Dn1". So what we need is a new convenience option that is shorter to type than the full -device + -netdev stuff, and which can be used to configure the on-board NICs that can not be handled via -device yet. Thus this patch now provides such a new option "--nic": It adds an entry in the nd_table to configure a on-board / default NIC, creates a host backend and connects the two directly, without a confusing "vlan" hub inbetween. Signed-off-by: Thomas Huth Reviewed-by: Paolo Bonzini --- include/sysemu/sysemu.h | 1 + net/net.c | 78 +++++++++++++++++++++++++++++++++++++++++++++= ++++ qemu-options.hx | 40 +++++++++++++++++++++---- vl.c | 7 +++++ 4 files changed, 120 insertions(+), 6 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 77bb3da..66f0761 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -197,6 +197,7 @@ extern QemuOptsList bdrv_runtime_opts; extern QemuOptsList qemu_chardev_opts; extern QemuOptsList qemu_device_opts; extern QemuOptsList qemu_netdev_opts; +extern QemuOptsList qemu_nic_opts; extern QemuOptsList qemu_net_opts; extern QemuOptsList qemu_global_opts; extern QemuOptsList qemu_mon_opts; diff --git a/net/net.c b/net/net.c index 2d05808..0bab269 100644 --- a/net/net.c +++ b/net/net.c @@ -1462,6 +1462,67 @@ static int net_init_netdev(void *dummy, QemuOpts *op= ts, Error **errp) return net_client_init(opts, true, errp); } =20 +/* For the convenience "--nic" parameter */ +static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp) +{ + char *mac, *nd_id; + int idx, ret; + NICInfo *ni; + const char *type; + + type =3D qemu_opt_get(opts, "type"); + if (type && g_str_equal(type, "none")) { + return 0; /* Nothing to do, default_net is cleared in vl.c */ + } + + idx =3D nic_get_free_idx(); + if (idx =3D=3D -1 || nb_nics >=3D MAX_NICS) { + error_setg(errp, "no more on-board/default NIC slots available"); + return -1; + } + + if (!type) { + qemu_opt_set(opts, "type", "user", &error_abort); + } + + ni =3D &nd_table[idx]; + memset(ni, 0, sizeof(*ni)); + ni->model =3D qemu_opt_get_del(opts, "model"); + + /* Create an ID if the user did not specify one */ + nd_id =3D g_strdup(qemu_opts_id(opts)); + if (!nd_id) { + nd_id =3D g_strdup_printf("__org.qemu.nic%i\n", idx); + qemu_opts_set_id(opts, nd_id); + } + + /* Handle MAC address */ + mac =3D qemu_opt_get_del(opts, "mac"); + if (mac) { + ret =3D net_parse_macaddr(ni->macaddr.a, mac); + g_free(mac); + if (ret) { + error_setg(errp, "invalid syntax for ethernet address"); + return -1; + } + if (is_multicast_ether_addr(ni->macaddr.a)) { + error_setg(errp, "NIC cannot have multicast MAC address"); + return -1; + } + } + qemu_macaddr_default_if_unset(&ni->macaddr); + + ret =3D net_client_init(opts, true, errp); + if (ret =3D=3D 0) { + ni->netdev =3D qemu_find_netdev(nd_id); + ni->used =3D true; + nb_nics++; + } + + g_free(nd_id); + return ret; +} + int net_init_clients(Error **errp) { net_change_state_entry =3D @@ -1474,6 +1535,10 @@ int net_init_clients(Error **errp) return -1; } =20 + if (qemu_opts_foreach(qemu_find_opts("nic"), net_param_nic, NULL, errp= )) { + return -1; + } + if (qemu_opts_foreach(qemu_find_opts("net"), net_init_client, NULL, er= rp)) { return -1; } @@ -1549,6 +1614,19 @@ QemuOptsList qemu_netdev_opts =3D { }, }; =20 +QemuOptsList qemu_nic_opts =3D { + .name =3D "nic", + .implied_opt_name =3D "type", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_nic_opts.head), + .desc =3D { + /* + * no elements =3D> accept any params + * validation will happen later + */ + { /* end of list */ } + }, +}; + QemuOptsList qemu_net_opts =3D { .name =3D "net", .implied_opt_name =3D "type", diff --git a/qemu-options.hx b/qemu-options.hx index a9249b6..399905e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2004,13 +2004,34 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, #endif "-netdev hubport,id=3Dstr,hubid=3Dn[,netdev=3Dnd]\n" " configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_A= LL) +DEF("nic", HAS_ARG, QEMU_OPTION_nic, + "--nic [tap|bridge|" +#ifdef CONFIG_SLIRP + "user|" +#endif +#ifdef __linux__ + "l2tpv3|" +#endif +#ifdef CONFIG_VDE + "vde|" +#endif +#ifdef CONFIG_NETMAP + "netmap|" +#endif +#ifdef CONFIG_POSIX + "vhost-user|" +#endif + "socket][,option][,...][mac=3Dmacaddr]\n" + " initialize an on-board / default host NIC (using MAC = address\n" + " macaddr) and connect it to the given host network bac= kend\n" + "--nic none use it alone to have zero network devices (the defaul= t is to\n" + " provided a 'user' network connection)\n", + QEMU_ARCH_ALL) DEF("net", HAS_ARG, QEMU_OPTION_net, "-net nic[,vlan=3Dn][,netdev=3Dnd][,macaddr=3Dmac][,model=3Dtype][,nam= e=3Dstr][,addr=3Dstr][,vectors=3Dv]\n" " 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 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 [" #ifdef CONFIG_SLIRP "user|" @@ -2456,10 +2477,17 @@ qemu -m 512 -object memory-backend-file,id=3Dmem,si= ze=3D512M,mem-path=3D/hugetlbfs,sha -device virtio-net-pci,netdev=3Dnet0 @end example =20 -@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 -is activated if no @option{-net} options are provided. +@item --nic [tap|bridge|user|l2tpv3|vde|netmap|vhost-user|socket][,...][,m= ac=3Dmacaddr] + +This option is a shortcut for setting both, the on-board (default) guest N= IC +hardware and the host network backend in one go. The host backend options = are +the same as with the corresponding @option{--netdev} option. The guest NIC +hardware MAC address can be set with @option{mac=3D@var{macaddr}}. + +@item --nic none +Indicate that no network devices should be configured. It is used to overr= ide +the default configuration (default NIC with @option{--net user} backend) w= hich +is activated if no other networking options are provided. ETEXI =20 STEXI diff --git a/vl.c b/vl.c index 698b681..59ffadb 100644 --- a/vl.c +++ b/vl.c @@ -3078,6 +3078,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_chardev_opts); qemu_add_opts(&qemu_device_opts); qemu_add_opts(&qemu_netdev_opts); + qemu_add_opts(&qemu_nic_opts); qemu_add_opts(&qemu_net_opts); qemu_add_opts(&qemu_rtc_opts); qemu_add_opts(&qemu_global_opts); @@ -3298,6 +3299,12 @@ int main(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_nic: + default_net =3D 0; + if (net_client_parse(qemu_find_opts("nic"), optarg) =3D=3D= -1) { + exit(1); + } + break; case QEMU_OPTION_net: default_net =3D 0; if (net_client_parse(qemu_find_opts("net"), optarg) =3D=3D= -1) { --=20 1.8.3.1 From nobody Wed Oct 22 15:02:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519149049847657.5032434094395; Tue, 20 Feb 2018 09:50:49 -0800 (PST) Received: from localhost ([::1]:56892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoC40-0002Qv-MQ for importer@patchew.org; Tue, 20 Feb 2018 12:50:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBuK-0002cK-Am for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBuH-0000hX-1d for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:48 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51588 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBuG-0000hC-Ro for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BD8D407244E for ; Tue, 20 Feb 2018 17:40:44 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21938AE7B6; Tue, 20 Feb 2018 17:40:40 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:40:06 +0100 Message-Id: <1519148406-15006-9-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 20 Feb 2018 17:40:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 20 Feb 2018 17:40:44 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 8/8] qemu-doc: Make "-net" less prominent 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: Paolo Bonzini , Stefan Hajnoczi 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" is clearly a legacy option. Yet we still use it in almost all examples in the qemu documentation, and many other spots in the network chapter. We should make it less prominent that users are not lured into using it so often anymore. So instead of starting the network chapter with "-net nic" and documenting "-net " below "-netdev " everywhere, all the "-net" related documentation is now moved to the end of the chapter. And the examples are changed to use the "--device" and "--netdev" options instead of "-net nic -net ". Signed-off-by: Thomas Huth --- qemu-options.hx | 176 +++++++++++++++++++++++++++-------------------------= ---- 1 file changed, 86 insertions(+), 90 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 399905e..ff5da07 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2048,41 +2048,18 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, " old way to initialize a host network interface\n" " (use the -netdev option if possible instead)\n", QEMU= _ARCH_ALL) STEXI -@item -net nic[,vlan=3D@var{n}][,netdev=3D@var{nd}][,macaddr=3D@var{mac}][= ,model=3D@var{type}] [,name=3D@var{name}][,addr=3D@var{addr}][,vectors=3D@v= ar{v}] -@findex -net -Configure or create an on-board (or machine default) Network Interface Card -(NIC) and connect it either to VLAN @var{n} (@var{n} =3D 0 is the default)= , or -to the netdev @var{nd}. The NIC is an e1000 by default on the PC -target. Optionally, the MAC address can be changed to @var{mac}, the -device address set to @var{addr} (PCI cards only), -and a @var{name} can be assigned for use in monitor commands. -Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vec= tors -that the card should have; this option currently only affects virtio cards= ; set -@var{v} =3D 0 to disable MSI-X. If no @option{-net} option is specified, a= single -NIC is created. QEMU can emulate several different models of network card. -Valid values for @var{type} are -@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er}, -@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, -@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. -Not all devices are supported on all targets. Use @code{-net nic,model=3D= help} -for a list of available devices for your target. - -@item -netdev user,id=3D@var{id}[,@var{option}][,@var{option}][,...] -@findex -netdev -@item -net user[,@var{option}][,@var{option}][,...] -Use the user mode network stack which requires no administrator +@item --netdev user,id=3D@var{id}[,@var{option}][,@var{option}][,...] +@findex --netdev +Configure user mode host network backend which requires no administrator privilege to run. Valid options are: =20 @table @option -@item vlan=3D@var{n} -Connect user mode stack to VLAN @var{n} (@var{n} =3D 0 is the default). - @item id=3D@var{id} -@itemx name=3D@var{name} Assign symbolic name for use in monitor commands. =20 -@option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must -be enabled. If neither is specified both protocols are enabled. +@item ipv4=3Don|off and ipv6=3Don|off +Specify that either IPv4 or IPv6 must be enabled. If neither is specified +both protocols are enabled. =20 @item net=3D@var{addr}[/@var{mask}] Set IP network address the guest will see. Optionally specify the netmask, @@ -2134,7 +2111,7 @@ can not be resolved. =20 Example: @example -qemu -net user,dnssearch=3Dmgmt.example.org,dnssearch=3Dexample.org [...] +qemu-system-i386 --device e1000,netdev=3Dn1 --netdev user,id=3Dn1,dnssearc= h=3Dmgmt.example.org,dnssearch=3Dexample.org [...] @end example =20 @item tftp=3D@var{dir} @@ -2150,7 +2127,8 @@ a guest from a local directory. =20 Example (using pxelinux): @example -qemu-system-i386 -hda linux.img -boot n -net user,tftp=3D/path/to/tftp/fil= es,bootfile=3D/pxelinux.0 +qemu-system-i386 --hda linux.img --boot n --device e1000,netdev=3Dn1 \ + --netdev user,id=3Dn1,tftp=3D/path/to/tftp/files,bootfile=3D/pxelinux.0 @end example =20 @item smb=3D@var{dir}[,smbserver=3D@var{addr}] @@ -2185,7 +2163,7 @@ screen 0, use the following: =20 @example # on the host -qemu-system-i386 -net user,hostfwd=3Dtcp:127.0.0.1:6001-:6000 [...] +qemu-system-i386 --device virtio-net-pci,netdev=3Dn1 --netdev user,id=3Dn1= ,hostfwd=3Dtcp:127.0.0.1:6001-:6000 [...] # this host xterm should open in the guest X11 server xterm -display :1 @end example @@ -2195,7 +2173,7 @@ the guest, use the following: =20 @example # on the host -qemu-system-i386 -net user,hostfwd=3Dtcp::5555-:23 [...] +qemu-system-i386 --device e1000,netdev=3Dn1 --netdev user,id=3Dn1,hostfwd= =3Dtcp::5555-:23 [...] telnet localhost 5555 @end example =20 @@ -2214,7 +2192,7 @@ lifetime, like in the following example: @example # open 10.10.1.1:4321 on bootup, connect 10.0.2.100:1234 to it whenever # the guest accesses it -qemu -net user,guestfwd=3Dtcp:10.0.2.100:1234-tcp:10.10.1.1:4321 [...] +qemu-system-i386 --device e1000,netdev=3Dn1 --netdev user,id=3Dn1,guestfwd= =3Dtcp:10.0.2.100:1234-tcp:10.10.1.1:4321 [...] @end example =20 Or you can execute a command on every TCP connection established by the gu= est, @@ -2223,7 +2201,7 @@ so that QEMU behaves similar to an inetd process for = that virtual server: @example # call "netcat 10.10.1.1 4321" on every TCP connection to 10.0.2.100:1234 # and connect the TCP stream to its stdin/stdout -qemu -net 'user,guestfwd=3Dtcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321' +qemu-system-i386 --device e1000,netdev=3Dn1 --netdev 'user,id=3Dn1,guestfw= d=3Dtcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321' @end example =20 @end table @@ -2233,9 +2211,8 @@ processed and applied to -net user. Mixing them with = the new configuration syntax gives undefined results. Their use for new applications is discoura= ged as they will be removed from future versions. =20 -@item -netdev tap,id=3D@var{id}[,fd=3D@var{h}][,ifname=3D@var{name}][,scri= pt=3D@var{file}][,downscript=3D@var{dfile}][,br=3D@var{bridge}][,helper=3D@= var{helper}] -@itemx -net tap[,vlan=3D@var{n}][,name=3D@var{name}][,fd=3D@var{h}][,ifnam= e=3D@var{name}][,script=3D@var{file}][,downscript=3D@var{dfile}][,br=3D@var= {bridge}][,helper=3D@var{helper}] -Connect the host TAP network interface @var{name} to VLAN @var{n}. +@item --netdev tap,id=3D@var{id}[,fd=3D@var{h}][,ifname=3D@var{name}][,scr= ipt=3D@var{file}][,downscript=3D@var{dfile}][,br=3D@var{bridge}][,helper=3D= @var{helper}] +Configure a host TAP network backend with ID @var{id}. =20 Use the network script @var{file} to configure it and the network script @var{dfile} to deconfigure it. If @var{name} is not provided, the OS @@ -2256,7 +2233,7 @@ Examples: =20 @example #launch a QEMU instance with the default network script -qemu-system-i386 linux.img -net nic -net tap +qemu-system-i386 linux.img --netdev tap,id=3Dn1 --device virtio-net-pci,ne= tdev=3Dn1 @end example =20 @example @@ -2270,12 +2247,11 @@ qemu-system-i386 linux.img \ @example #launch a QEMU instance with the default network helper to #connect a TAP device to bridge br0 -qemu-system-i386 linux.img \ - -net nic -net tap,"helper=3D/path/to/qemu-bridge-helper" +qemu-system-i386 linux.img --device e1000,netdev=3Dn1 \ + --netdev tap,id=3Dn1,"helper=3D/path/to/qemu-bridge-helper" @end example =20 -@item -netdev bridge,id=3D@var{id}[,br=3D@var{bridge}][,helper=3D@var{help= er}] -@itemx -net bridge[,vlan=3D@var{n}][,name=3D@var{name}][,br=3D@var{bridge}= ][,helper=3D@var{helper}] +@item --netdev bridge,id=3D@var{id}[,br=3D@var{bridge}][,helper=3D@var{hel= per}] Connect a host TAP network interface to a host bridge device. =20 Use the network helper @var{helper} to configure the TAP interface and @@ -2288,21 +2264,20 @@ Examples: @example #launch a QEMU instance with the default network helper to #connect a TAP device to bridge br0 -qemu-system-i386 linux.img -net bridge -net nic,model=3Dvirtio +qemu-system-i386 linux.img --netdev bridge,id=3Dn1 --device virtio-net,net= dev=3Dn1 @end example =20 @example #launch a QEMU instance with the default network helper to #connect a TAP device to bridge qemubr0 -qemu-system-i386 linux.img -net bridge,br=3Dqemubr0 -net nic,model=3Dvirtio +qemu-system-i386 linux.img --netdev bridge,br=3Dqemubr0,id=3Dn1 --device v= irtio-net,netdev=3Dn1 @end example =20 -@item -netdev socket,id=3D@var{id}[,fd=3D@var{h}][,listen=3D[@var{host}]:@= var{port}][,connect=3D@var{host}:@var{port}] -@itemx -net socket[,vlan=3D@var{n}][,name=3D@var{name}][,fd=3D@var{h}] [,l= isten=3D[@var{host}]:@var{port}][,connect=3D@var{host}:@var{port}] +@item --netdev socket,id=3D@var{id}[,fd=3D@var{h}][,listen=3D[@var{host}]:= @var{port}][,connect=3D@var{host}:@var{port}] =20 -Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual -machine using a TCP socket connection. If @option{listen} is -specified, QEMU waits for incoming connections on @var{port} +This host network backend can be used to connect the guest's network to +another QEMU virtual machine using a TCP socket connection. If @option{lis= ten} +is specified, QEMU waits for incoming connections on @var{port} (@var{host} is optional). @option{connect} is used to connect to another QEMU instance using the @option{listen} option. @option{fd}=3D@var= {h} specifies an already opened TCP socket. @@ -2311,21 +2286,19 @@ Example: @example # launch a first QEMU instance qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:56 \ - -net socket,listen=3D:1234 -# connect the VLAN 0 of this instance to the VLAN 0 -# of the first instance + --device e1000,netdev=3Dn1,mac=3D52:54:00:12:34:56 \ + --netdev socket,id=3Dn1,listen=3D:1234 +# connect the network of this instance to the network of the first instance qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:57 \ - -net socket,connect=3D127.0.0.1:1234 + --device e1000,netdev=3Dn2,mac=3D52:54:00:12:34:57 \ + --netdev socket,id=3Dn2,connect=3D127.0.0.1:1234 @end example =20 -@item -netdev socket,id=3D@var{id}[,fd=3D@var{h}][,mcast=3D@var{maddr}:@va= r{port}[,localaddr=3D@var{addr}]] -@itemx -net socket[,vlan=3D@var{n}][,name=3D@var{name}][,fd=3D@var{h}][,mc= ast=3D@var{maddr}:@var{port}[,localaddr=3D@var{addr}]] +@item --netdev socket,id=3D@var{id}[,fd=3D@var{h}][,mcast=3D@var{maddr}:@v= ar{port}[,localaddr=3D@var{addr}]] =20 -Create a VLAN @var{n} shared with another QEMU virtual -machines using a UDP multicast socket, effectively making a bus for -every QEMU with same multicast address @var{maddr} and @var{port}. +Configure a socket host network backend to shared the guest's network traf= fic +with another QEMU virtual machines using a UDP multicast socket, effective= ly +making a bus for every QEMU with same multicast address @var{maddr} and @v= ar{port}. NOTES: @enumerate @item @@ -2342,25 +2315,24 @@ Example: @example # launch one QEMU instance qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:56 \ - -net socket,mcast=3D230.0.0.1:1234 + --device e1000,netdev=3Dn1,mac=3D52:54:00:12:34:56 \ + --netdev socket,id=3Dn1,mcast=3D230.0.0.1:1234 # launch another QEMU instance on same "bus" qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:57 \ - -net socket,mcast=3D230.0.0.1:1234 + --device e1000,netdev=3Dn2,mac=3D52:54:00:12:34:57 \ + --netdev socket,id=3Dn2,mcast=3D230.0.0.1:1234 # launch yet another QEMU instance on same "bus" qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:58 \ - -net socket,mcast=3D230.0.0.1:1234 + --device e1000,netdev=3Dn3,macaddr=3D52:54:00:12:34:58 \ + --netdev socket,id=3Dn3,mcast=3D230.0.0.1:1234 @end example =20 Example (User Mode Linux compat.): @example -# launch QEMU instance (note mcast address selected -# is UML's default) +# launch QEMU instance (note mcast address selected is UML's default) qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:56 \ - -net socket,mcast=3D239.192.168.1:1102 + --device e1000,netdev=3Dn1,mac=3D52:54:00:12:34:56 \ + --netdev socket,id=3Dn1,mcast=3D239.192.168.1:1102 # launch UML /path/to/linux ubd0=3D/path/to/root_fs eth0=3Dmcast @end example @@ -2368,14 +2340,13 @@ qemu-system-i386 linux.img \ Example (send packets from host's 1.2.3.4): @example qemu-system-i386 linux.img \ - -net nic,macaddr=3D52:54:00:12:34:56 \ - -net socket,mcast=3D239.192.168.1:1102,localaddr=3D1.2.3.4 + --device e1000,netdev=3Dn1,mac=3D52:54:00:12:34:56 \ + --netdev socket,id=3Dn1,mcast=3D239.192.168.1:1102,locala= ddr=3D1.2.3.4 @end example =20 -@item -netdev l2tpv3,id=3D@var{id},src=3D@var{srcaddr},dst=3D@var{dstaddr}= [,srcport=3D@var{srcport}][,dstport=3D@var{dstport}],txsession=3D@var{txses= sion}[,rxsession=3D@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pinc= ounter][,txcookie=3D@var{txcookie}][,rxcookie=3D@var{rxcookie}][,offset=3D@= var{offset}] -@itemx -net l2tpv3[,vlan=3D@var{n}][,name=3D@var{name}],src=3D@var{srcaddr= },dst=3D@var{dstaddr}[,srcport=3D@var{srcport}][,dstport=3D@var{dstport}],t= xsession=3D@var{txsession}[,rxsession=3D@var{rxsession}][,ipv6][,udp][,cook= ie64][,counter][,pincounter][,txcookie=3D@var{txcookie}][,rxcookie=3D@var{r= xcookie}][,offset=3D@var{offset}] -Connect VLAN @var{n} to L2TPv3 pseudowire. L2TPv3 (RFC3391) is a popular -protocol to transport Ethernet (and other Layer 2) data frames between +@item --netdev l2tpv3,id=3D@var{id},src=3D@var{srcaddr},dst=3D@var{dstaddr= }[,srcport=3D@var{srcport}][,dstport=3D@var{dstport}],txsession=3D@var{txse= ssion}[,rxsession=3D@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pin= counter][,txcookie=3D@var{txcookie}][,rxcookie=3D@var{rxcookie}][,offset=3D= @var{offset}] +Configure a L2TPv3 pseudowire host network backend. L2TPv3 (RFC3391) is a +popular protocol to transport Ethernet (and other Layer 2) data frames bet= ween two systems. It is present in routers, firewalls and the Linux kernel (from version 3.3 onwards). =20 @@ -2428,14 +2399,13 @@ brctl addif br-lan vmtunnel0 # on 4.3.2.1 # launch QEMU instance - if your network has reorder or is very lossy add = ,pincounter =20 -qemu-system-i386 linux.img -net nic -net l2tpv3,src=3D4.2.3.1,dst=3D1.2.3.= 4,udp,srcport=3D16384,dstport=3D16384,rxsession=3D0xffffffff,txsession=3D0x= ffffffff,counter - +qemu-system-i386 linux.img --device e1000,netdev=3Dn1 \ + --netdev l2tpv3,id=3Dn1,src=3D4.2.3.1,dst=3D1.2.3.4,udp,srcport=3D1638= 4,dstport=3D16384,rxsession=3D0xffffffff,txsession=3D0xffffffff,counter =20 @end example =20 -@item -netdev vde,id=3D@var{id}[,sock=3D@var{socketpath}][,port=3D@var{n}]= [,group=3D@var{groupname}][,mode=3D@var{octalmode}] -@itemx -net vde[,vlan=3D@var{n}][,name=3D@var{name}][,sock=3D@var{socketpa= th}] [,port=3D@var{n}][,group=3D@var{groupname}][,mode=3D@var{octalmode}] -Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and +@item --netdev vde,id=3D@var{id}[,sock=3D@var{socketpath}][,port=3D@var{n}= ][,group=3D@var{groupname}][,mode=3D@var{octalmode}] +Configure VDE backend to connect to PORT @var{n} of a vde switch running o= n host and listening for incoming connections on @var{socketpath}. Use GROUP @var{gro= upname} and MODE @var{octalmode} to change default ownership and permissions for communication port. This option is only available if QEMU has been compiled @@ -2446,20 +2416,21 @@ Example: # launch vde switch vde_switch -F -sock /tmp/myswitch # launch QEMU instance -qemu-system-i386 linux.img -net nic -net vde,sock=3D/tmp/myswitch +qemu-system-i386 linux.img --device e1000,netdev=3Dn1 --netdev vde,id=3Dn1= ,sock=3D/tmp/myswitch @end example =20 -@item -netdev hubport,id=3D@var{id},hubid=3D@var{hubid}[,netdev=3D@var{nd}] +@item --netdev hubport,id=3D@var{id},hubid=3D@var{hubid}[,netdev=3D@var{nd= }] =20 -Create a hub port on QEMU "vlan" @var{hubid}. +Create a hub port on the emulated hub with ID @var{hubid}. =20 -The hubport netdev lets you connect a NIC to a QEMU "vlan" instead of a si= ngle -netdev. @code{-net} and @code{-device} with parameter @option{vlan} creat= e the -required hub automatically. Alternatively, you can also connect the hubport -to another netdev with ID @var{nd} by using the @option{netdev=3D@var{nd}} +The hubport netdev lets you connect a NIC to a QEMU emulated hub instead o= f a +single netdev. @code{--net} and @code{--device} with the parameter @option= {vlan} +(deprecated), or @code{--nic hubport} can also be used to connect a +network device or a NIC to a hub. Alternatively, you can also connect the +hubport to another netdev with ID @var{nd} by using the @option{netdev=3D@= var{nd}} option. =20 -@item -netdev vhost-user,chardev=3D@var{id}[,vhostforce=3Don|off][,queues= =3Dn] +@item --netdev vhost-user,chardev=3D@var{id}[,vhostforce=3Don|off][,queues= =3Dn] =20 Establish a vhost-user netdev, backed by a chardev @var{id}. The chardev s= hould be a unix domain socket backed one. The vhost-user uses a specifically def= ined @@ -2488,6 +2459,31 @@ hardware MAC address can be set with @option{mac=3D@= var{macaddr}}. Indicate that no network devices should be configured. It is used to overr= ide the default configuration (default NIC with @option{--net user} backend) w= hich is activated if no other networking options are provided. + +@item -net nic[,vlan=3D@var{n}][,netdev=3D@var{nd}][,macaddr=3D@var{mac}][= ,model=3D@var{type}] [,name=3D@var{name}][,addr=3D@var{addr}][,vectors=3D@v= ar{v}] +@findex -net +Legacy option to configure or create an on-board (or machine default) Netw= ork +Interface Card(NIC) and connect it either to the emulated hub port ("vlan") +with number @var{n} (@var{n} =3D 0 is the default), or to the netdev @var{= nd}. +The NIC is an e1000 by default on the PC target. Optionally, the MAC addre= ss +can be changed to @var{mac}, the device address set to @var{addr} (PCI car= ds +only), and a @var{name} can be assigned for use in monitor commands. +Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vec= tors +that the card should have; this option currently only affects virtio cards= ; set +@var{v} =3D 0 to disable MSI-X. If no @option{-net} option is specified, a= single +NIC is created. QEMU can emulate several different models of network card. +Valid values for @var{type} are +@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er}, +@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139}, +@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}. +Not all devices are supported on all targets. Use @code{-net nic,model=3D= help} +for a list of available devices for your target. + +@item -net user|tap|bridge|socket|l2tpv3|vde[,...][,vlan=3D@var{n}][,name= =3D@var{name}] +Configure a host network backend (with the options corresponding to the sa= me +@option{--netdev} option) and connect it to the emulated hub ("vlan") with= the +number @var{n} (default is number 0). Use @var{name} to specify the name o= f the +hub port. ETEXI =20 STEXI --=20 1.8.3.1