diff -r a623336112b9 src/virtManager/connection.py
--- a/src/virtManager/connection.py	Sun Feb 03 12:42:21 2008 -0500
+++ b/src/virtManager/connection.py	Fri Feb 08 15:54:40 2008 +0900
@@ -29,6 +29,7 @@ import dbus
 import dbus
 import threading
 import gtk
+import string
 
 from virtManager.domain import vmmDomain
 from virtManager.network import vmmNetwork
@@ -74,6 +75,35 @@ def _splitnetloc(url, start=0):
     else:
         delim = len(url)
     return url[start:delim], url[delim:]
+
+_kernel_version = None
+def kernel_version():
+    global _kernel_version
+    if not _kernel_version:
+        (sysname, nodename, release, version, machine) = os.uname()
+        if release.find("-") != -1:
+            (ver, rel) = release.split("-", 1)
+        else:
+            ver = release
+        _kernel_version = string.split(ver, ".", 4)        
+    return _kernel_version
+
+def cmp_kernel_version(v1, v2):
+    for i in (1, 2, 3):
+        if v1[i] != v2[i]:
+            try:
+                return int(v1[i]) - int(v2[i])
+            except:
+                if (v1[i] > v2[i]):
+                    return 1
+                else:
+                    return -1
+    return 0
+
+if cmp_kernel_version([2,5,0], kernel_version()) < 0:
+    MODULESCONF='/etc/modprobe.conf'
+else:
+    MODULESCONF='/etc/modules.conf'
 
 class vmmConnection(gobject.GObject):
     __gsignals__ = {
@@ -134,6 +164,9 @@ class vmmConnection(gobject.GObject):
         self.record = []
         self.hostinfo = None
 
+        self.hal_list = []
+        self.sysfspath = None
+
         self.detect_network_devices()
 
     def detect_network_devices(self):
@@ -151,6 +184,16 @@ class vmmConnection(gobject.GObject):
             # Find info about all current present media
             for path in self.hal_iface.FindDeviceByCapability("net"):
                 self._device_added(path)
+
+            # Add bonding
+            for mod in self.getNetConfModules():
+                for halmod in self.hal_list:
+                    if mod == halmod:
+                        break
+                else:
+                    if self.getDeviceType(mod) != 'Unknown':
+                        self._bridge_verify(mod, None)
+
         except:
             (type, value, stacktrace) = sys.exc_info ()
             logging.error("Unable to connect to HAL to list network devices: '%s'" + \
@@ -163,52 +206,92 @@ class vmmConnection(gobject.GObject):
         obj = self.bus.get_object("org.freedesktop.Hal", path)
         if obj.QueryCapability("net"):
             name = obj.GetPropertyString("net.interface")
-            mac = obj.GetPropertyString("net.address")
-
-            # Now magic to determine if the device is part of a bridge
-            shared = False
-            bridge = None
-            try:
-                # XXX Linux specific - needs porting for other OS - patches
-                # welcomed...
-                sysfspath = obj.GetPropertyString("linux.sysfs_path")
-
-                # If running a device in bridged mode, there's a reasonable
-                # chance that the actual ethernet device has been renamed to
-                # something else. ethN -> pethN
-                psysfspath = sysfspath[0:len(sysfspath)-len(name)] + "p" + name
-                if os.path.exists(psysfspath):
-                    name = "p" + name
-                    sysfspath = psysfspath
-
-                brportpath = os.path.join(sysfspath, "brport")
-
-                if os.path.exists(brportpath):
-                    shared = True
-                    brlinkpath = os.path.join(brportpath, "bridge")
-                    dest = os.readlink(brlinkpath)
-                    (head,tail) = os.path.split(dest)
-                    bridge = tail
-            except:
-                (type, value, stacktrace) = sys.exc_info ()
-                logging.error("Unable to determine if device is shared:" +
-                              str(type) + " " + str(value) + "\n" + \
-                              traceback.format_exc (stacktrace))
-
-            if self.netdevs.has_key(path):
-                currDev = self.netdevs[path]
-                if currDev.get_info() == (name, mac, shared, bridge):
-                    return
-                del self.netdevs[path]
-            dev = vmmNetDevice(self.config, self, name, mac, shared, bridge)
-            self.netdevs[path] = dev
-            self.emit("netdev-added", dev.get_name())
+            # XXX Linux specific - needs porting for other OS - patches
+            # welcomed...
+            if self.sysfspath is None:
+                self.sysfspath = obj.GetPropertyString("linux.sysfs_path")
+                self.sysfspath = self.sysfspath[0:len(self.sysfspath)-len(name)]
+
+            if not self.netdevs.has_key(name):
+                self.hal_list.append(name)
+                mac = obj.GetPropertyString("net.address")
+                self._bridge_verify(name, mac)
+
+    def _bridge_verify(self, name, mac):
+        if mac is None:
+            mac = self.getmac_fromsysfspath(name)
+
+        # ethN
+        psysfspath = os.path.join(self.sysfspath, name)
+        if os.path.exists(psysfspath):
+            self._bridge_added(name, mac, psysfspath)
+            # ethN.XX (with Tag)
+            self.tag_verify(name, mac, psysfspath)
+            self.device_plus_p(name, mac, psysfspath)
+
+    def device_plus_p(self, name, mac, psysfspath):
+        # Sick, disgusting hack for Xen netloop crack which renames
+        # ethN -> pethN, but which HAL never sees
+        psysfspath = os.path.join(self.sysfspath, "p" + name)
+        if os.path.exists(psysfspath):
+            self._bridge_added("p" + name, mac, psysfspath)
+            # pethN.XX (with Tag)
+            self.tag_verify("p" + name, mac, psysfspath)
+
+    def tag_verify(self, name, mac, psysfspath):
+        import glob
+        # Tag check
+        for tagpath in glob.glob(psysfspath + ".*"):
+            if os.path.exists(tagpath):
+                self._bridge_added(name + tagpath[len(psysfspath):len(tagpath)], mac, tagpath)
+
+    def _bridge_added(self, name, mac, psysfspath):
+        # Now magic to determine if the device is part of a bridge
+        shared = False
+        bridge = None
+
+        brportpath = os.path.join(psysfspath, "brport")
+        try:
+            if os.path.exists(brportpath):
+                shared = True
+                brlinkpath = os.path.join(brportpath, "bridge")
+                dest = os.readlink(brlinkpath)
+                (head,tail) = os.path.split(dest)
+                bridge = tail
+        except:
+            (type, value, stacktrace) = sys.exc_info ()
+            logging.error("Unable to determine if device is shared:" +
+                            str(type) + " " + str(value) + "\n" + \
+                            traceback.format_exc (stacktrace))
+
+        if self.netdevs.has_key(name):
+            currDev = self.netdevs[name]
+            if currDev.get_info() == (name, mac, shared, bridge):
+                return
+            del self.netdevs[name]
+        dev = vmmNetDevice(self.config, self, name, mac, shared, bridge)
+        self.netdevs[name] = dev
+        self.emit("netdev-added", dev.get_name())
+
+    def getmac_fromsysfspath(self, name):
+        mac = None
+        addrpath = self.sysfspath + name + "/address"
+        if os.path.exists(addrpath):
+            df = open(addrpath, 'r')
+            mac = df.readline()
+            df.close()
+
+        return mac
 
     def _device_removed(self, path):
-        if self.netdevs.has_key(path):
-            dev = self.netdevs[path]
+        obj = self.bus.get_object("org.freedesktop.Hal", path)
+        if obj.QueryCapability("net"):
+            name = obj.GetPropertyString("net.interface")
+
+        if self.netdevs.has_key(name):
+            dev = self.netdevs[name]
             self.emit("netdev-removed", dev.get_name())
-            del self.netdevs[path]
+            del self.netdevs[name]
 
     def is_read_only(self):
         return self.readOnly
@@ -847,5 +930,37 @@ class vmmConnection(gobject.GObject):
         else:
             return _("Unknown")
 
+    def getNetConfModules(self, refresh = None):
+        import re
+        modlist = []
+        if not modlist or refresh:
+            if os.path.exists(MODULESCONF):
+                df = open(MODULESCONF, 'r')
+                while True:
+                    rline = df.readline()
+                    if not rline:break
+                    if re.match(r'alias\s.*?\s', rline):
+                        modlist.append(re.search(r'\S*\S', re.search(r'\s.*?\s', re.match(r'alias\s.*?\s', rline).group()).group()).group())
+                df.close()
+        return modlist
+
+    def getDeviceType(self, devname):
+        UNKNOWN = _('Unknown')
+        ETHERNET = _('Ethernet')
+
+        type = UNKNOWN
+        if not devname or devname == "":
+            return type
+        
+        if type == UNKNOWN:
+            try:
+                # try to get a MAC address
+                hwaddr = self.getmac_fromsysfspath(devname)
+                if hwaddr:
+                    type = ETHERNET
+            except:
+                pass
+        return type
+
 gobject.type_register(vmmConnection)
 
