aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash/shell
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2018-03-22 13:21:05 +0100
committerTibor Frank <tifrank@cisco.com>2018-03-26 10:37:33 +0000
commit095b162010491a4759e05ca46f0e5a47e8ace141 (patch)
treef47fcd74d591a9532815147e211e37c1d19fdb23 /resources/libraries/bash/shell
parent3458e725729098a6c10f68ec4a05d7256984bcdc (diff)
Optimize Qemu installation to speed up vhost tests
Currently Qemu is being installed if there is a change of qsz parameter between tests/suites. Qemu is installed always into the same directory. This patch changes the default behavior to install qemu over and install pathced version to separate directory. It also disables force install. Change-Id: I0d7493a02b026a6ae4a5ea8bacf54656de9db567 Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/bash/shell')
-rw-r--r--resources/libraries/bash/shell/qemu_utils.sh38
1 files changed, 19 insertions, 19 deletions
diff --git a/resources/libraries/bash/shell/qemu_utils.sh b/resources/libraries/bash/shell/qemu_utils.sh
index 510d9f2838..cabf93d978 100644
--- a/resources/libraries/bash/shell/qemu_utils.sh
+++ b/resources/libraries/bash/shell/qemu_utils.sh
@@ -15,47 +15,47 @@
function qemu_utils.qemu_delete {
# Deletes the QEMU directory
# QEMU install directory
- qemu_install_dir=$1
- # QEMU install version
- qemu_install_ver=$2
+ local qemu_install_dir=$1
- [ -d ${qemu_install_dir}/${qemu_install_ver} ] && \
- sudo rm -r ${qemu_install_dir}/${qemu_install_ver} && \
- echo "${qemu_install_dir}/${qemu_install_ver} removed"
+ [ -d ${qemu_install_dir} ] && \
+ sudo rm -r ${qemu_install_dir} && \
+ echo "${qemu_install_dir} removed"
}
function qemu_utils.qemu_install {
# Downloads and installs QEMU
# QEMU install directory
- qemu_install_dir=$1
+ local qemu_install_dir=$1
# QEMU install version
- qemu_install_ver=$2
+ local qemu_install_ver=$2
# QEMU patch
- qemu_patch=$3
+ local qemu_patch=${3:-false}
# Force install (if true then remove previous installation; default false)
- force_install=${4:-false}
+ local force_install=${4:-false}
# QEMU repo URL
- qemu_package_url="http://download.qemu-project.org/${qemu_install_ver}.tar.xz"
+ local qemu_package_url="http://download.qemu-project.org/${qemu_install_ver}.tar.xz"
+ # QEMU target arch
+ local qemu_target_list=${5:-x86_64-softmmu}
- if [ $force_install ]; then
+ if [ $force_install = true ]; then
# Cleanup QEMU dir
- qemu_utils.qemu_delete $qemu_install_dir $qemu_install_ver
+ qemu_utils.qemu_delete $qemu_install_dir
else
# Test if QEMU was installed previously
test -d $qemu_install_dir && \
{ echo "Qemu already installed: $qemu_install_dir"; exit 0; }
fi
- tmp_dir=$(mktemp -d) || \
+ local tmp_dir=$(mktemp -d) || \
{ echo "Failed to create temporary working dir"; exit 1; }
- trap "rm -r ${tmp_dir}" EXIT
+ trap "sudo rm -r ${tmp_dir}" EXIT
# Download QEMU source code if no local copy exists
if [ ! -f /opt/${qemu_install_ver}.tar.xz ]; then
sudo wget -e use_proxy=yes -P /opt -q ${qemu_package_url} || \
{ echo "Failed to download ${qemu_install_ver}"; exit 1; }
fi
- tar --strip-components 1 -xvJf ${tmp_dir}/${qemu_install_ver}.tar.xz -C ${tmp_dir} && \
+ tar --strip-components 1 -xf /opt/${qemu_install_ver}.tar.xz -C ${tmp_dir} || \
{ echo "Failed to exctract ${qemu_install_ver}.tar.xz"; exit 1; }
cd ${tmp_dir}
@@ -63,14 +63,14 @@ function qemu_utils.qemu_install {
{ echo "Failed to create ${qemu_install_dir}"; exit 1; }
# Apply additional patches
- if [ $qemu_patch ]
+ if [ $qemu_patch = true ]
then
chmod +x ${SCRIPT_DIR}/qemu_patches/${qemu_install_ver}/*
run-parts --verbose --report ${SCRIPT_DIR}/qemu_patches/${qemu_install_ver}
fi
# Build
- sudo ./configure --target-list=x86_64-softmmu --prefix=${qemu_install_dir}/${qemu_install_ver} || \
+ sudo ./configure --target-list=${qemu_target_list} --prefix=${qemu_install_dir} || \
{ echo "Failed to configure ${qemu_install_ver}"; exit 1; }
sudo make -j`nproc` || \
{ echo "Failed to compile ${qemu_install_ver}"; exit 1; }
@@ -78,4 +78,4 @@ function qemu_utils.qemu_install {
{ echo "Failed to install ${qemu_install_ver}"; exit 1; }
echo "QEMU ${qemu_install_ver} ready"
-} \ No newline at end of file
+}