diff mbox

[Xen-devel,RFC,OSSTEST,09/19] ts-host-install: Add force-mac-address host flag

Message ID 1412942554-752-9-git-send-email-ian.campbell@citrix.com
State New
Headers show

Commit Message

Ian Campbell Oct. 10, 2014, 12:02 p.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.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 ts-host-install | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Ian Jackson Oct. 10, 2014, 2:09 p.m. UTC | #1
Ian Campbell writes ("[PATCH RFC OSSTEST 09/19] ts-host-install: Add force-mac-address host flag"):
> 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.

There is a potential problem with this, which is that Linux doctrine
is that devices do not have stable names.   So if you don't identify
the device by mac address, and your system has more than one network
interface, osstest can't identify the device reliably at all.

Do your actual boards have more than one eth* ?

Ian.
Ian Campbell Oct. 10, 2014, 2:12 p.m. UTC | #2
On Fri, 2014-10-10 at 15:09 +0100, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH RFC OSSTEST 09/19] ts-host-install: Add force-mac-address host flag"):
> > 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.
> 
> There is a potential problem with this, which is that Linux doctrine
> is that devices do not have stable names.   So if you don't identify
> the device by mac address, and your system has more than one network
> interface, osstest can't identify the device reliably at all.
> 
> Do your actual boards have more than one eth* ?

Just the one.

Ian.
Ian Jackson Oct. 10, 2014, 2:55 p.m. UTC | #3
Ian Campbell writes ("Re: [PATCH RFC OSSTEST 09/19] ts-host-install: Add force-mac-address host flag"):
> On Fri, 2014-10-10 at 15:09 +0100, Ian Jackson wrote:
> > Ian Campbell writes ("[PATCH RFC OSSTEST 09/19] ts-host-install: Add force-mac-address host flag"):
> > > 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.
> > 
> > There is a potential problem with this, which is that Linux doctrine
> > is that devices do not have stable names.   So if you don't identify
> > the device by mac address, and your system has more than one network
> > interface, osstest can't identify the device reliably at all.
> > 
> > Do your actual boards have more than one eth* ?
> 
> Just the one.

OK then,

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox

Patch

diff --git a/ts-host-install b/ts-host-install
index 7c8d693..e874b98 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
     }