This patch contains the scripts to install the Qemu rpm and make use of it for 29/26729/8
authorshravani <shravani.p@tcs.com>
Thu, 5 Jan 2017 13:06:26 +0000 (18:36 +0530)
committerShravani Paladugula <shravani.p@tcs.com>
Tue, 7 Feb 2017 12:24:08 +0000 (12:24 +0000)
lauching guest VM's

Change-Id: I74ce89e1e0d628b0be2d9165b8418a519b52064d
Co-Authored-By: Y Rajitha <y.rajitha@tcs.com>
Signed-off-by: Shravani <shravani.p@tcs.com>
ci/build_rpm/Dockerfile
ci/cyclicTestTrigger.sh
ci/envs/host-config
ci/envs/host-install-qemu.sh [new file with mode: 0755]
ci/envs/host-run-qemu.sh
ci/envs/utils.sh
tests/kvmfornfv_cyclictest_hostenv_guestenv.yaml

index 6d6d3ba..6004c90 100644 (file)
@@ -7,8 +7,11 @@ RUN yum -y update && yum -y install \
   gcc-c++ \
   zlib-devel \
   gtk2-devel \
+  glib2-devel \
   make \
   gettext \
   bc \
+  bison\
+  flex\
   rpm \
   rpm-build
index ec0477f..d222ae1 100755 (executable)
@@ -14,11 +14,16 @@ testName=$4
 
 source $WORKSPACE/ci/envs/utils.sh
 KERNELRPM_VERSION=$( getKernelVersion )
+QEMURPM_VERSION=$( getQemuVersion )
 
 if [ -z ${KERNELRPM_VERSION} ];then
    echo "Kernel RPM not found in build_output Directory"
    exit 1
 fi
+if [ -z ${QEMURPM_VERSION} ];then
+   echo "QEMU RPM not found in build_output Directory"
+   exit 1
+fi
 
 #calculating and verifying sha512sum of the guestimage.
 function verifyGuestImage {
@@ -82,6 +87,7 @@ function host_clean {
     sudo ssh root@${HOST_IP} "rpm=\$(rpm -qa | grep 'kernel-${KERNELRPM_VERSION}' | awk '{print \$1}'); rpm -ev \$rpm"
     sudo ssh root@${HOST_IP} "rm -rf /boot/initramfs-${KERNELRPM_VERSION}*.img"
     sudo ssh root@${HOST_IP} "grub2-mkconfig -o /boot/grub2/grub.cfg"
+    sudo ssh root@${HOST_IP} "rpm=\$(rpm -qa | grep 'qemu-${QEMURPM_VERSION}'| awk '{print \$1}'); rpm -ev \$rpm"
     sudo ssh root@${HOST_IP} "reboot"
 }
 
@@ -112,6 +118,7 @@ function runCyclicTest {
 
    #copying required files to run yardstick cyclic testcase
    cp $WORKSPACE/build_output/kernel-${KERNELRPM_VERSION}*.rpm ${volume}/rpm
+   cp $WORKSPACE/build_output/qemu-${QEMURPM_VERSION}*.rpm ${volume}/rpm
    cp -r $WORKSPACE/ci/envs/* ${volume}/scripts
    cp -r $WORKSPACE/tests/kvmfornfv_cyclictest_${testName}.yaml ${volume}
    cp -r $WORKSPACE/tests/pod.yaml ${volume}/scripts
index a6beb06..0f77b7a 100755 (executable)
@@ -14,7 +14,7 @@ numa_node=1
 huge_pages=2
 
 # QEMU executable path and number of cpus for guest
-qemu=/usr/libexec/qemu-kvm
+qemu=/usr/local/bin/qemu-system-x86_64
 guest_cpus=2
 
 # Isolated cpus for nfv, must be given as a range '-' and Numa node1 CPU's should be considered
diff --git a/ci/envs/host-install-qemu.sh b/ci/envs/host-install-qemu.sh
new file mode 100755 (executable)
index 0000000..18886ea
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+###############################################################################
+## Copyright (c) 2016 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 utils.sh
+source host-config
+
+QEMU_VERSION=$( getQemuVersion )
+
+if [ -z $QEMU_VERSION ];then
+   echo "qemu RPM not found"
+   exit 1
+fi
+rpmdir=${1:-"/root/workspace/rpm/"}
+rpmpat="qemu-${QEMU_VERSION}*.rpm"
+
+install_qemu () {
+    # Removing Existing qemu rpms
+    qemu_rpm=$(rpm -qa | grep 'qemu')
+    echo "Removing Existing qemu packages"
+    rpm -ev $qemu_rpm
+    # Install the qemu rpm
+    filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
+    if [ $filenum -eq 0 ]
+    then
+        echo "No qemu rpm found in workspace/rpm"
+        exit 1
+    elif [ $filenum -gt 1 ]
+    then
+        echo "Multiple qemu rpm found in workspace/rpm"
+        exit 1
+    else
+       qrpm=`find "${rpmdir}" -name "${rpmpat}"`
+        rpm -ihv $qrpm
+    fi
+}
+install_qemu
index 9cd4b45..389790e 100755 (executable)
@@ -36,6 +36,7 @@ ${qemu} -smp ${guest_cpus} -monitor unix:${qmp_sock},server,nowait \
      -realtime mlock=on -mem-prealloc -enable-kvm -m 1G \
      -mem-path /mnt/hugetlbfs-1g \
      -device virtio-net-pci,netdev=net0 \
+     -vnc :1
 
 threads=`echo "info cpus" | nc -U ${qmp_sock} | grep thread_id | cut -d= -f3`
 
index 90c66ba..89df273 100755 (executable)
@@ -27,3 +27,16 @@ function getHostIP {
    fi
    echo $HOST_IP
 }
+#Get the Qemu version from RPM generated(example:qemu-2.6.0-1.x86_64.rpm)
+function getQemuVersion {
+   rpm_dir="/root/workspace/rpm/"
+   if [ -d "$WORKSPACE" ];then
+      cd $WORKSPACE/build_output 2>/dev/null; qemuRPM=`ls qemu-[[:digit:]]* 2>/dev/null`
+      RPMVERSION=`echo ${qemuRPM}|awk -F '-' '{print $2}' | awk -F '-' '{print $NF}'`
+   elif [ -d "$rpm_dir" ];then
+      cd $rpm_dir 2>/dev/null; qemuRPM=`ls qemu-[[:digit:]]* 2>/dev/null`
+      RPMVERSION=`echo ${qemuRPM}|awk -F '-' '{print $2}' | awk -F '-' '{print $NF}'`
+   fi
+   echo ${RPMVERSION}
+}
+
index f3c84c8..8716851 100644 (file)
@@ -39,6 +39,7 @@ scenarios:
     - "host-setup0.sh"
     - "reboot"
     - "host-setup1.sh"
+    - "host-install-qemu.sh"
     - "host-run-qemu.sh"
     guest_setup_seqs:
     - "guest-setup0.sh"