From nobody Mon Feb 9 20:12:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576752682; cv=none; d=zohomail.com; s=zohoarc; b=Y2Z6uuRo8KZSS0rSsbm5vMJqXJyS5kwcMoi4YFTsx6ItoWd5Ti4xtwhVmg46nMupZwHzsqZZrw9pqUed4RY069BXcTEAxOsHYeiXIDSVfGXDCYguEe/aDij/kF+Q6JrNK3tmsFeBwPxqjAvPZ5dogN70r60SbnCjV9wHwgrr9lU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576752682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=710LliMJ7HC+nQ3MEl8A/s79QTfM7VktgrS1QINsiB4=; b=R66Pej9OKFm+hOwJNQl7yWCoALnfr0ydx7w+VYneEhtkp2MJ34orwaAseXAS2PHd87L15QiHaKnK6XXTp46ZUAkEt4a37t73g5T48pVIH9JzV/1YUrp7snecfecQ7pguAbfoSctNId69vbxTGkK9umISuOVem6SoSzl68NoF7bM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1576752682883825.9084429203209; Thu, 19 Dec 2019 02:51:22 -0800 (PST) Received: from localhost ([::1]:38720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtOq-0000B8-CV for importer@patchew.org; Thu, 19 Dec 2019 05:51:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38459) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtNH-0006Y4-DD for qemu-devel@nongnu.org; Thu, 19 Dec 2019 05:49:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtNF-0008CI-Pu for qemu-devel@nongnu.org; Thu, 19 Dec 2019 05:49:43 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:35739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ihtNF-00086j-Eb for qemu-devel@nongnu.org; Thu, 19 Dec 2019 05:49:41 -0500 Received: by mail-wr1-x431.google.com with SMTP id g17so5492959wro.2 for ; Thu, 19 Dec 2019 02:49:41 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p5sm5891469wrt.79.2019.12.19.02.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 02:49:35 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A18C71FF8F; Thu, 19 Dec 2019 10:49:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=710LliMJ7HC+nQ3MEl8A/s79QTfM7VktgrS1QINsiB4=; b=wPSsy7gaeRL+3R5VQKzqXRB/nlmvwPzSAKe1N0PSeGa1Bc7XE2TflSt2kAPrz4RkOC fFZpcPYWKXV4GdWCFNFdJLshzO5aqN2KP/CdXqZbTjfad8ausTxKf+VFCQkcqvB43hj5 i+z5Nbq5ScOcPMBs+VT5XqZBd6kpodWp3C/h+Ducib46VXqKUHr8FZbuxzV+dGpYP5iK fW2dgcmwDBDT+eD4grxBnUzJSI1ESIt4dkEtvSx9IiH9TjJCdPjkXk+cuQdxfZY5lPK1 eDmXOWobTcOCxOq/+gr1onRGtgVBQPk0UzVU/i0o7KJSlLs8cYDGlx+qnzQC/K2alOkq v0Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=710LliMJ7HC+nQ3MEl8A/s79QTfM7VktgrS1QINsiB4=; b=rSyW5GOxHyNfTPOy7JgyP6GUvtFpIn54fEBIQVNJ/xSyMxWwH7op07MJeHFvWVfptD IuZk4Sk7QzdGqRMr7vM424o7FxATjoCdTM2cCMnDZZhppOjOBNhMuZ03/lE8Nmp30SuB zAiQv/V+GbfHmwKQDCErMkcmSsscLSCu7m0XIdtIqYnSkOHO0GtLkoTDuzX6UwdKHRGU yUHDkQNoxdX65TgHsnS3nz/+MyrP6AE52VPQAL/UAyppxh9vjWYonIPdWixrue4KgeK2 08ZfKXMmwlQC+8C0Q1KMMcl66bsG9RL9Ee0IppqXBXTQxB3xTNb6fUm2KUxSyZ3VjO8i SwzQ== X-Gm-Message-State: APjAAAVgAzjVI2U5OSY2ZWUuyozRSXqu2PeB6RnCFiPiK4AKw8eCwnVU dWxcWW0wdedSnY5KxkI9qeKmHg== X-Google-Smtp-Source: APXvYqzjVrKLSFH8SUA+nzq5x19Hezam5UFa0hnIyBFsYJtuuGXsKX56eri6Ya7sns+DBDKOwgH93Q== X-Received: by 2002:adf:eb46:: with SMTP id u6mr8877397wrn.239.1576752580326; Thu, 19 Dec 2019 02:49:40 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 02/25] tests/vm: Allow to set qemu-img path Date: Thu, 19 Dec 2019 10:49:11 +0000 Message-Id: <20191219104934.866-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191219104934.866-1-alex.bennee@linaro.org> References: <20191219104934.866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 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 Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Wainer dos Santos Moschetta 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 Message-Id: <20191114134246.12073-2-wainersm@redhat.com> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 27f286858ad..ab5be0c7299 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 fea348e845c..9e7c46a4735 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 53b9515ee22..ed5dd4f3d0e 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 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 =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 7fec1479fb7..8e270fc0f03 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 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) =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ 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): =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 b92c39f89a6..6df5162dbf4 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 f611bebdc9d..3834cd7a8df 100755 --- a/tests/vm/ubuntu.i386 +++ b/tests/vm/ubuntu.i386 @@ -70,7 +70,7 @@ class UbuntuX86VM(basevm.BaseVM): sha256sum=3D"28969840626d1ea80bb249c08eef1a4533e8904aa51a327b4= 0f37ac4b4ff04ef") 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.20.1