From 99a97f74ca06f5407746c672f1ee48d2018ea33d Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 15:30:00 +0100 Subject: [PATCH 1/7] scripts: Add qemu version details to hypervisor script Set the qemu major and minor version variables in the hypervisor configuration script. Partially fixes #13. Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index 1556f22c7b..5b83bb95d3 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -175,6 +175,17 @@ show_array() # Entry point main() { + local qemu_version_file="VERSION" + [ -f ${qemu_version_file} ] || die "QEMU version file '$qemu_version_file' not found" + + local qemu_version_major=$(cut -d. -f1 "${qemu_version_file}") + local qemu_version_minor=$(cut -d. -f2 "${qemu_version_file}") + + [ -n "${qemu_version_major}" ] \ + || die "cannot determine qemu major version from file $qemu_version_file" + [ -n "${qemu_version_minor}" ] \ + || die "cannot determine qemu minor version from file $qemu_version_file" + arch=$(arch) # Array of configure options. From ef16fd26e0ca608f91803bf05efb61a85bec7431 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 09:44:03 +0100 Subject: [PATCH 2/7] scripts: Re-add tags for hypervisor config script PR #12 inadvertently removed the required tags for two of the qemu config options. Fixes #13. Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index 5b83bb95d3..ddab519184 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -282,7 +282,7 @@ main() # SECURITY: Don't build a static binary (lowers security) # needed if qemu version is less than 2.7 if [ ${qemu_version_major} -eq 2 ] && [ ${qemu_version_minor} -lt 7 ]; then - qemu_options+=(--disable-static) + qemu_options+=(security:--disable-static) fi # Not required as "-uuid ..." is always passed to the qemu binary @@ -325,7 +325,7 @@ main() # Always strip binaries # needed if qemu version is less than 2.7 if [ ${qemu_version_major} -eq 2 ] && [ ${qemu_version_minor} -lt 7 ]; then - qemu_options+=(--enable-strip) + qemu_options+=(size:--enable-strip) fi # Support Ceph RADOS Block Device (RBD) From a082b9ee241b56ea55a2f59baa2fc42d941154e4 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 10:05:51 +0100 Subject: [PATCH 3/7] scripts: Add extra check to hypervisor config script Check the specified tag in `check_tag()` to ensure it is not blank (which is invalid). Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index ddab519184..102c194fe2 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -92,6 +92,8 @@ check_tag() local tag="$1" local entry="$2" + [ -z "$tag" ] && die "no tag for entry '$entry'" + value="${recognised_tags[$tag]}" [ -n "$value" ] && return From 8cd0d9f0db023639ba0df537faf4db07642f7524 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 10:06:46 +0100 Subject: [PATCH 4/7] scripts: Add hypervisor config script comment Add an explanatory comment to the hypervisor configuration script. Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index 102c194fe2..379890901a 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -96,6 +96,7 @@ check_tag() value="${recognised_tags[$tag]}" + # each tag MUST have a description [ -n "$value" ] && return die "invalid tag '$tag' found for entry '$entry'" From 491780d6c20b2f719350aef092c9215a798a9619 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 10:19:33 +0100 Subject: [PATCH 5/7] scripts: extra hypervisor config script entry checks Add more checks for each entry. Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index 379890901a..fb960e4703 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -93,6 +93,7 @@ check_tag() local entry="$2" [ -z "$tag" ] && die "no tag for entry '$entry'" + [ -z "$entry" ] && die "no entry for tag '$tag'" value="${recognised_tags[$tag]}" @@ -108,6 +109,7 @@ check_tags() local entry="$2" [ -z "$tags" ] && die "entry '$entry' doesn't have any tags" + [ -z "$entry" ] && die "no entry for tags '$tags'" tags=$(echo "$tags"|tr ',' '\n') @@ -146,6 +148,8 @@ show_array() for entry in "${_array[@]}" do + [ -z "$entry" ] && die "found empty entry" + tags=$(echo "$entry"|cut -s -d: -f1) elem=$(echo "$entry"|cut -s -d: -f2-) From 90ce6d888a34c9c1553c6a63b0aaf5f648505025 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 10:19:54 +0100 Subject: [PATCH 6/7] scripts: Add extra hypervisor config script option check Add a check on the element (configure option). Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index fb960e4703..9a9e3a5c0a 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -153,6 +153,8 @@ show_array() tags=$(echo "$entry"|cut -s -d: -f1) elem=$(echo "$entry"|cut -s -d: -f2-) + [ -z "$elem" ] && die "no option for entry '$entry'" + check_tags "$tags" "$entry" if [ "$action" = "dump" ] From dcfc74471c8cce5243ecb5039e683306ddd9a815 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 3 Apr 2018 15:30:46 +0100 Subject: [PATCH 7/7] scripts: Quote variables in hypervisor script Double-quote the qemu version variables in the hypervisor configuration script. Signed-off-by: James O. D. Hunt --- scripts/configure-hypervisor.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/configure-hypervisor.sh b/scripts/configure-hypervisor.sh index 9a9e3a5c0a..a2e62cdd1f 100755 --- a/scripts/configure-hypervisor.sh +++ b/scripts/configure-hypervisor.sh @@ -290,7 +290,7 @@ main() # SECURITY: Don't build a static binary (lowers security) # needed if qemu version is less than 2.7 - if [ ${qemu_version_major} -eq 2 ] && [ ${qemu_version_minor} -lt 7 ]; then + if [ "${qemu_version_major}" -eq 2 ] && [ "${qemu_version_minor}" -lt 7 ]; then qemu_options+=(security:--disable-static) fi @@ -333,7 +333,7 @@ main() # Always strip binaries # needed if qemu version is less than 2.7 - if [ ${qemu_version_major} -eq 2 ] && [ ${qemu_version_minor} -lt 7 ]; then + if [ "${qemu_version_major}" -eq 2 ] && [ "${qemu_version_minor}" -lt 7 ]; then qemu_options+=(size:--enable-strip) fi