From nobody Thu May 2 22:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1573739286; cv=none; d=zoho.com; s=zohoarc; b=FuzUusE/vDgDqE+UeQQ9ICx5DPV1LH5blLzw1MU4D0x+IELVS9cRl9nXqX5w2HAkY20/y4+r1vUOqD+B0FNp5pcArwfaz7/KknAahD7oD/4+aFrzU31S7F3JGLfqHr9ctc5YxnK3wvD00qcQdelPrWhuuue/6q7YfoQ1KJ3+FlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573739286; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=BQnqCIJ+e9ZzmO5qQmS/9NiQJKqB0JsSt74DPmUryTU=; b=B8Mm4Q10MVGQcgbMikqy40xKDKpxZMYEZLoYHiDeaOco45wpoe9iTDssw/T+Rn6sh/j5lIhpqWGECwQ/tvT3G6cwWzwLWrTD8E6N5Vus3sHrzfoXtEvegx3RE+8KQC8/6awqQ8BW4b1hmes0xCXD9SAep4yROeAvFQUq3+Xan7o= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573739286113462.4030755471565; Thu, 14 Nov 2019 05:48:06 -0800 (PST) Received: from localhost ([::1]:57742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVFTf-0000tH-21 for importer@patchew.org; Thu, 14 Nov 2019 08:48:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36228) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVFOh-0005Kl-CZ for qemu-devel@nongnu.org; Thu, 14 Nov 2019 08:42:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVFOf-0002xw-Iv for qemu-devel@nongnu.org; Thu, 14 Nov 2019 08:42:55 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37411 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVFOf-0002wp-DX for qemu-devel@nongnu.org; Thu, 14 Nov 2019 08:42:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-lo-_0UTzP7uTtvNu88h4Vw-1; Thu, 14 Nov 2019 08:42:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52C9B1005500; Thu, 14 Nov 2019 13:42:50 +0000 (UTC) Received: from virtlab501.virt.lab.eng.bos.redhat.com (virtlab501.virt.lab.eng.bos.redhat.com [10.19.152.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id C105D60BEC; Thu, 14 Nov 2019 13:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573738972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BQnqCIJ+e9ZzmO5qQmS/9NiQJKqB0JsSt74DPmUryTU=; b=V9TvVTXnQaglYploeN8bl9PuNJbQ3mUXbqLpkLjd0HZMysHZIB6k6ycmtbDwOOo1epusJA d0UiSLRZuVXOA5Ys/Uj0ufMxUbc/Y1flLqKjMtpU2A6BxLMg9otobT00GIO11vYaAaICv3 ZYdwlKIAm61m2r/jxgKLo1+d/NVBbKI= From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 1/1] tests/vm: Allow to set qemu-img path Date: Thu, 14 Nov 2019 08:42:46 -0500 Message-Id: <20191114134246.12073-2-wainersm@redhat.com> In-Reply-To: <20191114134246.12073-1-wainersm@redhat.com> References: <20191114134246.12073-1-wainersm@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: lo-_0UTzP7uTtvNu88h4Vw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, philmd@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 8e981e062d..9be6cd4410 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -418,13 +418,15 @@ access, so they SHOULD NOT be exposed to external int= erfaces if you are concerned about attackers taking control of the guest and potentially exploiting a QEMU security bug to compromise the host. =20 -QEMU binary ------------ +QEMU binaries +------------- =20 By default, qemu-system-x86_64 is searched in $PATH to run the guest. If t= here 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=3D/path/to/qemu-2.10+``. =20 +Likewise the path to qemu-img can be set in QEMU_IMG environment variable. + Make jobs --------- =20 diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index fea348e845..9e7c46a473 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -34,6 +34,7 @@ vm-help vm-test: @echo " DEBUG=3D1 - Enable verbose output on host and i= nteractive debugging" @echo " V=3D1 - Enable verbose ouput on host and guest commands" @echo " QEMU=3D/path/to/qemu - Change path to QEMU binary" + @echo " QEMU_IMG=3D/path/to/qemu-img - Change path to qemu-img tool" =20 vm-build-all: $(addprefix vm-build-, $(IMAGES)) =20 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 91a9226026..d1efeb3646 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 =20 + def exec_qemu_img(self, *args): + cmd =3D [os.environ.get("QEMU_IMG", "qemu-img")] + cmd.extend(list(args)) + subprocess.check_call(cmd) + def add_source_dir(self, src_dir): name =3D "data-" + hashlib.sha1(src_dir.encode("utf-8")).hexdigest= ()[:5] tarfile =3D os.path.join(self._tmpdir, name + ".tar") diff --git a/tests/vm/centos b/tests/vm/centos index 53976f1c4c..eac07dacd6 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 =3D ["-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 7fec1479fb..8e270fc0f0 100755 --- a/tests/vm/fedora +++ b/tests/vm/fedora @@ -74,9 +74,7 @@ class FedoraVM(basevm.BaseVM): =20 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 =3D [ "-bios", "pc-bios/bios-256k.bin", diff --git a/tests/vm/freebsd b/tests/vm/freebsd index 2a19461a90..1825cc5821 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) =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ diff --git a/tests/vm/netbsd b/tests/vm/netbsd index 611e6cc5b5..ec6f3563b2 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -77,8 +77,7 @@ class NetBSDVM(basevm.BaseVM): =20 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) =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ diff --git a/tests/vm/openbsd b/tests/vm/openbsd index b92c39f89a..6df5162dbf 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -73,8 +73,7 @@ class OpenBSDVM(basevm.BaseVM): =20 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) =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386 index 38f740eabf..39bbe9cc21 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -70,7 +70,7 @@ class UbuntuX86VM(basevm.BaseVM): sha256sum=3D"e30091144c73483822b7c27193e9d47346dd1064229da577c= 3fedcf943f7cfcc") img_tmp =3D 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 =3D ["-cdrom", self._gen_cloud_init_= iso()]) self.wait_ssh() self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") --=20 2.18.1