]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add support for 'passthru' mode for direct network interfaces
authorDirk Herrendorefer <d.herrendoerfer@herrendoerfer.name>
Tue, 17 May 2011 11:26:09 +0000 (13:26 +0200)
committerEric Blake <eblake@redhat.com>
Wed, 18 May 2011 14:15:08 +0000 (08:15 -0600)
starting with kernel 2.6.38 macvtap supports a 'passthru' mode for
attaching virtual functions of a SRIOV capable network card directly to a VM.
This patch adds the capability to configure such a device.

Signed-off-by: Dirk Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
AUTHORS
configure.ac
docs/formatdomain.html.in
docs/schemas/domain.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/util/macvtap.c
src/util/macvtap.h

diff --git a/AUTHORS b/AUTHORS
index 1bb1f0f1aba0baf2c4bd234c90c6931db1998210..a1e93db6bd65e2071f90ae0c0fcc5b2cb0c5316c 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -170,6 +170,7 @@ Patches have also been contributed by:
   Mark Wu              <dwu@redhat.com>
   Yufang Zhang         <yuzhang@redhat.com>
   Supriya Kannery      <supriyak@in.ibm.com>
+  Dirk Herrendoerfer   <d.herrendoerfer@herrendoerfer.name>
 
   [....send patches to get your name here....]
 
index 233e4afa51e7c3d30fc6ca64659586663e96577b..8db3226bb16704e0a5f85040e70afe27d9ff6348 100644 (file)
@@ -2240,6 +2240,13 @@ if test "$with_macvtap" != "no" ; then
 fi
 AM_CONDITIONAL([WITH_MACVTAP], [test "$with_macvtap" = "yes"])
 AC_MSG_RESULT([$with_macvtap])
+if test "$with_macvtap" = yes; then
+    AC_CHECK_DECLS([MACVLAN_MODE_PASSTHRU], [], [], [[
+      #include <sys/socket.h>
+      #include <linux/if_link.h>
+    ]])
+fi
+
 
 AC_ARG_WITH([virtualport],
   AC_HELP_STRING([--with-virtualport],[enable virtual port support @<:@default=check@:>@]),
index 989dcf6317cd8c60f08c8f86e4007f06b5a96703..facdaf297255e3fe93571a1050304b6a472f9182 100644 (file)
       external router or gateway and that device sends them back to the
       host. This procedure is followed if either the source or destination
       device is in <code>private</code> mode.</dd>
+      <dt><code>passthrough</code></dt>
+      <dd>This feature attaches a virtual function of a SRIOV capable
+      NIC directly to a VM without losing the migration capability.
+      All packets are sent to the VF/IF of the configured network device.
+      Depending on the capabilities of the device additional prerequisites or
+      limitations may apply; for example, on Linux this requires
+      kernel 2.6.38 or newer. <span class="since">Since 0.9.2</span></dd>
     </dl>
 
 <pre>
index 7163c6e18637b53f8d6f422b23ddb509ab4039da..b252547eb91edd8bdf5eb7fc117c68b359e324c8 100644 (file)
   </define>
   <define name="bridgeMode">
     <data type="string">
-      <param name="pattern">(vepa|bridge|private)</param>
+      <param name="pattern">(vepa|bridge|private|passthrough)</param>
     </data>
   </define>
   <define name="addrMAC">
index 498438a4899f2dc7a77166dfee277ca96b4478e5..3298c80e57a3036dd3888799062db5063d03548e 100644 (file)
@@ -433,7 +433,8 @@ VIR_ENUM_IMPL(virDomainSeclabel, VIR_DOMAIN_SECLABEL_LAST,
 VIR_ENUM_IMPL(virDomainNetdevMacvtap, VIR_DOMAIN_NETDEV_MACVTAP_MODE_LAST,
               "vepa",
               "private",
-              "bridge")
+              "bridge",
+              "passthrough")
 
 VIR_ENUM_IMPL(virVirtualPort, VIR_VIRTUALPORT_TYPE_LAST,
               "none",
index fe42f21dad5520616c9e50825ac3db11f3343e24..5fe31d41d2d431d6e07a2c80a470410b1bf2d20a 100644 (file)
@@ -335,6 +335,7 @@ enum virDomainNetdevMacvtapType {
     VIR_DOMAIN_NETDEV_MACVTAP_MODE_VEPA,
     VIR_DOMAIN_NETDEV_MACVTAP_MODE_PRIVATE,
     VIR_DOMAIN_NETDEV_MACVTAP_MODE_BRIDGE,
+    VIR_DOMAIN_NETDEV_MACVTAP_MODE_PASSTHRU,
 
     VIR_DOMAIN_NETDEV_MACVTAP_MODE_LAST,
 };
index a7af0cb7817e1b2d921a23e9a91bcd5d6615811e..068638e71b4cf827c6f3f846431a14a449fd60ac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010-2011 Red Hat, Inc.
  * Copyright (C) 2010 IBM Corporation
  *
  * This library is free software; you can redistribute it and/or
 
 # include <netlink/msg.h>
 
+/* Older kernels lacked this enum value.  */
+# if !HAVE_DECL_MACVLAN_MODE_PASSTHRU
+#  define MACVLAN_MODE_PASSTHRU 8
+# endif
+
 #endif /* WITH_MACVTAP || WITH_VIRTUALPORT */
 
 #include "util.h"
@@ -473,6 +478,9 @@ macvtapModeFromInt(enum virDomainNetdevMacvtapType mode)
     case VIR_DOMAIN_NETDEV_MACVTAP_MODE_BRIDGE:
         return MACVLAN_MODE_BRIDGE;
 
+    case VIR_DOMAIN_NETDEV_MACVTAP_MODE_PASSTHRU:
+        return MACVLAN_MODE_PASSTHRU;
+
     case VIR_DOMAIN_NETDEV_MACVTAP_MODE_VEPA:
     default:
         return MACVLAN_MODE_VEPA;
@@ -546,7 +554,7 @@ configMacvtapTap(int tapfd, int vnet_hdr)
  *    be NULL if this function is supposed to choose a name
  * @macaddress: The MAC address for the macvtap device
  * @linkdev: The interface name of the NIC to connect to the external bridge
- * @mode: int describing the mode for 'bridge', 'vepa' or 'private'.
+ * @mode: int describing the mode for 'bridge', 'vepa', 'private' or 'passthru'.
  * @vnet_hdr: 1 to enable IFF_VNET_HDR, 0 to disable it
  * @vmuuid: The UUID of the VM the macvtap belongs to
  * @virtPortProfile: pointer to object holding the virtual port profile data
index 54205c76133b1255f4605cda8ce4eee45d50a232..a1383c454544b63e371a8e948e9f6e4477d68e44 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2011 Red Hat, Inc.
  * Copyright (C) 2010 IBM Corporation
  *
  * This library is free software; you can redistribute it and/or
@@ -89,10 +90,6 @@ void delMacvtap(const char *ifname,
                 const char *linkdev,
                 virVirtualPortProfileParamsPtr virtPortProfile);
 
-#  define MACVTAP_MODE_PRIVATE_STR  "private"
-#  define MACVTAP_MODE_VEPA_STR     "vepa"
-#  define MACVTAP_MODE_BRIDGE_STR   "bridge"
-
 int vpAssociatePortProfileId(const char *macvtap_ifname,
                              const unsigned char *macvtap_macaddr,
                              const char *linkdev,