diff mbox

[OSSTEST,v2,16/19] Set mac address in interfaces(5) if force-mac-address is set

Message ID 20171031135203.11537-17-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Oct. 31, 2017, 1:52 p.m. UTC
ff9e0d8cbd generated a udev rule for setting the mac address. But that
udev rule is not copied into the target so reboot after installation
will fail.

We can copy the udev rule to target system so the reboot after
installation works, but then the generated udev rules will end up in
initramfs, which means the guest (which uses host's initrd)  will use
the same rune to set conflicting mac address.

Put the mac address in interfaces(5). We still need to keep the udev
rule for the initrd overlay otherwise host installation will fail.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 Osstest/Debian.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 2bfd5ae..2c3bcf4 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -1207,6 +1207,16 @@  END
 	preseed_hook_command($ho, 'late_command', $sfx, $cmds);
     }
 
+    my $wantphysif= get_host_property($ho,'interface force','auto');
+    if ($wantphysif ne 'auto' && $ho->{Flags}{'force-mac-address'}) {
+	preseed_hook_command($ho, 'late_command', $sfx, <<END);
+#!/bin/sh
+set -ex
+
+sed -i 's/\\(iface\\s*$wantphysif\\s*inet.*\\)/\\1\\n    hwaddress $ho->{Ether}/' /target/etc/network/interfaces
+END
+    }
+
     if ( $ho->{Flags}{'need-uboot-bootscr'} ) {
 	my @bootargs = uboot_common_kernel_bootargs($ho);