From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlo Marcelo Arenas Belon Subject: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available Date: Sun, 16 Sep 2007 04:42:34 -0500 Message-ID: <20070916094233.GA13973@tapir> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org The following patch is part of a series of fixes used to allow for the use of the kvm python wrapper in Gentoo Linux. In this case, it will check first if /sbin/ip exists before trying to use it to find the MAC address of the network interface (preventing it to bomb out) and use /sbin/ifconfig if not as a fallback Carlo Signed-off-by: Carlo Marcelo Arenas Belon --- kvm | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/kvm b/kvm index 3e19e76..0b509f6 100755 --- a/kvm +++ b/kvm @@ -219,10 +219,16 @@ if options.debugger: if not options.notap: mac = options.mac if not mac: - for line in commands.getoutput('/sbin/ip link show eth0').splitlines(): - m = re.match(r'.*link/ether (..:..:..:..:..:..).*', line) - if m: - mac = m.group(1) + if os.access('/sbin/ip', os.F_OK): + for line in commands.getoutput('/sbin/ip link show eth0').splitlines(): + m = re.match(r'.*link/ether (..:..:..:..:..:..).*', line) + if m: + mac = m.group(1) + else: + for line in commands.getoutput('/sbin/ifconfig eth0').splitlines(): + m = re.match(r'.*HWaddr (..:..:..:..:..:..)', line) + if m: + mac = m.group(1) if not mac: raise Exception, 'Unable to determine eth0 mac address' mac_components = mac.split(':') -- 1.5.1.6 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/