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