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

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Tue Apr 7 15:06:49 UTC 2009


Author: parmelan-guest
Date: Tue Apr  7 15:06:49 2009
New Revision: 707

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=707
Log:
* tools/kvmlaunch:
  - exit with a proper message if the cmdline cannot be determined.
  - when dealing with bond interfaces, connect the first slave interface
    (instead of the bond interface) to the tun device. Also, ignore the other
    slave interfaces (to avoid having to compute non-conflicting MAC
    addresses for them).

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

Modified: branches/0.33-stable/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/debian/changelog?rev=707&op=diff
==============================================================================
--- branches/0.33-stable/debian/changelog (original)
+++ branches/0.33-stable/debian/changelog Tue Apr  7 15:06:49 2009
@@ -1,9 +1,6 @@
 pf-tools (0.33.18-0.WIP) unstable; urgency=low
 
   * WORK IN PROGRESS...
-
-  * lib/PFTools/Net.pm:
-    - in cmpif(), sort eth* before bond*.
 
   * lib/PFTools/Update.pm:
     - in Get_conf(), don't emit a Perl warning when there is no 'action'
@@ -17,10 +14,13 @@
     - use kvmlaunch-helper to have the kvm monitor in the first screen window
       and the guest serial port in the second screen window.
     - prepend the serial console configuration to the kernel cmdline if needed.
-    - new tun devices naming scheme to differentiate betwen bond0 and eth0 in
-      the same guest (use guest.b0 and guest.e0 instead of just guest.0).
-
- -- Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>  Tue, 31 Mar 2009 23:55:47 +0200
+    - exit with a proper message if the cmdline cannot be determined.
+    - when dealing with bond interfaces, connect the first slave interface
+      (instead of the bond interface) to the tun device. Also, ignore the other
+      slave interfaces (to avoid having to compute non-conflicting MAC
+      addresses for them).
+
+ -- Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>  Tue, 07 Apr 2009 16:59:03 +0200
 
 pf-tools (0.33.17-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=707&op=diff
==============================================================================
--- branches/0.33-stable/lib/PFTools/Net.pm (original)
+++ branches/0.33-stable/lib/PFTools/Net.pm Tue Apr  7 15:06:49 2009
@@ -146,10 +146,6 @@
 	if ( defined $4 ) { $bv = $4 }
 	if ( defined $6 ) { $ba = $6 }
     }
-
-    # sort eth* before bond*
-    return -1 if $ai eq 'eth' and $bi eq 'bond';
-    return  1 if $ai eq 'bond' and $bi eq 'eth';
 
     ( $ai cmp $bi ) || ( $an <=> $bn ) || ( $av <=> $bv ) || ( $aa <=> $ba );
 }

Modified: branches/0.33-stable/tools/kvmlaunch
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.33-stable/tools/kvmlaunch?rev=707&op=diff
==============================================================================
--- branches/0.33-stable/tools/kvmlaunch (original)
+++ branches/0.33-stable/tools/kvmlaunch Tue Apr  7 15:06:49 2009
@@ -214,7 +214,8 @@
 	# FIXME: this is a dirty hack to get the cmdline from the PXE config file.
 	my $vm_ip_in_hex = __get_host_ip_in_hex($Z, $vm_hostname);
 	my $pxe_cfg_file = "/distrib/tftpboot/pxelinux.cfg/$vm_ip_in_hex";
-	my $cmdline      = qx{grep DEBCONF_PRIORITY $pxe_cfg_file};
+	my $cmdline      = qx{grep DEBCONF_PRIORITY $pxe_cfg_file}
+	    or croak "FATAL: unable to find cmdline.";
 	chomp $cmdline;
 	$cmdline =~ s{\A \s* append \s* (.*) \s* \z}{$1}xms;
 
@@ -333,31 +334,45 @@
 
     my @interfaces = ();
 #    #UMRemap_If( $Z, $host );
-    my $umif = Get_UM_If( $Z, $host );
+    my $umif = Get_UM_If( $Z, $host ); # FIXME Get_KVM_If ?
+
+    my $hostclass = Host_class($host, $Z);
+    my $N = $Z->{'SERVERS'}->{'BY_NAME'}->{$hostclass};
+    my $M = $N->{'SRVLIST'}->{$host};
+
     foreach my $ifname ( sort { cmpif( $a, $b ) } keys %{$umif} ) {
 	my $tag = $umif->{$ifname};
 	next unless defined $tag;
 
-	my $virtual_ifname = __get_virtual_ifname($host, $ifname);
+	my $slave_ifname;
+	if ($M->{'bonding'}->{$ifname}) {
+	    warn "DEBUG: Bond interface $ifname, slaves: ", join(', ', @{ $M->{'bonding'}->{$ifname} }), "\n"
+		if $option->{'debug'};
+	    # Only use the first slave interface for kvm
+	    # (this avoids having to compute non-conflicting MAC adresses for the other slaves)
+	    $slave_ifname = ${ $M->{'bonding'}->{$ifname} }[0];
+	}
+
+	my $virtual_ifname = __get_virtual_ifname($host, $slave_ifname ? $slave_ifname : $ifname);
 	my $ip_address     = __get_iface_ip($Z, $host, $ifname);
 
-	warn "DEBUG:   iface $ifname <-> tag $tag <-> vif $virtual_ifname <-> IP $ip_address\n"
+	warn "DEBUG:   iface $ifname <-> tag $tag <-> vif $virtual_ifname <-> IP $ip_address",
+	    ($slave_ifname ? " (slave $slave_ifname)" : ''),
+	    "\n"
 	    if $option->{'debug'};
 
-	my ($bridge_name, $mac_address);
+	if ($tag eq 'TRUNK') {
+	    $tag = 0;
+	}
+	my $bridge_name = "br$tag";
+
+	my $mac_address;
 	if ($tag == 13) {
-#	    $bridge_name = 'brsystem2'; # FIXME gruik temporaire
 	    $mac_address = uc $dhcp_address;
 	}
 	else {
-	    if ($tag eq 'TRUNK') {
-		$tag = 0;
-	    }
-
-	    $bridge_name = "br$tag";
-
 	    my @mac_address = qw( AC DE 48 ); # private
-	    # Ajouter les 3 derniers octets de l'adresse IP de cette interface
+	    # Add the last 3 bytes from this interface's IP address
 	    my @ip_address = split '\.', $ip_address;
 	    shift @ip_address;
 	    push @mac_address, map { sprintf "%02X", $_ } @ip_address;
@@ -374,7 +389,10 @@
 	};
     }
 
-    return @interfaces;
+    # sort the interfaces again, because of the game we played with bond interfaces
+    return
+	sort { cmpif( $a->{'ifname'}, $b->{'ifname'} ) }
+	@interfaces;
 }
 
 
@@ -398,12 +416,12 @@
 sub __get_virtual_ifname { my ($host, $ifname) = @_;
 
     my $IFNAMESIZ         = 16;             # <linux/if.h>
-    my $MAX_HOSTNAME_SIZE = $IFNAMESIZ - 4; # '.' + type + digit + NULL
-
-    my ($iface_type, $iface_number) = $ifname =~ m{\A (\D)\D* (\d+) \z}xms;
+    my $MAX_HOSTNAME_SIZE = $IFNAMESIZ - 3; # '.' + digit + NULL
+
+    my ($iface_number) = $ifname =~ m{\A \D+ (\d+) \z}xms;
     my $mangled_hostname = length($host) > $MAX_HOSTNAME_SIZE ? "m-" . crc32_hex($host) : $host;
 
-    my $virtual_ifname = "$mangled_hostname.$iface_type$iface_number";
+    my $virtual_ifname = "$mangled_hostname.$iface_number";
 
     return $virtual_ifname;
 }




More information about the pf-tools-commits mailing list