public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available
@ 2007-09-16  9:42 Carlo Marcelo Arenas Belon
  2007-09-16 10:03 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2007-09-16  9:42 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

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 <carenas-kLeDWSohozoJb6fo7hG9ng@public.gmane.org>
---
 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/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-18 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-16  9:42 [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available Carlo Marcelo Arenas Belon
2007-09-16 10:03 ` Avi Kivity
     [not found]   ` <46ECFF59.3040702-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-16 10:37     ` using the kvm python wrapper (was Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available) Carlo Marcelo Arenas Belon
2007-09-18 14:03       ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox