From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [OSSTEST PATCH 05/12] ts-xen-install: default the interface to the one in /etc/network/interfaces Date: Tue, 11 Feb 2014 15:25:47 +0000 Message-ID: <1392132354-7594-6-git-send-email-ian.jackson@eu.citrix.com> References: <1392132354-7594-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WDFDp-0007zQ-EO for xen-devel@lists.xenproject.org; Tue, 11 Feb 2014 15:26:05 +0000 In-Reply-To: <1392132354-7594-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org The default was simply eth0. This is the other piece of automatically coping with the boot interface not being eth0. Signed-off-by: Ian Jackson --- ts-xen-install | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ts-xen-install b/ts-xen-install index 09c90ce..a1f5998 100755 --- a/ts-xen-install +++ b/ts-xen-install @@ -22,6 +22,7 @@ use File::Path; use POSIX; use Osstest::Debian; use Osstest::TestSupport; +use Data::Dumper; my $checkmode= 0; @@ -210,6 +211,23 @@ sub nodhcp () { "etc-network-interfaces", sub { my $physif= get_host_property($ho,'interface force',undef); + if (!defined $physif) { + # preread /etc/network/interfaces to figure out the interface + my %candidates; + while () { + next unless + m{^ \s* ( auto \s+ (\S+) ) \s* $}x || + m{^ \s* ( allow-hotplug \s+ (\S+) ) \s* $}x || + m{^ \s* ( iface \s+ (\S+) \s+ inet \s+ ) \s* $}x ; + push @{ $candidates{$2} }, $1; + } + EI->error and die $!; + delete $candidates{'lo'}; + die Dumper(\%candidates)." -- cannot determine default interface" + unless (scalar keys %candidates) == 1; + ($physif,) = keys %candidates; + seek EI,0,0 or die $!; + } my ($iface,$bridgex); if ($initscripts_nobridge) { -- 1.7.10.4