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