mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Skip bonding if /sys/class/net/bonding_masters doesn't exist (Shigeki Sakamoto)
This commit is contained in:
@@ -151,12 +151,13 @@ class vmmConnection(gobject.GObject):
|
||||
# find all bonding master devices and register them
|
||||
# XXX bonding stuff is linux specific
|
||||
bondMasters = self._net_get_bonding_masters()
|
||||
for bond in bondMasters:
|
||||
sysfspath = "/sys/class/net/" + bond
|
||||
mac = self._net_get_mac_address(bond, sysfspath)
|
||||
self._net_device_added(bond, mac, sysfspath)
|
||||
# Add any associated VLANs
|
||||
self._net_tag_device_added(bond, sysfspath)
|
||||
if bondMasters is not None:
|
||||
for bond in bondMasters:
|
||||
sysfspath = "/sys/class/net/" + bond
|
||||
mac = self._net_get_mac_address(bond, sysfspath)
|
||||
self._net_device_added(bond, mac, sysfspath)
|
||||
# Add any associated VLANs
|
||||
self._net_tag_device_added(bond, sysfspath)
|
||||
|
||||
# Find info about all current present physical net devices
|
||||
# This is OS portable...
|
||||
@@ -896,14 +897,17 @@ class vmmConnection(gobject.GObject):
|
||||
|
||||
def _net_get_bonding_masters(self):
|
||||
masters = []
|
||||
f = open("/sys/class/net/bonding_masters")
|
||||
while True:
|
||||
rline = f.readline()
|
||||
if not rline: break
|
||||
if rline == "\x00": continue
|
||||
rline = rline.strip("\n\t")
|
||||
masters = rline[:-1].split(' ')
|
||||
return masters
|
||||
if os.path.exists("/sys/class/net/bonding_masters"):
|
||||
f = open("/sys/class/net/bonding_masters")
|
||||
while True:
|
||||
rline = f.readline()
|
||||
if not rline: break
|
||||
if rline == "\x00": continue
|
||||
rline = rline.strip("\n\t")
|
||||
masters = rline[:-1].split(' ')
|
||||
return masters
|
||||
else:
|
||||
return None
|
||||
|
||||
def _net_is_bonding_slave(self, name, sysfspath):
|
||||
masterpath = sysfspath + "/master"
|
||||
|
||||
Reference in New Issue
Block a user