* [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
* Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available
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>
0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2007-09-16 10:03 UTC (permalink / raw)
To: Carlo Marcelo Arenas Belon; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* using the kvm python wrapper (was Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available)
[not found] ` <46ECFF59.3040702-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-09-16 10:37 ` Carlo Marcelo Arenas Belon
2007-09-18 14:03 ` Avi Kivity
0 siblings, 1 reply; 4+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2007-09-16 10:37 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
On Sun, Sep 16, 2007 at 12:03:05PM +0200, Avi Kivity wrote:
<SNIP>
> but why is anyone using this wrapper? I thought I was the
> only one, and that from tradition rather than any real need.
at least in my case, out of confusion, as it gets installed and is not
prepared to work in an installed tree but in the root of a compiled one, hence
generating errors when executed.
FWIW, it is also being used by debian in their kvm package installed in
/etc/kvm/utils/kvm as you can see from :
http://packages.debian.org/sid/kvm
I agree though that it isn't really that useful, and in that case it should
be probably removed (or at least not part of make install)
Carlo
-------------------------------------------------------------------------
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 [flat|nested] 4+ messages in thread
* Re: using the kvm python wrapper (was Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available)
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
0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2007-09-18 14:03 UTC (permalink / raw)
To: Carlo Marcelo Arenas Belon; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Carlo Marcelo Arenas Belon wrote:
> On Sun, Sep 16, 2007 at 12:03:05PM +0200, Avi Kivity wrote:
> <SNIP>
>
>> but why is anyone using this wrapper? I thought I was the
>> only one, and that from tradition rather than any real need.
>>
>
> at least in my case, out of confusion, as it gets installed and is not
> prepared to work in an installed tree but in the root of a compiled one, hence
> generating errors when executed.
>
> FWIW, it is also being used by debian in their kvm package installed in
> /etc/kvm/utils/kvm as you can see from :
>
> http://packages.debian.org/sid/kvm
>
> I agree though that it isn't really that useful, and in that case it should
> be probably removed (or at least not part of make install)
>
I don't think it's installed as part of the kvm Makefile. Maybe that's
a debian specific thing?
--
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/
^ permalink raw reply [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