From patchwork Thu Dec 19 10:49:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 182073 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp2095458och; Thu, 19 Dec 2019 02:50:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzbXkEVhLdukkb9wiMBRTPqAa532v2bdfeAcXd5Zq6I1XkWNVZIGfy6ZHzVifkc6kf2vcDf X-Received: by 2002:a9d:6a8f:: with SMTP id l15mr7950346otq.59.1576752606693; Thu, 19 Dec 2019 02:50:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576752606; cv=none; d=google.com; s=arc-20160816; b=tsErgxqfo22EF9OF1yU6nNNYsaY37PI840IZr7wku1LKHl6rLpZSV2vr7vYJK59Txr t72P7VS2r6MjWAu0NqZUY9p/xoSqzbpd6DUhReOS4lfCGvqAm2UCJz/g8yGxhTsgO+Zp 66v6EqY5XZbBs7kby278cyZEO7dq4hVvC8yTNVqDZ/6NM0DAzemA+Gc96inSgk9rAk3e JoKNpZK6A0Aioh5pSHgxRwkBpTN8PPwV79WJbxPZO3kitECJhvVW9lFIYaU8YUCXQpRv mLVQOPYRyv+k57foZNSYP/lcWOqZ4RpgdpKnmhd0vZsJbzu2sDjr6cjWNbKA9cPpvmJv Hnjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=710LliMJ7HC+nQ3MEl8A/s79QTfM7VktgrS1QINsiB4=; b=o8WeusF0IYKRNLUS1BxDFODWvBcGS/GaijZLi61b36cBKVHP1vNMzB1NJMucBC9uuM Wm54uL/4TjUTDhQN/UUVf62AbxPabb2N97bgBhiqBHkQ7eHtIA3K0+xgz+DrnPnvRJCZ YQKlmixG34BxJX6EumPewSFY+OjpI+JZ3yRMd6msXZy0jOzqgQKmiE1eIERak9BQBJc/ KcnBgumaSe9b0xaLnpHNVDVBQDHALW5S2+fP85iMY0TBHl0hT3LlU72qAj/ET6dOdvTN 50SuE5Fr/juSMbaEwOLaxhltXbNstQQSJRkYA71gHoNHbC3cEN+5hDabEiCBMUTCQOen o/gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wPSsy7ga; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w16si3007427oih.154.2019.12.19.02.50.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2019 02:50:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wPSsy7ga; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtNd-0006e7-Fe for patch@linaro.org; Thu, 19 Dec 2019 05:50:05 -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) 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-Received: by 2002:adf:eb46:: with SMTP id u6mr8877397wrn.239.1576752580326; Thu, 19 Dec 2019 02:49:40 -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) From: =?utf-8?q?Alex_Benn=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 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_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Philippe Mathieu-Daudé -- 2.20.1 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 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 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 + 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")