CI integration for KVMforNFV.
[kvmfornfv.git] / ci / envs / guest-setup0.sh
1 #!/bin/bash
2 ##############################################################################
3 ## Copyright (c) 2015 Intel Corp.
4 ##
5 ## All rights reserved. This program and the accompanying materials
6 ## are made available under the terms of the Apache License, Version 2.0
7 ## which accompanies this distribution, and is available at
8 ## http://www.apache.org/licenses/LICENSE-2.0
9 ###############################################################################
10
11
12 rpmdir=${1:-"/root/workspace/rpm"}
13 rpmpat="kernel-4.4*.rpm"
14 guest_isolcpus=1
15
16 # The script's caller should passing the rpm directory that is built out from
17 # build.sh. The default rpmdir is the one used by yardstick scripts.
18 install_kernel () {
19     # Install the kernel rpm
20     filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
21     if [ $filenum -eq 0 ]
22     then
23         echo "No kernel rpm found in workspace/rpm"
24         exit 1
25     elif [ $filenum -gt 1 ]
26     then
27         echo "Multiple kernel rpm found in workspace/rpm"
28         exit 1
29     else
30         krpm=`find "${rpmdir}" -name "${rpmpat}"`
31         rpm -ihv $krpm
32     fi
33 }
34
35 config_grub () {
36     key=$1
37     val=$2
38
39     if  grep '[" ]'${key} /etc/default/grub > /dev/null ; then
40         sed -i  's/\([" ]\)'${key}'=[^ "]*/\1'${key}'='${val}'/' /etc/default/grub
41     else
42         sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 '${key}'='${val}'"/' /etc/default/grub
43     fi
44 }
45
46 # Isolate CPUs from the general scheduler
47 config_grub 'isolcpus' ${guest_isolcpus}
48
49 # Stop timer ticks on isolated CPUs whenever possible
50 config_grub 'nohz_full' ${guest_isolcpus}
51
52 # Disable machine check
53 config_grub 'mce' 'off'
54
55 # Use polling idle loop to improve performance
56 config_grub 'idle' 'poll'
57
58 ## Disable clocksource verification at runtime
59 config_grub 'tsc' 'reliable'
60
61 grub2-mkconfig -o /boot/grub2/grub.cfg
62 install_kernel