kvm-build.sh (1317B)
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 12if test -f "$TORTURE_STOPFILE" 13then 14 echo "kvm-build.sh early exit due to run STOP request" 15 exit 1 16fi 17 18config_template=${1} 19if test -z "$config_template" -o ! -f "$config_template" -o ! -r "$config_template" 20then 21 echo "kvm-build.sh :$config_template: Not a readable file" 22 exit 1 23fi 24resdir=${2} 25 26T=${TMPDIR-/tmp}/test-linux.sh.$$ 27trap 'rm -rf $T' 0 28mkdir $T 29 30cp ${config_template} $T/config 31cat << ___EOF___ >> $T/config 32CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD" 33CONFIG_VIRTIO_PCI=y 34CONFIG_VIRTIO_CONSOLE=y 35___EOF___ 36 37configinit.sh $T/config $resdir 38retval=$? 39if test $retval -gt 1 40then 41 exit 2 42fi 43 44# Tell "make" to use double the number of real CPUs on the build system. 45ncpus="`getconf _NPROCESSORS_ONLN`" 46make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1 47retval=$? 48if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out 49then 50 echo Kernel build error 51 egrep "Stop|Error|error:|warning:" < $resdir/Make.out 52 echo Run aborted. 53 exit 3 54fi