public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Carlo Marcelo Arenas Belon
	<carenas-kLeDWSohozoJb6fo7hG9ng@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is	not available
Date: Sun, 16 Sep 2007 12:03:05 +0200	[thread overview]
Message-ID: <46ECFF59.3040702@qumranet.com> (raw)
In-Reply-To: <20070916094233.GA13973@tapir>

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 <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(':')
>   


-- 
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/

  reply	other threads:[~2007-09-16 10:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
     [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=46ECFF59.3040702@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=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