From patchwork Tue Sep 13 07:11:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 669211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sYGBG14BKz9sdm for ; Tue, 13 Sep 2016 17:13:57 +1000 (AEST) Received: from localhost ([::1]:46921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhuk-0007i6-4f for incoming@patchwork.ozlabs.org; Tue, 13 Sep 2016 03:13:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhtK-0006cT-Sw for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:12:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjhtH-00058C-Kf for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:12:26 -0400 Received: from ozlabs.ru ([83.169.36.222]:53262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhtH-00052S-9h for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:12:23 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 6EAF01200F3; Tue, 13 Sep 2016 09:11:59 +0200 (CEST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Tue, 13 Sep 2016 17:11:54 +1000 Message-Id: <1473750714-48290-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 2.5.0.rc3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.169.36.222 Subject: [Qemu-devel] [PATCH qemu v2] tap: Allow specifying a bridge 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: Alexey Kardashevskiy Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The tap backend is already using qemu-bridge-helper to attach tap interface to a bridge but (unlike the bridge backend) it always uses the default bridge name - br0. This adds a "br" property support to the tap backend. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Greg Kurz Tested-by: Greg Kurz --- Changes: v2: * documented a new member in json and hx --- net/tap.c | 4 +++- qapi-schema.json | 3 +++ qemu-options.hx | 12 +++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/net/tap.c b/net/tap.c index 6abb962..b6896a7 100644 --- a/net/tap.c +++ b/net/tap.c @@ -857,7 +857,9 @@ free_fail: return -1; } - fd = net_bridge_run_helper(tap->helper, DEFAULT_BRIDGE_INTERFACE, + fd = net_bridge_run_helper(tap->helper, + tap->has_br ? + tap->br : DEFAULT_BRIDGE_INTERFACE, errp); if (fd == -1) { return -1; diff --git a/qapi-schema.json b/qapi-schema.json index c4f3674..dbb9f8f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2575,6 +2575,8 @@ # # @downscript: #optional script to shut down the interface # +# @br: #optional bridge name +# # @helper: #optional command to execute to configure bridge # # @sndbuf: #optional send buffer limit. Understands [TGMKkb] suffixes. @@ -2604,6 +2606,7 @@ '*fds': 'str', '*script': 'str', '*downscript': 'str', + '*br': 'str', '*helper': 'str', '*sndbuf': 'size', '*vnet_hdr': 'bool', diff --git a/qemu-options.hx b/qemu-options.hx index a71aaf8..0b3ea42 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1594,10 +1594,11 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " configure a host TAP network backend with ID 'str'\n" #else "-netdev tap,id=str[,fd=h][,fds=x:y:...:z][,ifname=name][,script=file][,downscript=dfile]\n" - " [,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off]\n" + " [,br=bridge][,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off]\n" " [,vhostfd=h][,vhostfds=x:y:...:z][,vhostforce=on|off][,queues=n]\n" " [,poll-us=n]\n" " configure a host TAP network backend with ID 'str'\n" + " connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n" " use network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n" " to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" @@ -1884,8 +1885,8 @@ processed and applied to -net user. Mixing them with the new configuration syntax gives undefined results. Their use for new applications is discouraged as they will be removed from future versions. -@item -netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,helper=@var{helper}] -@itemx -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,helper=@var{helper}] +@item -netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}] +@itemx -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}] Connect the host TAP network interface @var{name} to VLAN @var{n}. Use the network script @var{file} to configure it and the network script @@ -1896,8 +1897,9 @@ automatically provides one. The default network configure script is to disable script execution. If running QEMU as an unprivileged user, use the network helper -@var{helper} to configure the TAP interface. The default network -helper executable is @file{/path/to/qemu-bridge-helper}. +@var{helper} to configure the TAP interface and attach it to the bridge. +The default network helper executable is @file{/path/to/qemu-bridge-helper} +and the default bridge device is @file{br0}. @option{fd}=@var{h} can be used to specify the handle of an already opened host TAP interface.