From: Carlo Marcelo Arenas Belon <carenas-kLeDWSohozoJb6fo7hG9ng@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available
Date: Sun, 16 Sep 2007 04:42:34 -0500 [thread overview]
Message-ID: <20070916094233.GA13973@tapir> (raw)
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/
next reply other threads:[~2007-09-16 9:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-16 9:42 Carlo Marcelo Arenas Belon [this message]
2007-09-16 10:03 ` [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070916094233.GA13973@tapir \
--to=carenas-kledwsohozojb6fo7hg9ng@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox