pf-tools commit: r737 [parmelan-guest] - in /branches/0.33-stable: debian/changelog lib/PFTools/Net.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Apr 21 15:32:44 UTC 2010


Author: parmelan-guest
Date: Wed Apr 21 15:32:43 2010
New Revision: 737

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=737
Log:
* lib/PFTools/Net.pm:
  - detect if we are running in a KVM or QEMU virtual host.
  - when remapping interfaces, do not reuse bonding slaves.
  - uncomment the Warn for duplicated network definitions.

Modified:
    branches/0.33-stable/debian/changelog
    branches/0.33-stable/lib/PFTools/Net.pm

Modified: branches/0.33-stable/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/debian/changelog?rev=737&op=diff
==============================================================================
--- branches/0.33-stable/debian/changelog (original)
+++ branches/0.33-stable/debian/changelog Wed Apr 21 15:32:43 2010
@@ -8,7 +8,13 @@
     - in Add_Server : adding the possibility for "undefining" an interface for
     a particular numbered host with the special value "NONE"
 
- -- Christophe Caillet <quadchris at free.fr>  Thu, 14 Jan 2010 17:17:03 +0100
+  [ Thomas Parmelan ]
+  * lib/PFTools/Net.pm:
+    - detect if we are running in a KVM or QEMU virtual host.
+    - when remapping interfaces, do not reuse bonding slaves.
+    - uncomment the Warn for duplicated network definitions.
+
+ -- Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>  Wed, 21 Apr 2010 17:27:26 +0200
 
 pf-tools (0.33.19-1) unstable; urgency=low
 

Modified: branches/0.33-stable/lib/PFTools/Net.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/lib/PFTools/Net.pm?rev=737&op=diff
==============================================================================
--- branches/0.33-stable/lib/PFTools/Net.pm (original)
+++ branches/0.33-stable/lib/PFTools/Net.pm Wed Apr 21 15:32:43 2010
@@ -61,7 +61,7 @@
 
 use PFTools::Conf;
 
-use Data::Dumper;
+#use Data::Dumper;
 #$Data::Dumper::Sortkeys = 1;
 #$Data::Dumper::Useperl = 1;
 
@@ -292,6 +292,7 @@
 	$net =~ s/^[^\.]+\.//;
 	my $NET = $Z->{'NETWORK'}->{'BY_NAME'}->{$net};
 
+#Debug "[Get_UM_If] net:$nam ifname: $M->{'ifup'}->{$nam}";
 	if ( $M->{'ifup'}->{$nam} =~ m/([^:.\d]+)(\d+)?(\.(\d+))?(:(\d+))?/ )
 	{
 	    my $ai;
@@ -310,6 +311,7 @@
 		&& ( $umif->{$vlan_raw_device} ne 'TRUNK' || !defined $av )
 		&& $umif->{$vlan_raw_device} ne $NET->{'tag'} )
 	    {
+#Debug "vlan_raw_device:$vlan_raw_device umif:$umif->{$vlan_raw_device} av:$av tag:$NET->{'tag'}";
 		Abort( $ERR_SYNTAX,
 		          "Get_UM_If[" 
 			. $host . "]: "
@@ -334,7 +336,7 @@
 sub UMRemap_If {
     my ( $Z, $host ) = @_;
 
-    #Debug "UMRemap_If called for $host";
+#Debug "UMRemap_If called for $host";
 
     my %umif;
     my %umvlan;
@@ -372,6 +374,20 @@
 		    . $net
 		    . ": cannot wire, tag unknown" );
 	    exit 1;
+	}
+
+	# For kvmlaunch, we must NOT reallocate ethX if it is a slave
+	# of a bonding interface
+	if ($M->{'bonding'}->{ $M->{'ifup'}->{$nam} }) {
+#Debug "slaves for $M->{'ifup'}->{$nam}: " . join ', ', @{ $M->{'bonding'}->{ $M->{'ifup'}->{$nam} } };
+	    foreach my $slave (@{ $M->{'bonding'}->{ $M->{'ifup'}->{$nam} } }) {
+		if ( $slave =~ m/^([^:.\d]+)(\d+)$/ ) {
+		    my ($iftype, $ifnumber) = ($1, $2);
+		    if ($iftype eq 'eth' and $lastused < $ifnumber) {
+			$lastused = $ifnumber;
+		    }
+		}
+	    }
 	}
 
 #Debug "IF '$M->{ifup}->{$nam}' -> NET '$net' -> TAG '" . (defined $NET->{tag} ? $NET->{tag} : '?') . "'\n";
@@ -512,7 +528,7 @@
 	    if ( !defined $umvlan{$nam} ) {
 		$lastused++;
 
-# Debug "orphan UNTAGGED $nam (was $iforphan{$nam}[$namidx]) allocated to eth$lastused\n";
+#Debug "orphan UNTAGGED $nam (was $iforphan{$nam}[$namidx]) allocated to eth$lastused\n";
 		$ifmap{ $iforphan{$nam}[$namidx] } = "eth" . $lastused;
 		$umvlan{$nam}                      = "eth" . $lastused;
 		$umif{ "eth" . $lastused }         = $nam;
@@ -528,7 +544,7 @@
 		}
 	    }
 
-# Debug "iforphan : "; warn Dumper(\%iforphan); Debug "ifmap : "; warn Dumper(\%ifmap);
+#Debug "iforphan : "; warn Dumper(\%iforphan); Debug "ifmap : "; warn Dumper(\%ifmap);
 	}
     }
 
@@ -1444,14 +1460,15 @@
 	    "Masque de reseau manquant pour le reseau " . $net );
     }
 
-#     if ( defined( $Z->{'NETWORK'}->{'BY_ADDR'}->{ $S->{'network'} } ) ) {
-# 	Warn( $ERR_SYNTAX,
-# 	          "Adresse de reseau dupliquee ("
-# 		. $S->{'network'}
-# 		. ") pour le reseau "
-# 		. $net . " avec le reseau "
-# 		. $Z->{'NETWORK'}->{'BY_ADDR'}->{ $S->{'network'} }->{'name'} );
-#     }
+    # Not an error, only a warning
+    if ( defined( $Z->{'NETWORK'}->{'BY_ADDR'}->{ $S->{'network'} } ) ) {
+	Warn( $ERR_SYNTAX,
+	          "Adresse de reseau dupliquee ("
+		. $S->{'network'}
+		. ") pour le reseau "
+		. $net . " avec le reseau "
+		. $Z->{'NETWORK'}->{'BY_ADDR'}->{ $S->{'network'} }->{'name'} );
+    }
 
     # Calcul des adresses, netmasks et broadcasts
     $N->{'name'}      = $net;
@@ -2179,14 +2196,18 @@
     $PFTOOLS_VARS->{'UML'} = 1;
 }
 
-if ( !$PFTOOLS_VARS->{'UML'}
-    && `LANG=C LC_ALL=C /sbin/ifconfig eth0 2>>/dev/null | grep HWaddr | awk '{print \$5}'`
-    =~ "^00:50:56:" )
+elsif ( `grep -e '^model name[ 	]*: QEMU Virtual CPU' /proc/cpuinfo 2>/dev/null` ne '') {
+    $PFTOOLS_VARS->{'KVM'} = 1;
+    $PFTOOLS_VARS->{'UML'} = 1; # not true, but close. Understand "UML" as "generic virtualisation"
+}
+
+elsif ( `LANG=C LC_ALL=C /sbin/ifconfig eth0 2>/dev/null | awk '/HWaddr/ {print \$5}'`
+    =~ m/^00:50:56:/ )
 {
     $PFTOOLS_VARS->{'VMWARE'} = 1;
 }
 
-if ( !$PFTOOLS_VARS->{'UML'} && `/sbin/ifconfig eth3 2>>/dev/null` eq "" ) {
+elsif ( `/sbin/ifconfig eth3 2>/dev/null` eq '' ) {
     $NOETH3 = 1;
 }
 




More information about the pf-tools-commits mailing list