Skip to contentSkip to conversation

Fallback to use /sbin/ifconfig if /sbin/ip is not available

PATCH In review Carlo Marcelo Arenas Belon 2 participants 4 messages Sep 16, 2007 – Sep 18, 2007 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fallback to use /sbin/ifconfig if /sbin/ip is not available

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

---
 kvm |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
kvm +10 -4
index 3e19e76..0b509f6 100755
@@ -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(':')
Signature · 7 lines
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/
#1 lore raw
Quoted 8 lines · Carlo Marcelo Arenas Belon

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.

Quoted 33 lines

Carlo

---
 kvm |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
kvm +10 -4
index 3e19e76..0b509f6 100755
@@ -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(':')
Signature · 7 lines
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/

A message that is not in the archive (sent off-list or not yet received): 46ECFF59.3040702-atKUWr5tajBWk0Htik3J/[email protected]

#3 lore raw

using the kvm python wrapper (was Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available)

On Sun, Sep 16, 2007 at 12:03:05PM +0200, Avi Kivity wrote:
<SNIP>

Quoted 2 lines

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/

#4 lore raw

Re: using the kvm python wrapper (was Re: [PATCH] Fallback to use /sbin/ifconfig if /sbin/ip is not available)

Quoted 11 lines · Carlo Marcelo Arenas Belon

On Sun, Sep 16, 2007 at 12:03:05PM +0200, Avi Kivity wrote:
<SNIP>

Quoted 3 lines

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.

Quoted 8 lines

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?

Signature · 7 lines
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/