From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available Date: Sun, 16 Sep 2007 12:03:05 +0200 Message-ID: <46ECFF59.3040702@qumranet.com> References: <20070916094233.GA13973@tapir> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Carlo Marcelo Arenas Belon Return-path: In-Reply-To: <20070916094233.GA13973@tapir> 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 Carlo Marcelo Arenas Belon wrote: > 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 > > No real objection to the patch (well, the code wants to be in a function), but why is anyone using this wrapper? I thought I was the only one, and that from tradition rather than any real need. > 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(':') > -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- 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/