From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: fam@euphon.net, berrange@redhat.com, stefanb@linux.vnet.ibm.com,
"Alex Bennée" <alex.bennee@linaro.org>,
richard.henderson@linaro.org, f4bug@amsat.org,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
cota@braap.org, stefanha@redhat.com, marcandre.lureau@redhat.com,
pbonzini@redhat.com, aurelien@aurel32.net
Subject: [PATCH v1 02/16] tests/vm: Allow to set qemu-img path
Date: Mon, 16 Dec 2019 11:07:18 +0000 [thread overview]
Message-ID: <20191216110732.24027-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20191216110732.24027-1-alex.bennee@linaro.org>
From: Wainer dos Santos Moschetta <wainersm@redhat.com>
By default VM build test use qemu-img from system's PATH to
create the image disk. Due the lack of qemu-img on the system
or the desire to simply use a version built with QEMU, it would
be nice to allow one to set its path. So this patch makes that
possible by reading the path to qemu-img from QEMU_IMG if set,
otherwise it fallback to default behavior.
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <20191114134246.12073-2-wainersm@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
docs/devel/testing.rst | 6 ++++--
tests/vm/Makefile.include | 1 +
tests/vm/basevm.py | 5 +++++
tests/vm/centos | 2 +-
tests/vm/fedora | 4 +---
tests/vm/freebsd | 3 +--
tests/vm/netbsd | 3 +--
tests/vm/openbsd | 3 +--
tests/vm/ubuntu.i386 | 2 +-
9 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index 8e981e062d5..9be6cd44109 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -418,13 +418,15 @@ access, so they SHOULD NOT be exposed to external interfaces if you are
concerned about attackers taking control of the guest and potentially
exploiting a QEMU security bug to compromise the host.
-QEMU binary
------------
+QEMU binaries
+-------------
By default, qemu-system-x86_64 is searched in $PATH to run the guest. If there
isn't one, or if it is older than 2.10, the test won't work. In this case,
provide the QEMU binary in env var: ``QEMU=/path/to/qemu-2.10+``.
+Likewise the path to qemu-img can be set in QEMU_IMG environment variable.
+
Make jobs
---------
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index fea348e845c..9e7c46a4735 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -34,6 +34,7 @@ vm-help vm-test:
@echo " DEBUG=1 - Enable verbose output on host and interactive debugging"
@echo " V=1 - Enable verbose ouput on host and guest commands"
@echo " QEMU=/path/to/qemu - Change path to QEMU binary"
+ @echo " QEMU_IMG=/path/to/qemu-img - Change path to qemu-img tool"
vm-build-all: $(addprefix vm-build-, $(IMAGES))
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 0b8c1b26576..930ad821eed 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -152,6 +152,11 @@ class BaseVM(object):
def build_image(self, img):
raise NotImplementedError
+ def exec_qemu_img(self, *args):
+ cmd = [os.environ.get("QEMU_IMG", "qemu-img")]
+ cmd.extend(list(args))
+ subprocess.check_call(cmd)
+
def add_source_dir(self, src_dir):
name = "data-" + hashlib.sha1(src_dir.encode("utf-8")).hexdigest()[:5]
tarfile = os.path.join(self._tmpdir, name + ".tar")
diff --git a/tests/vm/centos b/tests/vm/centos
index b9e851f2d33..f2f0befd845 100755
--- a/tests/vm/centos
+++ b/tests/vm/centos
@@ -68,7 +68,7 @@ class CentosVM(basevm.BaseVM):
sys.stderr.write("Extracting the image...\n")
subprocess.check_call(["ln", "-f", cimg, img_tmp + ".xz"])
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp + ".xz"])
- subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"])
+ self.exec_qemu_img("resize", img_tmp, "50G")
self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
self.wait_ssh()
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
diff --git a/tests/vm/fedora b/tests/vm/fedora
index 7fec1479fb7..8e270fc0f03 100755
--- a/tests/vm/fedora
+++ b/tests/vm/fedora
@@ -74,9 +74,7 @@ class FedoraVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["cp", "-f", cimg, iso])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
-
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
"-bios", "pc-bios/bios-256k.bin",
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index 2a19461a909..1825cc58218 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -82,8 +82,7 @@ class FreeBSDVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["cp", "-f", cimg, iso_xz])
subprocess.check_call(["xz", "-dvf", iso_xz])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index 611e6cc5b5c..ec6f3563b25 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -77,8 +77,7 @@ class NetBSDVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["ln", "-f", cimg, iso])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index b92c39f89a6..6df5162dbf4 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -73,8 +73,7 @@ class OpenBSDVM(basevm.BaseVM):
self.print_step("Preparing iso and disk image")
subprocess.check_call(["cp", "-f", cimg, iso])
- subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
- img_tmp, self.size])
+ self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386
index f611bebdc9d..3834cd7a8df 100755
--- a/tests/vm/ubuntu.i386
+++ b/tests/vm/ubuntu.i386
@@ -70,7 +70,7 @@ class UbuntuX86VM(basevm.BaseVM):
sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
img_tmp = img + ".tmp"
subprocess.check_call(["cp", "-f", cimg, img_tmp])
- subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"])
+ self.exec_qemu_img("resize", img_tmp, "50G")
self.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
self.wait_ssh()
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
--
2.20.1
next prev parent reply other threads:[~2019-12-16 11:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 11:07 [PATCH v1 00/16] testing and logging changes for master Alex Bennée
2019-12-16 11:07 ` [PATCH v1 01/16] configure: allow disable of cross compilation containers Alex Bennée
2019-12-16 18:59 ` Philippe Mathieu-Daudé
2019-12-18 18:17 ` Richard Henderson
2019-12-16 11:07 ` Alex Bennée [this message]
2019-12-16 11:07 ` [PATCH v1 03/16] travis.yml: Run tcg tests with tci Alex Bennée
2019-12-17 15:35 ` Richard Henderson
2019-12-16 11:07 ` [PATCH v1 04/16] iotests: Provide a function for checking the creation of huge files Alex Bennée
2019-12-16 11:07 ` [PATCH v1 05/16] iotests: Skip test 060 if it is not possible to create large files Alex Bennée
2019-12-16 11:07 ` [PATCH v1 06/16] iotests: Skip test 079 " Alex Bennée
2019-12-16 19:00 ` Philippe Mathieu-Daudé
2019-12-16 11:07 ` [PATCH v1 07/16] tests/hd-geo-test: Skip test when images can not be created Alex Bennée
2019-12-16 11:07 ` [PATCH v1 08/16] tests/test-util-filemonitor: Skip test on non-x86 Travis containers Alex Bennée
2019-12-16 11:07 ` [PATCH v1 09/16] travis.yml: Enable builds on arm64, ppc64le and s390x Alex Bennée
2019-12-16 11:07 ` [PATCH v1 10/16] ci: build out-of-tree Alex Bennée
2019-12-16 11:21 ` Li-Wen Hsu
2019-12-16 11:07 ` [PATCH v1 11/16] Fix double free issue in qemu_set_log_filename() Alex Bennée
2019-12-16 11:07 ` [PATCH v1 12/16] Cleaned up flow of code in qemu_set_log(), to simplify and clarify Alex Bennée
2019-12-16 11:07 ` [PATCH v1 13/16] Add a mutex to guarantee single writer to qemu_logfile handle Alex Bennée
2019-12-16 11:07 ` [PATCH v1 14/16] qemu_log_lock/unlock now preserves the " Alex Bennée
2019-12-16 11:07 ` [PATCH v1 15/16] Add use of RCU for qemu_logfile Alex Bennée
2019-12-16 11:07 ` [PATCH v1 16/16] Added tests for close and change of logfile Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191216110732.24027-3-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=cota@braap.org \
--cc=f4bug@amsat.org \
--cc=fam@euphon.net \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanb@linux.vnet.ibm.com \
--cc=stefanha@redhat.com \
--cc=wainersm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).