[virt-tools-list] [RFC] enable direct interface selection

Gerhard Stenzel gstenzel at linux.vnet.ibm.com
Fri Mar 25 15:33:02 UTC 2011


Hi,
here are two patches to enable direct interface selection when defining
a new VM. One is for virtinst and one is for virt-manager. I combine
them in one posting because they are closely related.

If the approach looks okay, I am happy to resend as attachments if
necessary.
If the approach looks not okay, please advice ....





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>

virtinst:

diff --git a/virtinst/VirtualNetworkInterface.py
b/virtinst/VirtualNetworkInterface.py
index 65bfe2b..ae20d05 100644
--- a/virtinst/VirtualNetworkInterface.py
+++ b/virtinst/VirtualNetworkInterface.py
@@ -352,6 +352,8 @@ class
VirtualNetworkInterface(VirtualDevice.VirtualDevice):
             src_xml     = "      <source network='%s'/>\n" %
self.network
         elif self.type == self.TYPE_ETHERNET and self.source_dev:
             src_xml     = "      <source dev='%s'/>\n" %
self.source_dev
+        elif self.type == self.TYPE_DIRECT and self.bridge:
+            src_xml     = "      <source dev='%s' mode='vepa'/>\n" %
self.bridge
 
         if self.model:
             model_xml   = "      <model type='%s'/>\n" % self.model


virt-manager

Index: virt-manager/src/virtManager/uihelpers.py
===================================================================
--- virt-manager.orig/src/virtManager/uihelpers.py
+++ virt-manager/src/virtManager/uihelpers.py
@@ -440,8 +440,10 @@ def populate_network_list(net_list, conn
                 bridge_name = name
                 brlabel = _("(Empty bridge)")
         else:
-            sensitive = False
-            brlabel = "(%s)" % _("Not bridged")
+            sensitive = True
+            nettype = VirtualNetworkInterface.TYPE_DIRECT
+            bridge_name = name
+            brlabel = ": %s" % _("direct")
 
         label = _("Host device %s %s") % (br.get_name(), brlabel)
         if hasShared and not brIdxLabel:
@@ -530,6 +532,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
 

-- 
Best regards, 

Gerhard Stenzel, 
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294




More information about the virt-tools-list mailing list