e852726d749ec56d671254ba23e80623acabbc65
[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 utils.sh
13 source host-config
14
15 KERNEL_VERSION=$( getKernelVersion )
16 if [ -z $KERNEL_VERSION ];then
17    echo "Kernel RPM not found"
18    exit 1
19 fi
20 rpmdir=${1:-"/root/workspace/rpm/"}
21 rpmpat="kernel-${KERNEL_VERSION}*.rpm"
22 rpmdev="kernel-devel-${KERNEL_VERSION}*.rpm"
23
24 config_grub () {
25     key=$1
26     val=$2
27
28     if  grep '[" ]'${key} /etc/default/grub > /dev/null ; then
29         sed -i  's/\([" ]\)'${key}'=[^ "]*/\1'${key}'='${val}'/' /etc/default/grub
30     else
31         sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 '${key}'='${val}'"/' /etc/default/grub
32     fi
33 }
34
35 # The script's caller should passing the rpm directory that is built out from
36 # build.sh. The default rpmdir is the one used by yardstick scripts.
37 install_kernel () {
38     # Install the kernel rpm
39     filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
40     if [ $filenum -eq 0 ]
41     then
42         echo "No kernel rpm found in workspace/rpm"
43         exit 1
44     elif [ $filenum -gt 1 ]
45     then
46         echo "Multiple kernel rpm found in workspace/rpm"
47         exit 1
48     else
49         krpm=`find "${rpmdir}" -name "${rpmpat}"`
50         kdrpm=`find "${rpmdir}" -name "${rpmdev}"`
51         rpm -ihv $krpm
52         rpm -ihv $kdrpm
53     fi
54 }
55
56 # Isolate CPUs from the general scheduler
57 config_grub 'isolcpus' ${host_isolcpus}
58
59 # Stop timer ticks on isolated CPUs whenever possible
60 config_grub 'nohz_full' ${host_isolcpus}
61
62 # Do not call RCU callbacks on isolated CPUs
63 config_grub 'rcu_nocbs' ${host_isolcpus}
64
65 # Enable intel iommu driver and disable DMA translation for devices
66 config_grub 'iommu' 'pt'
67 config_grub 'intel_iommu' 'on'
68
69 # Set HugeTLB pages to 1GB
70 config_grub 'default_hugepagesz' '1G'
71 config_grub 'hugepagesz' '1G'
72
73 # Disable machine check
74 config_grub 'mce' 'off'
75
76 ## Use polling idle loop to improve performance
77 config_grub 'idle' 'poll'
78
79 ## Disable clocksource verification at runtime
80 config_grub 'tsc' 'reliable'
81
82 install_kernel
83
84 grub2-mkconfig -o /boot/grub2/grub.cfg