mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-09 00:07:57 -06:00
tests/vm: Allow to set qemu-img path
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>
This commit is contained in:
parent
afc3a8f9f1
commit
1e48931c0c
9 changed files with 16 additions and 13 deletions
|
@ -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
|
concerned about attackers taking control of the guest and potentially
|
||||||
exploiting a QEMU security bug to compromise the host.
|
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
|
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,
|
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+``.
|
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
|
Make jobs
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ vm-help vm-test:
|
||||||
@echo " DEBUG=1 - Enable verbose output on host and interactive debugging"
|
@echo " DEBUG=1 - Enable verbose output on host and interactive debugging"
|
||||||
@echo " V=1 - Enable verbose ouput on host and guest commands"
|
@echo " V=1 - Enable verbose ouput on host and guest commands"
|
||||||
@echo " QEMU=/path/to/qemu - Change path to QEMU binary"
|
@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))
|
vm-build-all: $(addprefix vm-build-, $(IMAGES))
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,11 @@ class BaseVM(object):
|
||||||
def build_image(self, img):
|
def build_image(self, img):
|
||||||
raise NotImplementedError
|
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):
|
def add_source_dir(self, src_dir):
|
||||||
name = "data-" + hashlib.sha1(src_dir.encode("utf-8")).hexdigest()[:5]
|
name = "data-" + hashlib.sha1(src_dir.encode("utf-8")).hexdigest()[:5]
|
||||||
tarfile = os.path.join(self._tmpdir, name + ".tar")
|
tarfile = os.path.join(self._tmpdir, name + ".tar")
|
||||||
|
|
|
@ -68,7 +68,7 @@ class CentosVM(basevm.BaseVM):
|
||||||
sys.stderr.write("Extracting the image...\n")
|
sys.stderr.write("Extracting the image...\n")
|
||||||
subprocess.check_call(["ln", "-f", cimg, img_tmp + ".xz"])
|
subprocess.check_call(["ln", "-f", cimg, img_tmp + ".xz"])
|
||||||
subprocess.check_call(["xz", "--keep", "-dvf", 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.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
|
||||||
self.wait_ssh()
|
self.wait_ssh()
|
||||||
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
|
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
|
||||||
|
|
|
@ -74,9 +74,7 @@ class FedoraVM(basevm.BaseVM):
|
||||||
|
|
||||||
self.print_step("Preparing iso and disk image")
|
self.print_step("Preparing iso and disk image")
|
||||||
subprocess.check_call(["cp", "-f", cimg, iso])
|
subprocess.check_call(["cp", "-f", cimg, iso])
|
||||||
subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
|
self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
|
||||||
img_tmp, self.size])
|
|
||||||
|
|
||||||
self.print_step("Booting installer")
|
self.print_step("Booting installer")
|
||||||
self.boot(img_tmp, extra_args = [
|
self.boot(img_tmp, extra_args = [
|
||||||
"-bios", "pc-bios/bios-256k.bin",
|
"-bios", "pc-bios/bios-256k.bin",
|
||||||
|
|
|
@ -82,8 +82,7 @@ class FreeBSDVM(basevm.BaseVM):
|
||||||
self.print_step("Preparing iso and disk image")
|
self.print_step("Preparing iso and disk image")
|
||||||
subprocess.check_call(["cp", "-f", cimg, iso_xz])
|
subprocess.check_call(["cp", "-f", cimg, iso_xz])
|
||||||
subprocess.check_call(["xz", "-dvf", iso_xz])
|
subprocess.check_call(["xz", "-dvf", iso_xz])
|
||||||
subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
|
self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
|
||||||
img_tmp, self.size])
|
|
||||||
|
|
||||||
self.print_step("Booting installer")
|
self.print_step("Booting installer")
|
||||||
self.boot(img_tmp, extra_args = [
|
self.boot(img_tmp, extra_args = [
|
||||||
|
|
|
@ -77,8 +77,7 @@ class NetBSDVM(basevm.BaseVM):
|
||||||
|
|
||||||
self.print_step("Preparing iso and disk image")
|
self.print_step("Preparing iso and disk image")
|
||||||
subprocess.check_call(["ln", "-f", cimg, iso])
|
subprocess.check_call(["ln", "-f", cimg, iso])
|
||||||
subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
|
self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
|
||||||
img_tmp, self.size])
|
|
||||||
|
|
||||||
self.print_step("Booting installer")
|
self.print_step("Booting installer")
|
||||||
self.boot(img_tmp, extra_args = [
|
self.boot(img_tmp, extra_args = [
|
||||||
|
|
|
@ -73,8 +73,7 @@ class OpenBSDVM(basevm.BaseVM):
|
||||||
|
|
||||||
self.print_step("Preparing iso and disk image")
|
self.print_step("Preparing iso and disk image")
|
||||||
subprocess.check_call(["cp", "-f", cimg, iso])
|
subprocess.check_call(["cp", "-f", cimg, iso])
|
||||||
subprocess.check_call(["qemu-img", "create", "-f", "qcow2",
|
self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
|
||||||
img_tmp, self.size])
|
|
||||||
|
|
||||||
self.print_step("Booting installer")
|
self.print_step("Booting installer")
|
||||||
self.boot(img_tmp, extra_args = [
|
self.boot(img_tmp, extra_args = [
|
||||||
|
|
|
@ -70,7 +70,7 @@ class UbuntuX86VM(basevm.BaseVM):
|
||||||
sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
|
sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
|
||||||
img_tmp = img + ".tmp"
|
img_tmp = img + ".tmp"
|
||||||
subprocess.check_call(["cp", "-f", cimg, 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.boot(img_tmp, extra_args = ["-cdrom", self._gen_cloud_init_iso()])
|
||||||
self.wait_ssh()
|
self.wait_ssh()
|
||||||
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
|
self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue