[virt-tools-list] [PATCH V2] virt-manager: enable direct interface selection

Gerhard Stenzel gstenzel at linux.vnet.ibm.com
Fri Apr 8 08:42:34 UTC 2011


Resending the fixed version as I could not find it in git.

The following patch adds support to select direct interfaces
when defining a virtual machine via virt-manager

Signed-off-by: Gerhard Stenzel <gerhard.stenzel at de.ibm.com>

Index: virt-manager/src/virtManager/uihelpers.py
===================================================================
--- virt-manager.orig/src/virtManager/uihelpers.py
+++ virt-manager/src/virtManager/uihelpers.py
@@ -354,7 +354,7 @@ def get_network_selection(net_list, brid
 
     return net_type, net_src
 
-def populate_network_list(net_list, conn, show_manual_bridge=True):
+def populate_network_list(net_list, conn, show_direct_interfaces=True):
     model = net_list.get_model()
     model.clear()
 
@@ -438,8 +438,15 @@ def populate_network_list(net_list, conn
                 bridge_name = name
                 brlabel = _("(Empty bridge)")
         else:
-            sensitive = False
-            brlabel = "(%s)" % _("Not bridged")
+            if (show_direct_interfaces and virtinst.support.check_conn_support(conn.vmm,
+                         virtinst.support.SUPPORT_CONN_HV_DIRECT_INTERFACE)):
+                sensitive = True
+                nettype = VirtualNetworkInterface.TYPE_DIRECT
+                bridge_name = name
+                brlabel = ": %s" % _("macvtap")
+            else:
+                sensitive = False
+                brlabel = "(%s)" % _("Not bridged")
 
         label = _("Host device %s %s") % (br.get_name(), brlabel)
         if hasShared and not brIdxLabel:
@@ -482,11 +489,10 @@ def populate_network_list(net_list, conn
         model.insert(0, row)
         default = 0
 
-    if show_manual_bridge:
-        # After all is said and done, add a manual bridge option
-        manual_row = build_row(None, None, _("Specify shared device name"),
-                               True, False, manual_bridge=True)
-        model.append(manual_row)
+    # After all is said and done, add a manual bridge option
+    manual_row = build_row(None, None, _("Specify shared device name"),
+                           True, False, manual_bridge=True)
+    model.append(manual_row)
 
     set_active(default)
     return return_warn
@@ -527,6 +533,8 @@ def validate_network(parent, conn, netty
             netname = devname
         elif nettype == VirtualNetworkInterface.TYPE_BRIDGE:
             bridge = devname
+        elif nettype == VirtualNetworkInterface.TYPE_DIRECT:
+            bridge = devname
         elif nettype == VirtualNetworkInterface.TYPE_USER:
             pass
 
Index: virt-manager/src/virtManager/create.py
===================================================================
--- virt-manager.orig/src/virtManager/create.py
+++ virt-manager/src/virtManager/create.py
@@ -548,7 +548,7 @@ class vmmCreate(vmmGObjectUI):
         # Networking
         net_list        = self.window.get_widget("config-netdev")
 
-        do_warn = uihelpers.populate_network_list(net_list, self.conn)
+        do_warn = uihelpers.populate_network_list(net_list, self.conn, False)
         self.set_net_warn(self.conn.netdev_error or do_warn,
                           self.conn.netdev_error, True)
 

===================================================================

Best regards, 

Gerhard Stenzel
-------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294




More information about the virt-tools-list mailing list