The mechanism used to PXE boot can differ depending on the firmware
type. Therefore refactor into Osstest::TestSupport and key off a new
host property "firmware".

Currently supported is "bios" (the default) and "uboot", both of which
use pxelinux.cfg style files.

The default for the firmware property is "bios", hence no change for
any existing system (including those which use uboot, regardless of
whether they are now configured with the firmware proprty or not)

As part of this "setup_pxeboot" becomes "setup_pxeboot_di" since it is
somewhat d-i specific.

Signed-off-by: Ian Campbell <ian.campb...@citrix.com>
---
v3: reorder setup_${firmware}_pxeboot to setup_pxeboot_${firmware}
    join $dicmd in setup_pxeboot instead of caller
---
 Osstest/TestSupport.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++----
 ts-host-install        | 23 ++++++-----------------
 2 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 66a0d81..512efd2 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -104,7 +104,7 @@ BEGIN {
 
                       await_webspace_fetch_byleaf create_webfile
                       file_link_contents get_timeout
-                      setup_pxeboot setup_pxeboot_local host_pxefile
+                      setup_pxeboot_di setup_pxeboot_local host_pxefile
 
                       ether_prefix
 
@@ -2098,16 +2098,34 @@ sub host_pxefile ($;$) {
         (join ",", sort keys %v)." ?";
 }
 
-sub setup_pxeboot ($$) {
+sub setup_pxelinux_bootcfg ($$) {
     my ($ho, $bootfile) = @_;
     my $f= host_pxefile($ho);
     file_link_contents("$ho->{Tftp}{Path}$ho->{Tftp}{PxeDir}$f", $bootfile,
        "$ho->{Name}-pxelinux.cfg");
 }
 
-sub setup_pxeboot_local ($) {
+# Systems using BIOS are configured to use pxelinux
+sub setup_pxeboot_di_bios ($$$$$;%) {
+    my ($ho,$kern,$initrd,$dicmd,$hocmd,%xopts) = @_;
+    my $dtbs = "fdtdir $xopts{dtbs}" if $xopts{dtbs};
+    setup_pxelinux_bootcfg($ho, <<END);
+    serial 0 $c{Baud}
+timeout 5
+label overwrite
+       menu label ^Overwrite
+       menu default
+       kernel $kern
+       append $dicmd initrd=$initrd -- $hocmd
+       ipappend $xopts{ipappend}
+       $dtbs
+default overwrite
+END
+}
+
+sub setup_pxeboot_local_bios ($) {
     my ($ho) = @_;
-    setup_pxeboot($ho, <<END);
+    setup_pxelinux_bootcfg($ho, <<END);
 serial 0 $c{Baud}
 timeout 5
 label local
@@ -2116,6 +2134,29 @@ default local
 END
 }
 
+# uboot emulates pxelinux, so reuse BIOS stuff
+sub setup_pxeboot_di_uboot ($$$$$;%) { return &setup_pxeboot_di_bios; }
+sub setup_pxeboot_local_uboot ($) { return &setup_pxeboot_local_bios; }
+
+sub setup_pxeboot_local ($) {
+    my ($ho) = @_;
+    my $firmware = get_host_property($ho, "firmware", "bios");
+    $firmware =~ s/-/_/g;
+    no strict qw(refs);
+    return &{"setup_pxeboot_local_${firmware}"}($ho);
+}
+
+sub setup_pxeboot_di ($$$$$;%) {
+    my ($ho,$kern,$initrd,$dicmd,$hocmd,%xopts) = @_;
+    my $firmware = get_host_property($ho, "firmware", "bios");
+    $firmware =~ s/-/_/g;
+    no strict qw(refs);
+    return &{"setup_pxeboot_di_${firmware}"}($ho,$kern,$initrd,
+                                            join(' ',@{$dicmd}),
+                                            join(' ',@{$hocmd}),
+                                            %xopts);
+}
+
 #---------- ISO images ----------
 sub iso_create_genisoimage ($$$$;@) {
     my ($ho,$iso,$dir,$isotimeout,@xopts) = @_;
diff --git a/ts-host-install b/ts-host-install
index 57a6b3f..632bac7 100755
--- a/ts-host-install
+++ b/ts-host-install
@@ -244,13 +244,14 @@ SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", 
ATTR{address}=="$ho->{Ether}", A
 END
     }
 
-    my $dtbs = "";
+    my %xopts;
+
     foreach my $kp (keys %{ $ho->{Flags} }) {
        # Backwards compatibility
        $kp = "need-kernel-deb-wheezy-backports" if $kp eq 
"need-kernel-deb-armmp";
        $kp =~ s/need-kernel-deb-$ho->{Suite}-// or next;
 
-       $dtbs = "fdtdir /$d_i/$kp-dtbs"
+       $xopts{dtbs} = "/$d_i/$kp-dtbs"
            if -e "$ho->{Tftp}{Path}/$d_i/$kp-dtbs";
     }
 
@@ -284,21 +285,9 @@ END
         get_host_property($ho, "linux-boot-append $ho->{Suite}", ''),
         get_host_property($ho, "linux-boot-append $ho->{Suite} $r{arch}", '');
 
-    my $dicmd= join ' ', @dicmdline;
-    my $hocmd= join ' ', @hocmdline;
-
-    setup_pxeboot($ho, <<END);
-serial 0 $c{Baud}
-timeout 5
-label overwrite
-       menu label ^Overwrite
-       menu default
-       kernel $kernel
-       append initrd=/$initrd $dicmd -- $hocmd
-       ipappend $ipappend
-       $dtbs
-default overwrite
-END
+    $xopts{ipappend} = $ipappend;
+    setup_pxeboot_di($ho, $kernel, "/$initrd", \@dicmdline, \@hocmdline,
+                    %xopts);
 }
 
 install();
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to