From: Stefan Berger Subject: [PATCH] [XEND] Modprobe vlan support before trying to use vconfig Date: Thu, 26 Jul 2007 09:47:42 -0400 Message-ID: <1185457662.5592.5.camel@gsal-3.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-xqL1Ib3lHRpPPaOJMGCK" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-xqL1Ib3lHRpPPaOJMGCK Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. Signed-off-by: Stefan Berger --=-xqL1Ib3lHRpPPaOJMGCK Content-Disposition: attachment; filename=xend_pif_modprobe_vlan.diff Content-Type: text/x-patch; name=xend_pif_modprobe_vlan.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/tools/python/xen/xend/XendPIF.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/XendPIF.py +++ root/xen-unstable.hg/tools/python/xen/xend/XendPIF.py @@ -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: --=-xqL1Ib3lHRpPPaOJMGCK Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-xqL1Ib3lHRpPPaOJMGCK--