diff mbox

[Xen-devel,OSSTEST,v2,08/20] ts-host-install: Add force-mac-address host flag

Message ID 1414579302-6692-8-git-send-email-ian.campbell@citrix.com
State New
Headers show

Commit Message

Ian Campbell Oct. 29, 2014, 10:41 a.m. UTC
This causes us to emit udev runes which force the device named in the host's
Interface_Force property to have the MAC address given in the host's Ether
property. This is the reverse of the behaviour of the Interface_Force property
without this flag, which is to rename the device with MAC address Ether to have
the requested name.

This is necessary because the arndale's USB Ethernet device has no burned in
MAC address and there is no mechanism to configure this e.g. via the bootloader
in a way which Linux will then notice.

Without this change Linux will pick a random mac address when loading the
driver, which breaks osstest's attempts to observe when the test host has
picked up its preseed file by watching the webserver logs, since DHCP will not
map a random mac address to the IP we are expecting.

This is only useful on systems which have exactly one Ethernet device,
otherwise there is no reliable way to determine which device is which.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v2; Added final para to commit log.
---
 ts-host-install | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/ts-host-install b/ts-host-install
index 2f72b5f..b954e53 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -181,6 +181,7 @@  sub setup_pxeboot_firstboot($) {
 
     my $ipappend = 2;
     my $wantphysif= get_host_property($ho,'interface force','auto');
+    logm("Forcing interface $wantphysif");
     if ($wantphysif ne 'auto') {
 	$ipappend = 0;
 	die "need Ether for $ho->{Name} ($wantphysif)"
@@ -188,7 +189,9 @@  sub setup_pxeboot_firstboot($) {
         system_checked(qw(mkdir -p --), "$initrd_overlay.d/etc/udev/rules.d");
         file_simple_write_contents
             ("$initrd_overlay.d/etc/udev/rules.d/70-persistent-net.rules",
-             <<END);
+             $ho->{Flags}{'force-mac-address'} ? <<END : <<END);
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNEL=="$wantphysif", RUN += "/bin/ip link set $wantphysif address $ho->{Ether}"
+END
 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$ho->{Ether}", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$wantphysif"
 END
     }