kvm-build.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. #
  3. # Build a kvm-ready Linux kernel from the tree in the current directory.
  4. #
  5. # Usage: kvm-build.sh config-template build-dir resdir
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, you can access it online at
  19. # http://www.gnu.org/licenses/gpl-2.0.html.
  20. #
  21. # Copyright (C) IBM Corporation, 2011
  22. #
  23. # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  24. config_template=${1}
  25. if test -z "$config_template" -o ! -f "$config_template" -o ! -r "$config_template"
  26. then
  27. echo "kvm-build.sh :$config_template: Not a readable file"
  28. exit 1
  29. fi
  30. builddir=${2}
  31. resdir=${3}
  32. T=${TMPDIR-/tmp}/test-linux.sh.$$
  33. trap 'rm -rf $T' 0
  34. mkdir $T
  35. cp ${config_template} $T/config
  36. cat << ___EOF___ >> $T/config
  37. CONFIG_INITRAMFS_SOURCE="$TORTURE_INITRD"
  38. CONFIG_VIRTIO_PCI=y
  39. CONFIG_VIRTIO_CONSOLE=y
  40. ___EOF___
  41. configinit.sh $T/config O=$builddir $resdir
  42. retval=$?
  43. if test $retval -gt 1
  44. then
  45. exit 2
  46. fi
  47. ncpus=`cpus2use.sh`
  48. make O=$builddir -j$ncpus $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
  49. retval=$?
  50. if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
  51. then
  52. echo Kernel build error
  53. egrep "Stop|Error|error:|warning:" < $resdir/Make.out
  54. echo Run aborted.
  55. exit 3
  56. fi