This patch includes host and guest configuration script updates
[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 source utils.sh
12
13 KERNEL_VERSION=$( getKernelVersion )
14 if [ -z $KERNEL_VERSION ];then
15    echo "Kernel RPM not found"
16    exit 1
17 fi
18 rpmdir=${1:-"/root/workspace/rpm"}
19 rpmpat="kernel-${KERNEL_VERSION}*.rpm"
20 guest_isolcpus=1
21
22 # The script's caller should passing the rpm directory that is built out from
23 # build.sh. The default rpmdir is the one used by yardstick scripts.
24 install_kernel () {
25     # Install the kernel rpm
26     filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
27     if [ $filenum -eq 0 ]
28     then
29         echo "No kernel rpm found in workspace/rpm"
30         exit 1
31     elif [ $filenum -gt 1 ]
32     then
33         echo "Multiple kernel rpm found in workspace/rpm"
34         exit 1
35     else
36         krpm=`find "${rpmdir}" -name "${rpmpat}"`
37         rpm -ihv $krpm
38     fi
39 }
40
41 config_grub () {
42     key=$1
43     val=$2
44
45     if  grep '[" ]'${key} /etc/default/grub > /dev/null ; then
46         sed -i  's/\([" ]\)'${key}'=[^ "]*/\1'${key}'='${val}'/' /etc/default/grub
47     else
48         sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 '${key}'='${val}'"/' /etc/default/grub
49     fi
50 }
51
52 # Isolate CPUs from the general scheduler
53 config_grub 'isolcpus' ${guest_isolcpus}
54
55 # Stop timer ticks on isolated CPUs whenever possible
56 config_grub 'nohz_full' ${guest_isolcpus}
57
58 # Disable machine check
59 config_grub 'mce' 'off'
60
61 # Use polling idle loop to improve performance
62 config_grub 'idle' 'poll'
63
64 ## Disable clocksource verification at runtime
65 config_grub 'tsc' 'reliable'
66
67 sed -ie 's/saved/0/g' /etc/default/grub
68 install_kernel
69 grub2-mkconfig -o /boot/grub2/grub.cfg