Patchwork Change "-net tap, helper" to "-net tap, bridgehelper"

login
register
mail settings
Submitter Corey Bryant
Date Feb. 7, 2012, 1:16 a.m.
Message ID <1328577371-19939-1-git-send-email-coreyb@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/139870/
State New
Headers show

Comments

Corey Bryant - Feb. 7, 2012, 1:16 a.m.
The purpose of the "helper" option for "-net tap" isn't obvious
based on its name.  This patch changes the option name to
"bridgehelper" to make its purpose more self-documenting.

With this patch, a typical invocation will be similar to one of the
following (where the default bridge is br0):

  qemu linux.img
  -net tap,bridgehelper="/usr/local/libexec/qemu-bridge-helper"
  -net nic,model=virtio

  qemu linux.img
  -netdev tap,bridgehelper="/usr/local/libexec/qemu-bridge-helper",id=hn0
  -device virtio-net-pci,netdev=hn0,id=nic1

Alternatively, if a user wants to use a different bridge, a typical
invocation would be simliar to one of the following:

  qemu linux.img
  -net tap,bridgehelper="/usr/local/libexec/qemu-bridge-helper --br=qemubr0"
  -net nic,model=virtio

  qemu linux.img
  -netdev tap,bridgehelper="/usr/local/libexec/qemu-bridge-helper --br=qemubr0",id=hn0
  -device virtio-net-pci,netdev=hn0,id=nic1

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
---
 net.c           |    2 +-
 net/tap.c       |   14 +++++++-------
 qemu-options.hx |   24 ++++++++++++------------
 3 files changed, 20 insertions(+), 20 deletions(-)
Paul Brook - Feb. 8, 2012, 11:42 p.m.
> The purpose of the "helper" option for "-net tap" isn't obvious
> based on its name.  This patch changes the option name to
> "bridgehelper" to make its purpose more self-documenting.
> 
> With this patch, a typical invocation will be similar to one of the
> following (where the default bridge is br0):

I don't see why this option is specific to bridging.  Surely it could be used 
in any system where you want to have a helper script open the tap device.

Paul

Patch

diff --git a/net.c b/net.c
index c34474f..3773739 100644
--- a/net.c
+++ b/net.c
@@ -958,7 +958,7 @@  static const struct {
                 .help = "script to shut down the interface",
             }, {
 #ifdef CONFIG_NET_BRIDGE
-                .name = "helper",
+                .name = "bridgehelper",
                 .type = QEMU_OPT_STRING,
                 .help = "command to execute to configure bridge",
             }, {
diff --git a/net/tap.c b/net/tap.c
index f240028..d39c787 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -594,9 +594,9 @@  int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
             qemu_opt_get(opts, "script") ||
             qemu_opt_get(opts, "downscript") ||
             qemu_opt_get(opts, "vnet_hdr") ||
-            qemu_opt_get(opts, "helper")) {
+            qemu_opt_get(opts, "bridgehelper")) {
             error_report("ifname=, script=, downscript=, vnet_hdr=, "
-                         "and helper= are invalid with fd=");
+                         "and bridgehelper= are invalid with fd=");
             return -1;
         }
 
@@ -611,17 +611,17 @@  int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
 
         model = "tap";
 
-    } else if (qemu_opt_get(opts, "helper")) {
+    } else if (qemu_opt_get(opts, "bridgehelper")) {
         if (qemu_opt_get(opts, "ifname") ||
             qemu_opt_get(opts, "script") ||
             qemu_opt_get(opts, "downscript") ||
             qemu_opt_get(opts, "vnet_hdr")) {
             error_report("ifname=, script=, downscript=, and vnet_hdr= "
-                         "are invalid with helper=");
+                         "are invalid with bridgehelper=");
             return -1;
         }
 
-        fd = net_bridge_run_helper(qemu_opt_get(opts, "helper"),
+        fd = net_bridge_run_helper(qemu_opt_get(opts, "bridgehelper"),
                                    DEFAULT_BRIDGE_INTERFACE);
         if (fd == -1) {
             return -1;
@@ -662,9 +662,9 @@  int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
 
     if (qemu_opt_get(opts, "fd")) {
         snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
-    } else if (qemu_opt_get(opts, "helper")) {
+    } else if (qemu_opt_get(opts, "bridgehelper")) {
         snprintf(s->nc.info_str, sizeof(s->nc.info_str),
-                 "helper=%s", qemu_opt_get(opts, "helper"));
+                 "bridgehelper=%s", qemu_opt_get(opts, "bridgehelper"));
     } else {
         const char *ifname, *script, *downscript;
 
diff --git a/qemu-options.hx b/qemu-options.hx
index 19906e5..d484aef 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1222,13 +1222,13 @@  DEF("net", HAS_ARG, QEMU_OPTION_net,
     "-net tap[,vlan=n][,name=str],ifname=name\n"
     "                connect the host TAP network interface to VLAN 'n'\n"
 #else
-    "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h][,vhostforce=on|off]\n"
+    "-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile][,bridgehelper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off][,vhostfd=h][,vhostforce=on|off]\n"
     "                connect the host TAP network interface to VLAN 'n' \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"
     "                use '[down]script=no' to disable script execution\n"
-    "                use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n"
+    "                use bridgehelper command 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n"
     "                configure it\n"
     "                use 'fd=h' to connect to an already opened TAP interface\n"
     "                use 'sndbuf=nbytes' to limit the size of the send buffer (the\n"
@@ -1405,7 +1405,7 @@  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 -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,helper=@var{helper}]
+@item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,bridgehelper=@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
@@ -1415,9 +1415,9 @@  automatically provides one. The default network configure script is
 @file{/etc/qemu-ifdown}. Use @option{script=no} or @option{downscript=no}
 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{/usr/local/libexec/qemu-bridge-helper}.
+If running QEMU as an unprivileged user, use the bridge helper command
+@var{helper} to configure the TAP interface. The default bridge helper
+executable is @file{/usr/local/libexec/qemu-bridge-helper}.
 
 @option{fd}=@var{h} can be used to specify the handle of an already
 opened host TAP interface.
@@ -1437,29 +1437,29 @@  qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
 @end example
 
 @example
-#launch a QEMU instance with the default network helper to
+#launch a QEMU instance with the default bridge helper to
 #connect a TAP device to bridge br0
-qemu linux.img -net nic -net tap,"helper=/usr/local/libexec/qemu-bridge-helper"
+qemu linux.img -net nic -net tap,"bridgehelper=/usr/local/libexec/qemu-bridge-helper"
 @end example
 
 @item -net bridge[,vlan=@var{n}][,name=@var{name}][,br=@var{bridge}][,helper=@var{helper}]
 Connect a host TAP network interface to a host bridge device.
 
-Use the network helper @var{helper} to configure the TAP interface and
-attach it to the bridge. The default network helper executable is
+Use the bridge helper @var{helper} to configure the TAP interface and
+attach it to the bridge. The default bridge helper executable is
 @file{/usr/local/libexec/qemu-bridge-helper} and the default bridge
 device is @file{br0}.
 
 Examples:
 
 @example
-#launch a QEMU instance with the default network helper to
+#launch a QEMU instance with the default bridge helper to
 #connect a TAP device to bridge br0
 qemu linux.img -net bridge -net nic,model=virtio
 @end example
 
 @example
-#launch a QEMU instance with the default network helper to
+#launch a QEMU instance with the default bridge helper to
 #connect a TAP device to bridge qemubr0
 qemu linux.img -net bridge,br=qemubr0 -net nic,model=virtio
 @end example