1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0+ 3# 4# Build a kvm-ready Linux kernel from the tree in the current directory. 5# 6# Usage: kvm-build.sh config-template resdir 7# 8# Copyright (C) IBM Corporation, 2011 9# 10# Authors: Paul E. McKenney <paulmck@linux.ibm.com> 11 12config_template=${1} 13if test -z "$config_template" -o ! -f "$config_template" -o ! -r "$config_template" 14then 15 echo "kvm-build.sh :$config_template: Not a readable file" 16 exit 1 17fi 18resdir=${2} 19 20T=${TMPDIR-/tmp}/test-linux.sh.$$ 21trap 'rm -rf $T' 0 22mkdir $T 23 24cp ${config_template} $T/config 25cat << ___EOF___ >> $T/config 26CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD" 27CONFIG_VIRTIO_PCI=y 28CONFIG_VIRTIO_CONSOLE=y 29___EOF___ 30 31configinit.sh $T/config $resdir 32retval=$? 33if test $retval -gt 1 34then 35 exit 2 36fi 37ncpus=`cpus2use.sh` 38make -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1 39retval=$? 40if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out 41then 42 echo Kernel build error 43 egrep "Stop|Error|error:|warning:" < $resdir/Make.out 44 echo Run aborted. 45 exit 3 46fi 47