Modprobe vlan support before trying to use vconfig
PATCH 1/1 Modprobe vlan support before trying to use vconfig
This patch makes sure that vlan support is available before vconfig is used (on Linux). An attempt is made to 'modprobe 8021q' to enable this feature on those systems where it might have been compiled as a module. A warning is left in the log if VLAN could not be enabled.
xen-unstable.hg/tools/python/xen/xend/XendPIF.py +19 -0
@@ -31,6 +31,22 @@ log.setLevel(logging.TRACE) MAC_RE = re.compile(':'.join(['[0-9a-f]{2}'] * 6)) IP_IFACE_RE = re.compile(r'^\d+: (\w+):.*mtu (\d+) .* link/\w+ ([0-9a-f:]+)') +modprobed_8021q = False +ostype = os.uname() + +def linux_enable_vlan(): + global modprobed_8021q + if not os.path.exists("/proc/net/vlan"): + if not modprobed_8021q: + modprobed_8021q = True + rc, o = commands.getstatusoutput("modprobe 8021q") + if rc != 0: + log.warn("Could not enable VLAN feature in kernel.") + return False + else: + return False + return True + def linux_phy_to_virt(pif_name): return 'eth' + re.sub(r'^[a-z]+', '', pif_name)
@@ -91,6 +107,9 @@ def linux_set_mtu(iface, mtu): return False def _create_VLAN(dev, vlan): + if ostype == "Linux" and linux_enable_vlan() == False: + return False + rc, _ = commands.getstatusoutput('vconfig add %s %d' % (dev, vlan)) if rc != 0:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
xen-unstable.hg/tools/python/xen/xend/XendPIF.py log.setLevel(logging.TRACE) · line 38
Quoted 2 lines · Stefan Berger
xen-unstable.hg/tools/python/xen/xend/XendPIF.py +2
-0+def linux_enable_vlan(): + global modprobed_8021q
could this please go in osdep.py with the rest of the OS-specific stuff*, and just have an osdep.enable_vlan() function?
thanks
john
* well, apart from all the new Linux-specific code there is...
John Levon <[email protected]> wrote on 07/26/2007 09:43:57 AM:
Quoted 7 lines · Stefan Berger
xen-unstable.hg/tools/python/xen/xend/XendPIF.py log.setLevel(logging.TRACE) · line 38
Quoted 3 lines
xen-unstable.hg/tools/python/xen/xend/XendPIF.py +2
-0+def linux_enable_vlan(): + global modprobed_8021qcould this please go in
osdep.pywith the rest of the OS-specific stuff*, and just have anosdep.enable_vlan()function?
Ok, I will do that.
Thanks
Stefan
Quoted 5 lines
thanks
john* well, apart from all the new Linux-specific code there is...
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
[email protected] wrote on 07/26/2007 09:43:57 AM:
Quoted 7 lines · Stefan Berger
xen-unstable.hg/tools/python/xen/xend/XendPIF.py log.setLevel(logging.TRACE) · line 38
Quoted 3 lines
xen-unstable.hg/tools/python/xen/xend/XendPIF.py +2
-0+def linux_enable_vlan(): + global modprobed_8021qcould this please go in
osdep.pywith the rest of the OS-specific stuff*, and just have anosdep.enable_vlan()function?
Now after these other two patches that I just committed, the problem with the vlan creation is gone and the only benefit of such a function osdep.enable_vlan() would be to print out a warning message into the log file to indicate that VLAN support is not available on the system (after a failed modprobe). Not sure whether it is worth such a function, though, but might be useful for debugging. Comments?
Stefan
Quoted 10 lines
thanks
john* well, apart from all the new Linux-specific code there is...
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel