QemuUtil lib change to work with ubuntu and centos 11/5411/12
authorMatej Klotton <mklotton@cisco.com>
Fri, 17 Feb 2017 12:18:43 +0000 (13:18 +0100)
committerMatej Klotton <mklotton@cisco.com>
Thu, 23 Feb 2017 08:40:46 +0000 (09:40 +0100)
 - replace nc to socat for comunicating with qemu QGA
 - change disk type to use virtio driver
 - add check to bind only network interface for testpmd

Change-Id: I19ab16cbd8fec1ec78263ccfb1309a144e5af845
Signed-off-by: Matej Klotton <mklotton@cisco.com>
bootstrap-centos.sh
resources/libraries/python/QemuUtils.py
resources/libraries/robot/performance.robot
resources/tools/disk-image-builder/centos/CHANGELOG
resources/tools/disk-image-builder/centos/run-listmaker.sh
resources/tools/disk-image-builder/nested/CHANGELOG
resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support
resources/tools/disk-image-builder/nested/image-patches/08-virtio-disk [new file with mode: 0644]
resources/tools/disk-image-builder/ubuntu/CHANGELOG
resources/tools/disk-image-builder/ubuntu/run-listmaker.sh
resources/tools/testbed-setup/playbooks/01-host-setup.yaml

index 0e5e664..a57ae17 100755 (executable)
@@ -27,7 +27,7 @@ VIRL_SERVER_STATUS_FILE="status"
 VIRL_SERVER_EXPECTED_STATUS="PRODUCTION"
 
 VIRL_TOPOLOGY=double-ring-nested.centos7
-VIRL_RELEASE=csit-centos-7.3-1611_2017-02-14_1.3
+VIRL_RELEASE=csit-centos-7.3-1611_2017-02-20_1.3
 
 SSH_OPTIONS="-i ${VIRL_PKEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o LogLevel=error"
 
index a4e14d2..acc00de 100644 (file)
@@ -227,9 +227,10 @@ class QemuUtils(object):
             response will contain the "error" keyword instead of "return".
         """
         # To enter command mode, the qmp_capabilities command must be issued.
-        qmp_cmd = 'echo "{ \\"execute\\": \\"qmp_capabilities\\" }' + \
-            '{ \\"execute\\": \\"' + cmd + '\\" }" | sudo -S nc -U ' + \
-            self.__QMP_SOCK
+        qmp_cmd = 'echo "{ \\"execute\\": \\"qmp_capabilities\\" }' \
+                  '{ \\"execute\\": \\"' + cmd + \
+                  '\\" }" | sudo -S socat - UNIX-CONNECT:' + self.__QMP_SOCK
+
         (ret_code, stdout, stderr) = self._ssh.exec_command(qmp_cmd)
         if int(ret_code) != 0:
             logger.debug('QMP execute failed {0}'.format(stderr))
@@ -246,8 +247,9 @@ class QemuUtils(object):
     def _qemu_qga_flush(self):
         """Flush the QGA parser state
         """
-        qga_cmd = 'printf "\xFF" | sudo -S nc ' \
-            '-q 1 -U ' + self.__QGA_SOCK
+        qga_cmd = '(printf "\xFF"; sleep 1) | sudo -S socat - UNIX-CONNECT:' + \
+                  self.__QGA_SOCK
+        #TODO: probably need something else
         (ret_code, stdout, stderr) = self._ssh.exec_command(qga_cmd)
         if int(ret_code) != 0:
             logger.debug('QGA execute failed {0}'.format(stderr))
@@ -267,8 +269,10 @@ class QemuUtils(object):
         :param cmd: QGA command to execute.
         :type cmd: str
         """
-        qga_cmd = 'echo "{ \\"execute\\": \\"' + cmd + '\\" }" | sudo -S nc ' \
-            '-q 1 -U ' + self.__QGA_SOCK
+        qga_cmd = '(echo "{ \\"execute\\": \\"' + \
+                  cmd + \
+                  '\\" }"; sleep 1) | sudo -S socat - UNIX-CONNECT:' + \
+                  self.__QGA_SOCK
         (ret_code, stdout, stderr) = self._ssh.exec_command(qga_cmd)
         if int(ret_code) != 0:
             logger.debug('QGA execute failed {0}'.format(stderr))
@@ -494,6 +498,9 @@ class QemuUtils(object):
         # If 'huge_allocate' is set to true try to allocate as well.
         self._huge_page_check(allocate=self._qemu_opt.get('huge_allocate'))
 
+        # Disk option
+        drive = '-drive file={},format=raw,cache=none,if=virtio'.format(
+            self._qemu_opt.get('disk_image'))
         # Setup QMP via unix socket
         qmp = '-qmp unix:{0},server,nowait'.format(self.__QMP_SOCK)
         # Setup serial console
@@ -505,11 +512,12 @@ class QemuUtils(object):
             '-device isa-serial,chardev=qga0'
         # Graphic setup
         graphic = '-monitor none -display none -vga none'
+
         # Run QEMU
-        cmd = '{0} {1} {2} {3} {4} -hda {5} {6} {7} {8} {9}'.format(
+        cmd = '{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}'.format(
             self.__QEMU_BIN, self._qemu_opt.get('smp'), mem, ssh_fwd,
             self._qemu_opt.get('options'),
-            self._qemu_opt.get('disk_image'), qmp, serial, qga, graphic)
+            drive, qmp, serial, qga, graphic)
         (ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd, timeout=300)
         if int(ret_code) != 0:
             logger.debug('QEMU start failed {0}'.format(stderr))
index caee7be..20f2f0b 100644 (file)
@@ -80,7 +80,7 @@
 | | ...
 | | Set Suite Variable | ${glob_loss_acceptance} | 0.5
 | | Set Suite Variable | ${glob_loss_acceptance_type} | percentage
-| | Set Suite Variable | ${glob_vm_image} | /var/lib/vm/csit-nested-1.5.img
+| | Set Suite Variable | ${glob_vm_image} | /var/lib/vm/csit-nested-1.6.img
 
 | 2-node circular Topology Variables Setup
 | | [Documentation]
index 0f78c07..b2cb1b9 100644 (file)
@@ -1,3 +1,7 @@
+## [1.3] - 2017-02-20
+
+Added socat and psmisc as vm testing dependency.
+
 ## [1.2] - 2017-01-24
 
 Centos 7.3-1611 -- Add dhcp client to kickstart file.
index 9b19587..0155d9c 100755 (executable)
@@ -64,7 +64,7 @@ RPM_WANTLIST_INFRA="nfs-utils cloud-init pkgconfig yum-utils"
 RPM_WANTLIST_CSIT="python-devel python-pip python-virtualenv python-setuptools python-pip openssl-devel git strongswan"
 RPM_WANTLIST_VPP="dkms bridge-utils"
 RPM_WANTLIST_TREX="zlib-devel unzip"
-RPM_WANTLIST_MISC="gperftools glusterfs glusterfs-api libiscsi libibverbs libpcap libpcap-devel pixman libpng pulseaudio-libs librados2 librbd1 librdmacm libseccomp spice-server libusb usbredir glusterfs-devel seavgabios-bin sgabios-bin ipxe-roms-qemu nss-devel seabios-bin"
+RPM_WANTLIST_MISC="socat psmisc gperftools glusterfs glusterfs-api libiscsi libibverbs libpcap libpcap-devel pixman libpng pulseaudio-libs librados2 librbd1 librdmacm libseccomp spice-server libusb usbredir glusterfs-devel seavgabios-bin sgabios-bin ipxe-roms-qemu nss-devel seabios-bin"
 
 RPM_WANTLIST_NESTED="qemu-img-ev-2.3.0-31.el7_2.21.1.x86_64.rpm libcacard-ev-2.3.0-31.el7_2.21.1.x86_64.rpm libcacard-devel-ev-2.3.0-31.el7_2.21.1.x86_64.rpm qemu-kvm-ev-debuginfo-2.3.0-31.el7_2.21.1.x86_64.rpm qemu-kvm-tools-ev-2.3.0-31.el7_2.21.1.x86_64.rpm qemu-kvm-common-ev-2.3.0-31.el7_2.21.1.x86_64.rpm qemu-kvm-ev-2.3.0-31.el7_2.21.1.x86_64.rpm libcacard-tools-ev-2.3.0-31.el7_2.21.1.x86_64.rpm"
 RPM_WANTLIST_JAVA="java-1.8.0-openjdk-headless java-1.8.0-openjdk-devel"
index 50217e2..9901d13 100644 (file)
@@ -1,3 +1,11 @@
+## [1.6] - 2017-02-20
+
+### Changes
+- replace /dev/sda to /dev/vda, to use with virtio disk driver
+- add noapic to bootloader's kernel line
+- bind igb_uio driver only to network device
+
+
 ## [1.5] - 2016-11-14
 
 ### Changes
index 5990f09..2de4ad6 100755 (executable)
@@ -46,10 +46,13 @@ echo 1af4 1000 > /sys/bus/pci/drivers/${TARGET_DRIVER}/new_id
 #
 for dev in $(find /sys/bus/pci/drivers/virtio-pci -type l -name '*:*:*.*' | sed -e 's/.*\///')
 do
-  echo Unbinding $dev from virtio-pci
-  echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
-  echo Binding $dev to ${TARGET_DRIVER}
-  echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
+  class=$(cat /sys/bus/pci/drivers/virtio-pci/${dev}/class)
+  if [ "$class" = "0x020000" ]; then
+       echo Unbinding $dev from virtio-pci
+       echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
+       echo Binding $dev to ${TARGET_DRIVER}
+       echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
+  fi
 done
 
 # RCU and IRQ affinity
diff --git a/resources/tools/disk-image-builder/nested/image-patches/08-virtio-disk b/resources/tools/disk-image-builder/nested/image-patches/08-virtio-disk
new file mode 100644 (file)
index 0000000..5ef2782
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+patch boot/grub/menu.lst <<"_EOF"
+17c17
+<       kernel /boot/bzImage rw root=/dev/sda1 ipv6.disable=1 console=ttyS0,115200n8 isolcpus=1,2,3,4 nohz_full=1,2,3,4 rcu_nocbs=1,2,3,4 intel_pstate=disable
+---
+>       kernel /boot/bzImage rw root=/dev/vda1 ipv6.disable=1 console=ttyS0,115200n8 isolcpus=1,2,3,4 nohz_full=1,2,3,4 rcu_nocbs=1,2,3,4 intel_pstate=disable noapic
+_EOF
index 6b904dd..01ab988 100644 (file)
@@ -1,3 +1,7 @@
+## [1.7] - 2017-02-20
+
+Added socat as vm testing dependency.
+
 ## [1.6] - 2016-12-19
 
 Add cmake
index 3b0a2e0..acc1447 100755 (executable)
@@ -66,7 +66,7 @@ APT_WANTLIST_CSIT="python-dev python-pip python-virtualenv git strongswan"
 APT_WANTLIST_TLDK="libpcap0.8-dev libpcap-dev cmake"
 APT_WANTLIST_VPP="dkms bridge-utils"
 APT_WANTLIST_TREX="zlib1g-dev unzip"
-APT_WANTLIST_NESTED="qemu-system-x86"
+APT_WANTLIST_NESTED="socat qemu-system-x86"
 APT_WANTLIST_JAVA="openjdk-8-jdk-headless"
 #Docker is currently disabled due to issues with apt repositories retrieval
 #APT_WANTLIST_DOCKER="docker-engine"
index 3486df5..b660abb 100644 (file)
@@ -27,6 +27,8 @@
     apt: name=crudini state=present
   - name: install expect
     apt: name=expect state=present
+  - name: install socat
+    apt: name=socat state=present
   - name: install qemu
     apt: name=qemu-system-x86 state=present
 - hosts: virl

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.