2013-09-29 04:12:21 +07:00
|
|
|
#!/bin/bash
|
2019-02-11 22:14:09 +07:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2013-09-29 04:12:21 +07:00
|
|
|
#
|
|
|
|
# Build a kvm-ready Linux kernel from the tree in the current directory.
|
|
|
|
#
|
2018-04-24 04:03:00 +07:00
|
|
|
# Usage: kvm-build.sh config-template build-dir resdir
|
2013-09-29 04:12:21 +07:00
|
|
|
#
|
|
|
|
# Copyright (C) IBM Corporation, 2011
|
|
|
|
#
|
2019-02-11 22:14:09 +07:00
|
|
|
# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
|
2013-09-29 04:12:21 +07:00
|
|
|
|
|
|
|
config_template=${1}
|
|
|
|
if test -z "$config_template" -o ! -f "$config_template" -o ! -r "$config_template"
|
|
|
|
then
|
|
|
|
echo "kvm-build.sh :$config_template: Not a readable file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
builddir=${2}
|
2018-04-24 04:03:00 +07:00
|
|
|
resdir=${3}
|
2013-09-29 04:12:21 +07:00
|
|
|
|
2017-08-31 05:33:49 +07:00
|
|
|
T=${TMPDIR-/tmp}/test-linux.sh.$$
|
2013-09-29 04:12:21 +07:00
|
|
|
trap 'rm -rf $T' 0
|
|
|
|
mkdir $T
|
|
|
|
|
2017-05-02 07:49:29 +07:00
|
|
|
cp ${config_template} $T/config
|
2013-09-29 04:12:21 +07:00
|
|
|
cat << ___EOF___ >> $T/config
|
2014-02-27 02:16:07 +07:00
|
|
|
CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
|
2013-09-29 04:12:21 +07:00
|
|
|
CONFIG_VIRTIO_PCI=y
|
|
|
|
CONFIG_VIRTIO_CONSOLE=y
|
|
|
|
___EOF___
|
|
|
|
|
2018-04-24 04:03:00 +07:00
|
|
|
configinit.sh $T/config O=$builddir $resdir
|
2013-09-29 04:12:21 +07:00
|
|
|
retval=$?
|
|
|
|
if test $retval -gt 1
|
|
|
|
then
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
ncpus=`cpus2use.sh`
|
2018-04-24 04:03:00 +07:00
|
|
|
make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
|
2013-09-29 04:12:21 +07:00
|
|
|
retval=$?
|
2018-04-24 04:03:00 +07:00
|
|
|
if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
|
2013-09-29 04:12:21 +07:00
|
|
|
then
|
|
|
|
echo Kernel build error
|
2018-04-24 04:03:00 +07:00
|
|
|
egrep "Stop|Error|error:|warning:" < $resdir/Make.out
|
2013-09-29 04:12:21 +07:00
|
|
|
echo Run aborted.
|
|
|
|
exit 3
|
|
|
|
fi
|