summaryrefslogtreecommitdiffstats
path: root/ci/envs
diff options
context:
space:
mode:
Diffstat (limited to 'ci/envs')
-rw-r--r--ci/envs/create-rt-tests-rpm.sh30
-rwxr-xr-xci/envs/guest-cmd.sh10
-rwxr-xr-xci/envs/guest-modify.sh142
-rwxr-xr-xci/envs/guest-setup0.sh63
-rwxr-xr-xci/envs/guest-setup1.sh26
-rw-r--r--ci/envs/host-config19
-rwxr-xr-xci/envs/host-run-qemu.sh45
-rwxr-xr-xci/envs/host-setup0.sh75
-rwxr-xr-xci/envs/host-setup1.sh76
-rw-r--r--ci/envs/rt-tests.patch26
10 files changed, 512 insertions, 0 deletions
diff --git a/ci/envs/create-rt-tests-rpm.sh b/ci/envs/create-rt-tests-rpm.sh
new file mode 100644
index 000000000..96fef2bcd
--- /dev/null
+++ b/ci/envs/create-rt-tests-rpm.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+usage ()
+{
+ echo "$0 rpmdir"
+ exit 1
+}
+
+rpmdir=$1
+rm -rf ${rpmdir}/rt-tests-0.96-1.el7.centos.x86_64.rpm
+gitdir=`mktemp -d`
+ROOTDIR=$(cd $(dirname "$0")/../.. && pwd)
+VERSION=v0.96
+cd $gitdir
+git clone https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
+cd rt-tests
+git checkout -b ${VERSION} ${VERSION}
+patch -p1 -i ${ROOTDIR}/ci/envs/rt-tests.patch
+make HAVE_PARSE_CPUSTRING_ALL=1 rpm
+cp ./RPMS/x86_64/rt-tests-0.96-1.el7.centos.x86_64.rpm $rpmdir
+rm -rf $gitdir
+
diff --git a/ci/envs/guest-cmd.sh b/ci/envs/guest-cmd.sh
new file mode 100755
index 000000000..abfa51a40
--- /dev/null
+++ b/ci/envs/guest-cmd.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
diff --git a/ci/envs/guest-modify.sh b/ci/envs/guest-modify.sh
new file mode 100755
index 000000000..1208dd37e
--- /dev/null
+++ b/ci/envs/guest-modify.sh
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# This is copy from yardstick-img-modify on yardstick project. Currently
+# yardstick script only ubuntu image, and this one is more for CentOS.
+# Example invocation:
+# yardstick-img-modify /home/yardstick/tools/ubuntu-server-cloudimg-modify.sh
+#
+# Warning: the script will create files by default in:
+# /tmp/workspace/yardstick
+# the files will be owned by root!
+#
+# TODO: image resize is needed if the base image is too small
+#
+
+set -e
+set -x
+
+die() {
+ echo "error: $1" >&2
+ exit 1
+}
+
+usage () {
+ echo "$0 cmd workspace"
+ exit 1
+}
+
+test $# -eq 2 || usage
+test $(id -u) -eq 0 || die "should invoke using sudo"
+
+ROOTDIR=$(cd $(dirname "$0")/../.. && pwd)
+cmd=$1
+test -x $cmd
+workspace=$2
+mountdir=`mktemp -d`
+
+image_url=${IMAGE_URL:-"http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1510.qcow2"}
+md5sums_url=${MD5SUMS_URL:-"http://cloud.centos.org/centos/7/images/sha256sum.txt"}
+
+imgfile="${workspace}/guest.img"
+raw_imgfile="${workspace}/guest.raw"
+filename=$(basename $image_url)
+md5filename=$(basename $md5sums_url)
+
+# download and checksum base image, conditionally if local copy is outdated
+download() {
+ test -d $workspace || mkdir -p $workspace
+ cd $workspace
+ rm -f $md5filename # always download the checksum file to a detect stale image
+ wget $md5sums_url
+ test -e $filename || wget -nc $image_url
+ grep "$filename\$" $md5filename |sha256sum -c
+ if [ $? -ne 0 ]; then
+ rm $filename
+ wget -nc $image_url
+ grep $filename $md5filename | md5sum -c
+ fi
+ rm -rf $raw_imgfile
+ qemu-img convert $filename $raw_imgfile
+ cd -
+}
+
+# mount image
+setup() {
+ mkdir -p $mountdir
+
+ loopdevice=$(kpartx -l $raw_imgfile | head -1 | cut -f1 -d ' ')
+
+ kpartx -a $raw_imgfile
+ # No idea why need this sleep
+ sleep 3
+ mount /dev/mapper/$loopdevice $mountdir
+
+ cp $cmd "$mountdir/"
+}
+
+# modify image running a script using in a chrooted environment
+modify() {
+ # Add the ssh key to the image
+ mkdir -p ${mountdir}/root/.ssh
+ cp ${ROOTDIR}/ci/envs/kvm4nfv_key.pub ${mountdir}/root/.ssh/authorized_keys
+ chmod 700 ${mountdir}/root/.ssh
+ chmod 600 ${mountdir}/root/.ssh/authorized_keys
+
+
+ umount $mountdir
+
+ qemu-img convert -O qcow2 $raw_imgfile $imgfile
+}
+
+# cleanup (umount) the image
+cleanup() {
+ # designed to be idempotent
+ mount | grep $mountdir && umount $mountdir
+ kpartx -d $raw_imgfile || true
+ rm -f $raw_imgfile
+ rm -rf $mountdir
+}
+
+exitcode=""
+error_trap()
+{
+ local rc=$?
+
+ set +e
+
+ if [ -z "$exitcode" ]; then
+ exitcode=$rc
+ fi
+
+ cleanup
+
+ echo "Image build failed with $exitcode"
+
+ exit $exitcode
+}
+
+main() {
+ cleanup
+
+ trap "error_trap" EXIT SIGTERM
+
+ download
+ setup
+ modify
+
+ trap - EXIT SIGTERM
+ cleanup
+
+ echo "the modified image is found here: $imgfile"
+}
+
+main
diff --git a/ci/envs/guest-setup0.sh b/ci/envs/guest-setup0.sh
new file mode 100755
index 000000000..490bd570d
--- /dev/null
+++ b/ci/envs/guest-setup0.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+
+rpmdir=${1:-"/root/workspace/"}
+rpmpat="kernel-4.1*.rpm"
+rpm -ihv ${rpmdir}/rt-tests-0.96-1.el7.centos.x86_64.rpm
+guest_isolcpus=1
+
+# The script's caller should passing the rpm directory that is built out from
+# build.sh. The default rpmdir is the one used by yardstick scripts.
+install_kernel () {
+ # Install the kernel rpm
+ filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
+ if [ $filenum -eq 0 ]
+ then
+ echo "No kernel rpm found in workspace/rpm"
+ exit 1
+ elif [ $filenum -gt 1 ]
+ then
+ echo "Multiple kernel rpm found in workspace/rpm"
+ exit 1
+ else
+ krpm=`find "${rpmdir}" -name "${rpmpat}"`
+ rpm -ihv $krpm
+ fi
+}
+
+config_grub () {
+ key=$1
+ val=$2
+
+ if grep '[" ]'${key} /etc/default/grub > /dev/null ; then
+ sed -i 's/\([" ]\)'${key}'=[^ "]*/\1'${key}'='${val}'/' /etc/default/grub
+ else
+ sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 '${key}'='${val}'"/' /etc/default/grub
+ fi
+}
+
+# Isolate CPUs from the general scheduler
+config_grub 'isolcpus' ${guest_isolcpus}
+
+# Stop timer ticks on isolated CPUs whenever possible
+config_grub 'nohz_full' ${guest_isolcpus}
+
+# Disable machine check
+config_grub 'mce' 'off'
+
+# Use polling idle loop to improve performance
+config_grub 'idle' 'poll'
+
+## Disable clocksource verification at runtime
+config_grub 'tsc' 'reliable'
+
+grub2-mkconfig -o /boot/grub2/grub.cfg
+install_kernel
diff --git a/ci/envs/guest-setup1.sh b/ci/envs/guest-setup1.sh
new file mode 100755
index 000000000..678baa43b
--- /dev/null
+++ b/ci/envs/guest-setup1.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+set_irq_affinity () {
+ for irq in /proc/irq/* ; do
+ echo 0 > /proc/irq/${1}/smp_affinity_list
+ done
+}
+
+# Disable watchdogs to reduce overhead
+echo 0 > /proc/sys/kernel/watchdog
+echo 0 > /proc/sys/kernel/nmi_watchdog
+
+# Route device interrupts to non-RT CPU
+set_irq_affinity
+
+# Disable RT throttling
+echo -1 > /proc/sys/kernel/sched_rt_period_us
+echo -1 > /proc/sys/kernel/sched_rt_runtime_us
diff --git a/ci/envs/host-config b/ci/envs/host-config
new file mode 100644
index 000000000..ce6243ce0
--- /dev/null
+++ b/ci/envs/host-config
@@ -0,0 +1,19 @@
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+# Isolated cpus for nfv, must be delimited with ','
+host_isolcpus=3,4
+
+# Number of huge pages to create and on which NUMA node
+numa_node=0
+huge_pages=2
+
+# QEMU executable path and number of cpus for guest
+qemu=/usr/libexec/qemu-kvm
+guest_cpus=2
diff --git a/ci/envs/host-run-qemu.sh b/ci/envs/host-run-qemu.sh
new file mode 100755
index 000000000..c7a2fecc6
--- /dev/null
+++ b/ci/envs/host-run-qemu.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+cpumask () {
+ m=$((1<<${1}))
+ printf 0x%x ${m}
+}
+
+qmp_sock="/tmp/qmp-sock-$$"
+
+${qemu} -smp ${guest_cpus} -monitor unix:${qmp_sock},server,nowait -daemonize \
+ -cpu host,migratable=off,+invtsc,+tsc-deadline,pmu=off \
+ -realtime mlock=on -mem-prealloc -enable-kvm -m 1G \
+ -mem-path /mnt/hugetlbfs-1g \
+ -drive file=/root/workspace/image/guest.img,cache=none,aio=threads \
+ -netdev user,id=guest0,hostfwd=tcp::5555-:22 \
+ -device virtio-net-pci,netdev=guest0 \
+ -nographic -serial /dev/null -parallel /dev/null
+
+i=0
+for c in `echo ${host_isolcpus} | sed 's/,/ /g'` ; do
+ cpu[$i]=${c}
+ i=`expr $i + 1`
+done
+
+threads=`echo "info cpus" | nc -U ${qmp_sock} | grep thread_id | cut -d= -f3`
+
+# Bind QEMU processor threads to RT CPUs
+i=0
+for tid in ${threads} ; do
+ tid=`printf %d ${tid}` # this is required to get rid of cr at end
+ mask=`cpumask ${cpu[$i]}`
+ taskset -p ${mask} ${tid}
+ i=`expr $i + 1`
+done
diff --git a/ci/envs/host-setup0.sh b/ci/envs/host-setup0.sh
new file mode 100755
index 000000000..79d1f585a
--- /dev/null
+++ b/ci/envs/host-setup0.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+rpmdir=${1:-"/root/workspace/rpm/"}
+rpmpat="kernel-4.1*.rpm"
+
+config_grub () {
+ key=$1
+ val=$2
+
+ if grep '[" ]'${key} /etc/default/grub > /dev/null ; then
+ sed -i 's/\([" ]\)'${key}'=[^ "]*/\1'${key}'='${val}'/' /etc/default/grub
+ else
+ sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 '${key}'='${val}'"/' /etc/default/grub
+ fi
+}
+
+# The script's caller should passing the rpm directory that is built out from
+# build.sh. The default rpmdir is the one used by yardstick scripts.
+install_kernel () {
+ # Install the kernel rpm
+ filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
+ if [ $filenum -eq 0 ]
+ then
+ echo "No kernel rpm found in workspace/rpm"
+ exit 1
+ elif [ $filenum -gt 1 ]
+ then
+ echo "Multiple kernel rpm found in workspace/rpm"
+ exit 1
+ else
+ krpm=`find "${rpmdir}" -name "${rpmpat}"`
+ rpm -ihv $krpm
+ fi
+}
+
+# Isolate CPUs from the general scheduler
+config_grub 'isolcpus' ${host_isolcpus}
+
+# Stop timer ticks on isolated CPUs whenever possible
+config_grub 'nohz_full' ${host_isolcpus}
+
+# Do not call RCU callbacks on isolated CPUs
+config_grub 'rcu_nocbs' ${host_isolcpus}
+
+# Enable intel iommu driver and disable DMA translation for devices
+config_grub 'iommu' 'pt'
+config_grub 'intel_iommu' 'on'
+
+# Set HugeTLB pages to 1GB
+config_grub 'default_hugepagesz' '1G'
+config_grub 'hugepagesz' '1G'
+
+# Disable machine check
+config_grub 'mce' 'off'
+
+## Use polling idle loop to improve performance
+config_grub 'idle' 'poll'
+
+## Disable clocksource verification at runtime
+config_grub 'tsc' 'reliable'
+
+grub2-mkconfig -o /boot/grub2/grub.cfg
+
+install_kernel
diff --git a/ci/envs/host-setup1.sh b/ci/envs/host-setup1.sh
new file mode 100755
index 000000000..3d2de6ddf
--- /dev/null
+++ b/ci/envs/host-setup1.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+
+##############################
+# Create 1GB pages for guest #
+##############################
+
+hugepage_size=`cat /proc/meminfo |grep Hugepagesize |tr -s " "| cut -f 2 -d " "`
+if [[ $hugepage_size -ne 1048576 ]]
+then
+ echo "Need 1G huge page support for performance benefit"
+ exit 1
+fi
+
+mkdir -p /mnt/hugetlbfs-1g
+mount -t hugetlbfs hugetlbfs /mnt/hugetlbfs-1g -osize=1G
+
+hugepage_dir="/sys/devices/system/node/node${numa_node}/hugepages/hugepages-1048576kB/nr_hugepages"
+
+huge_pages+=`cat $hugepage_dir`
+echo ${huge_pages} > ${hugepage_dir}
+
+############################
+# RT optimization #
+############################
+# Disable watchdogs to reduce overhead
+echo 0 > /proc/sys/kernel/watchdog
+echo 0 > /proc/sys/kernel/nmi_watchdog
+
+# Change RT priority of ksoftirqd and rcuc kernel threads on isolated CPUs
+i=0
+for c in `echo $host_isolcpus | sed 's/,/ /g'` ; do
+ tid=`pgrep -a ksoftirq | grep "ksoftirqd/${c}$" | cut -d ' ' -f 1`
+ chrt -fp 2 ${tid}
+
+ tid=`pgrep -a rcuc | grep "rcuc/${c}$" | cut -d ' ' -f 1`
+ chrt -fp 3 ${tid}
+
+ cpu[$i]=${c}
+ i=`expr $i + 1`
+done
+
+# Change RT priority of rcub kernel threads
+for tid in `pgrep -a rcub | cut -d ' ' -f 1` ; do
+ chrt -fp 3 ${tid}
+done
+
+# Disable RT throttling
+echo -1 > /proc/sys/kernel/sched_rt_period_us
+echo -1 > /proc/sys/kernel/sched_rt_runtime_us
+
+# Reroute interrupts bound to isolated CPUs to CPU 0
+for irq in /proc/irq/* ; do
+ if [ -d ${irq} ] && ! grep - ${irq}/smp_affinity_list > /dev/null ; then
+ al=`cat ${irq}/smp_affinity_list`
+ if [[ ${cpu[*]} =~ ${al} ]] ; then
+ echo 0 > ${irq}/smp_affinity_list
+ fi
+ fi
+done
+
+# Change the iptable so that we can ssh to the guest remotely
+iptables -I INPUT -p tcp --dport 5555 -j ACCEPT
+# TODO: download guest disk image from artifactory
+
diff --git a/ci/envs/rt-tests.patch b/ci/envs/rt-tests.patch
new file mode 100644
index 000000000..b938e0768
--- /dev/null
+++ b/ci/envs/rt-tests.patch
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * * Copyright (c) 2015 Intel Corp.
+ * *
+ * * All rights reserved. This program and the accompanying materials
+ * * are made available under the terms of the Apache License, Version 2.0
+ * * which accompanies this distribution, and is available at
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *******************************************************************************/
+
+diff --git a/Makefile b/Makefile
+index 1e4b7d1b0d3a..98968b94a57f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -198,10 +198,10 @@ release: distclean changelog
+ cp -r Makefile COPYING ChangeLog MAINTAINERS doc README.markdown src tmp/rt-tests
+ rm -f rt-tests-$(VERSION).tar rt-tests-$(VERSION).tar.asc
+ tar -C tmp -cf rt-tests-$(VERSION).tar rt-tests
+- gpg2 --default-key clrkwllms@kernel.org --detach-sign --armor rt-tests-$(VERSION).tar
++ #gpg2 --default-key clrkwllms@kernel.org --detach-sign --armor rt-tests-$(VERSION).tar
+ gzip rt-tests-$(VERSION).tar
+ rm -f ChangeLog
+- cp rt-tests-$(VERSION).tar.gz rt-tests-$(VERSION).tar.asc releases
++ cp rt-tests-$(VERSION).tar.gz releases
+
+ .PHONY: tarball
+ tarball: