From 0110af1aae0d63b1298cf582c57b48717241d9dc Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 19 Aug 2006 13:40:17 +0000 Subject: [PATCH] 2006-08-19 13:40:16 by steve Allow MAC address to be specified for the initial network interface. --- bin/xen-create-image | 47 +++++++++++++++++++++++++++++++++++++++----- debian/changelog | 3 +++ etc/xm.tmpl | 21 ++++++++++++++++++-- 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 9637b55..6694286 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -446,7 +446,7 @@ Install an X11 server, using VNC and XDM -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.80 2006-08-18 13:16:55 steve Exp $ + $Id: xen-create-image,v 1.81 2006-08-19 13:40:16 steve Exp $ =cut @@ -901,6 +901,7 @@ sub parseCommandLineArguments "gateway=s", \$CONFIG{'gateway'}, "hostname=s", \$CONFIG{'hostname'}, "ip=s@", \$CONFIG{'ip'}, + "mac=s", \$CONFIG{'mac'}, "netmask=s", \$CONFIG{'netmask'}, "p2p=s", \$CONFIG{'p2p'}, @@ -939,7 +940,7 @@ sub parseCommandLineArguments if ( $VERSION ) { - my $REVISION = '$Revision: 1.80 $'; + my $REVISION = '$Revision: 1.81 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { @@ -1294,16 +1295,52 @@ sub showSummery # # Show each IP address added. # + # Note we only allow the first IP address to have a MAC address specified. + # my $ips = $CONFIG{'ip'}; + my $mac = $CONFIG{'mac'}; my $count = 1; + # + # Print out each network address, and if there is a mac address + # associated with it then use it too. + # foreach my $i ( @$ips ) { - logprint( "IP Address $count : $i\n" ); - $count += 1; + my $m = undef; + + if ( ( $count == 1 ) && ( defined( $mac ) ) ) + { + $m = $mac; + } + + logprint( "IP Address $count : $i" ); + if ( defined( $m ) ) + { + logprint( " [MAC: $m]" ); + } + logprint( "\n" ); + + $count += 1; + } + + # + # mac address setting still works even for DHCP, but in that + # case only the first one works. + # + if ( $CONFIG{'dhcp'} ) + { + if ( defined( $CONFIG{'mac'} ) ) + { + + logprint( "IP Address : DHCP [MAC: $CONFIG{'mac'}]\n" ); + } + else + { + logprint( "IP Address : DHCP\n" ); + } } - $CONFIG{'dhcp'} && logprint( "IP Address : DHCP\n" ); $CONFIG{'netmask'} && logprint( "Netmask : $CONFIG{'netmask'}\n" ); $CONFIG{'gateway'} && logprint( "Gateway : $CONFIG{'gateway'}\n" ); $CONFIG{'p2p'} && logprint( "Point to Point : $CONFIG{'p2p'}\n" ); diff --git a/debian/changelog b/debian/changelog index 4aa87ab..82e99b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,9 @@ (Closes: #383736) - Improved documentation on custom variables in the Xen configuration file in the manpage for xt-create-xen-config + - Allow the MAC address to be set for the first network interface, + regardless of DHCP/static addressing. + (Closes: #383492) xen-tools (2.3-1) unstable; urgency=high diff --git a/etc/xm.tmpl b/etc/xm.tmpl index 8667d85..a558f42 100644 --- a/etc/xm.tmpl +++ b/etc/xm.tmpl @@ -43,11 +43,28 @@ name = '{$hostname}' { if ( $dhcp ) { $OUT .= "dhcp = 'dhcp'\n"; - $OUT .= "vif = [ '' ]"; + + # Setup the mac address, if present. + my $m = ''; + if ( $mac ) + { + $m = "mac=$mac" + } + + $OUT .= "vif = [ '$m' ]"; } else { - $OUT .= "vif = [ 'ip=$ip1' ]"; + # + # Setup the mac address, if present. + # + my $m = ''; + if ( $mac ) + { + $m = "mac=$mac" + } + + $OUT .= "vif = [ 'ip=$ip1,$m' ]"; } }