[Xen-devel] [OSSTEST PATCH 4/6] Debian: preferred arch: Honour LinuxKernPreferredArchInfo

Ian Jackson posted 6 patches 6 years, 9 months ago
[Xen-devel] [OSSTEST PATCH 4/6] Debian: preferred arch: Honour LinuxKernPreferredArchInfo
Posted by Ian Jackson 6 years, 9 months ago
Nothing sets this yet.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 600f18b1..addaaad2 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -1334,6 +1334,44 @@ END
 	preseed_hook_command($ho, 'late_command', $sfx, $cmds);
     });
 
+    my $kern_arch_info = $xopts{LinuxKernPreferredArchInfo};
+    # LinuxKernPreferredArchInfo contains
+    #    Kernel_Debian     the Debian arch for the kernel we would prefer
+    my $kern_arch = $kern_arch_info->{Kernel_Debian};
+    if ($kern_arch &&
+	$ho->{Flags}{"arch-$r{arch}"} && !$ho->{Flags}{"arch-$kern_arch"}) {
+	# We check the flag for $r{arch} because for various reasons
+	# it may not be set.  For example, in standalone mode it is
+	# currently not normally necessary to set any arch hostflags.
+	# In that situation we bet that the kern arch can be used;
+	# this is a good bet because currently this is used for
+	# running amd64 kernels with i386 userland and hosts that can
+	# do only i386 are fairly rare, especially server hosts.
+	# If this causes a problem, setting the i386 host flag will
+	# (somewhat counterintuitively) cause this check to miss
+	# the amd64 host flag
+	logm("NOT using $kern_arch kernel (flags say not supported by host)");
+	$kern_arch = undef;
+    }
+    if ($kern_arch) {
+	logm("Using $kern_arch kernel for $r{arch} userland");
+	preseed_hook_command($ho, 'late_command', $sfx, <<END);
+#!/bin/sh
+set -ex
+in-target sh -xec '
+    # the $r{arch} kernels end up being the default so shuffle them
+    # where update-grub will not find them
+    for f in /boot/vmlinu*; do
+        dpkg-divert --rename --divert "/boot/~disable~\${f##*/}" "\$f"
+    done
+    dpkg --add-architecture $kern_arch
+    apt-get update
+    apt-get install -f -y linux-image-$kern_arch
+    update-grub
+'
+END
+    }
+
     if ( $ho->{Flags}{'need-uboot-bootscr'} ) {
 	my @bootargs = uboot_common_kernel_bootargs($ho);
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel