From 8c465631f6029b174e6d2549e1305b5b4cb8b8de Mon Sep 17 00:00:00 2001 From: Matej Klotton Date: Fri, 17 Feb 2017 13:18:43 +0100 Subject: QemuUtil lib change to work with ubuntu and centos - 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 --- resources/libraries/python/QemuUtils.py | 26 ++++++++++++++-------- resources/libraries/robot/performance.robot | 2 +- .../tools/disk-image-builder/centos/CHANGELOG | 4 ++++ .../disk-image-builder/centos/run-listmaker.sh | 2 +- .../tools/disk-image-builder/nested/CHANGELOG | 8 +++++++ .../nested/image-patches/06-dpdk-support | 11 +++++---- .../nested/image-patches/08-virtio-disk | 8 +++++++ .../tools/disk-image-builder/ubuntu/CHANGELOG | 4 ++++ .../disk-image-builder/ubuntu/run-listmaker.sh | 2 +- .../testbed-setup/playbooks/01-host-setup.yaml | 2 ++ 10 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 resources/tools/disk-image-builder/nested/image-patches/08-virtio-disk (limited to 'resources') diff --git a/resources/libraries/python/QemuUtils.py b/resources/libraries/python/QemuUtils.py index a4e14d2427..acc00de455 100644 --- a/resources/libraries/python/QemuUtils.py +++ b/resources/libraries/python/QemuUtils.py @@ -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)) diff --git a/resources/libraries/robot/performance.robot b/resources/libraries/robot/performance.robot index caee7be6e1..20f2f0b0b2 100644 --- a/resources/libraries/robot/performance.robot +++ b/resources/libraries/robot/performance.robot @@ -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] diff --git a/resources/tools/disk-image-builder/centos/CHANGELOG b/resources/tools/disk-image-builder/centos/CHANGELOG index 0f78c07754..b2cb1b90d2 100644 --- a/resources/tools/disk-image-builder/centos/CHANGELOG +++ b/resources/tools/disk-image-builder/centos/CHANGELOG @@ -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. diff --git a/resources/tools/disk-image-builder/centos/run-listmaker.sh b/resources/tools/disk-image-builder/centos/run-listmaker.sh index 9b195873a9..0155d9c031 100755 --- a/resources/tools/disk-image-builder/centos/run-listmaker.sh +++ b/resources/tools/disk-image-builder/centos/run-listmaker.sh @@ -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" diff --git a/resources/tools/disk-image-builder/nested/CHANGELOG b/resources/tools/disk-image-builder/nested/CHANGELOG index 50217e28c8..9901d1379d 100644 --- a/resources/tools/disk-image-builder/nested/CHANGELOG +++ b/resources/tools/disk-image-builder/nested/CHANGELOG @@ -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 diff --git a/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support b/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support index 5990f0925b..2de4ad6962 100755 --- a/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support +++ b/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support @@ -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 index 0000000000..5ef2782d52 --- /dev/null +++ b/resources/tools/disk-image-builder/nested/image-patches/08-virtio-disk @@ -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 diff --git a/resources/tools/disk-image-builder/ubuntu/CHANGELOG b/resources/tools/disk-image-builder/ubuntu/CHANGELOG index 6b904ddf2f..01ab988664 100644 --- a/resources/tools/disk-image-builder/ubuntu/CHANGELOG +++ b/resources/tools/disk-image-builder/ubuntu/CHANGELOG @@ -1,3 +1,7 @@ +## [1.7] - 2017-02-20 + +Added socat as vm testing dependency. + ## [1.6] - 2016-12-19 Add cmake diff --git a/resources/tools/disk-image-builder/ubuntu/run-listmaker.sh b/resources/tools/disk-image-builder/ubuntu/run-listmaker.sh index 3b0a2e0123..acc1447976 100755 --- a/resources/tools/disk-image-builder/ubuntu/run-listmaker.sh +++ b/resources/tools/disk-image-builder/ubuntu/run-listmaker.sh @@ -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" diff --git a/resources/tools/testbed-setup/playbooks/01-host-setup.yaml b/resources/tools/testbed-setup/playbooks/01-host-setup.yaml index 3486df5a85..b660abb1b7 100644 --- a/resources/tools/testbed-setup/playbooks/01-host-setup.yaml +++ b/resources/tools/testbed-setup/playbooks/01-host-setup.yaml @@ -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 -- cgit 1.2.3-korg