From nobody Wed Nov 5 01:54:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531858757001395.936581647042; Tue, 17 Jul 2018 13:19:17 -0700 (PDT) Received: from localhost ([::1]:32977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffWGL-0003pP-UJ for importer@patchew.org; Tue, 17 Jul 2018 16:07:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffWBX-0000cV-Sk for qemu-devel@nongnu.org; Tue, 17 Jul 2018 16:03:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffWBS-0001gK-WD for qemu-devel@nongnu.org; Tue, 17 Jul 2018 16:02:59 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:39782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffWBS-0001fn-On for qemu-devel@nongnu.org; Tue, 17 Jul 2018 16:02:54 -0400 Received: by mail-wr1-x42e.google.com with SMTP id h10-v6so2397349wre.6 for ; Tue, 17 Jul 2018 13:02:54 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x7-v6sm2589072wrr.95.2018.07.17.13.02.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jul 2018 13:02:52 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 31C923E032A; Tue, 17 Jul 2018 20:55:55 +0100 (BST) 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=Uo3rRHX/CxkGdJt3ZfpfWFyhxy9sw2jyW1uYilOJI94=; b=COn7I6p82KG4HrkCfj7hKTvJpO5ST8gzPrjnzOdnBEcmUfPVNpsd3nWAMNsLL/HnLO y+Dk/VE3+RyvgNoVjPdAjXKSGjaxQ5R7P5rl/juGZKVcyHGV2WTYDdTnBcTKEW36uQYE SdaunzfJqMzDYFP77pYS2ckUorlitYw52PDlM= 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=Uo3rRHX/CxkGdJt3ZfpfWFyhxy9sw2jyW1uYilOJI94=; b=ATH121Xzv1QRS06ARLgN4hYVll/pDrE4txcOjGziP4aatelpdUjpzfVPOnKT7dvd8B MZ3plIvVvorROHcnt7LSy/P3HhaoT2BcM/cozb0p5vTfZsf/Vo7Mxp6CHPjlUy4ciwaL zVhJqPG9FDF0LL16gMVRpM3P7AfJlll00xIP848HndRx6O1zlyegrQDocS56+GEsWK/7 eOCx2fgim6twcWYjFDrtDCRr0EREpgO2QXhoeS4TwtkCuRCTm375p2eQLpfN/QxHin5D B4MHBcf9LaxyHdMjKi47MrN4KZPang2yFMeVAmpmC/kqE1UC1IC+NywnbxqbOLiYXvpF ZZwg== X-Gm-Message-State: AOUpUlHjSzM5b9lCY0nwGvdmKsxv+IivnfyJk6haAD2dGWsQXsmov3jr WreZED7GmRbBacPMhpoaQwMb2A== X-Google-Smtp-Source: AAOMgpe8eYrTdzRWSFi2oCcVuj36SBoOljb+RDRj1lWV8DDj7Qjrh/88sTAZaD5+xugZxl2xOI/XlQ== X-Received: by 2002:a5d:514d:: with SMTP id u13-v6mr2349346wrt.162.1531857773583; Tue, 17 Jul 2018 13:02:53 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: cota@braap.org, famz@redhat.com, berrange@redhat.com, f4bug@amsat.org, richard.henderson@linaro.org, balrogg@gmail.com, aurelien@aurel32.net, agraf@suse.de Date: Tue, 17 Jul 2018 20:55:52 +0100 Message-Id: <20180717195553.9111-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180717195553.9111-1-alex.bennee@linaro.org> References: <20180717195553.9111-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::42e Subject: [Qemu-devel] [PATCH v3 for 3.0 17/18] docker: perform basic binfmt_misc validation in docker.py X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Setting up binfmt_misc is outside of the scope of the docker.py script but we can at least validate it with any given executable so we have a more useful error message than the sed line of deboostrap failing cryptically. Signed-off-by: Alex Benn=C3=A9e Reported-by: Richard Henderson --- tests/docker/docker.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 523f4b95a2..a3f5b0c1b0 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -112,6 +112,31 @@ def _copy_binary_with_libs(src, dest_dir): so_path =3D os.path.dirname(l) _copy_with_mkdir(l , dest_dir, so_path) =20 + +def _check_binfmt_misc(executable): + """Check binfmt_misc has entry for executable in the right place. + + The details of setting up binfmt_misc are outside the scope of + this script but we should at least fail early with a useful + message if it won't work.""" + + binary =3D os.path.basename(executable) + binfmt_entry =3D "/proc/sys/fs/binfmt_misc/%s" % (binary) + + if not os.path.exists(binfmt_entry): + print ("No binfmt_misc entry for %s" % (binary)) + return False + + with open(binfmt_entry) as x: entry =3D x.read() + + qpath =3D "/usr/bin/%s" % (binary) + if not re.search("interpreter %s\n" % (qpath), entry): + print ("binfmt_misc for %s does not point to %s" % (binary, qpath)) + return False + + return True + + def _read_qemu_dockerfile(img_name): # special case for Debian linux-user images if img_name.startswith("debian") and img_name.endswith("user"): @@ -315,6 +340,11 @@ class BuildCommand(SubCommand): # Create a docker context directory for the build docker_dir =3D tempfile.mkdtemp(prefix=3D"docker_build") =20 + # Validate binfmt_misc will work + if args.include_executable: + if not _check_binfmt_misc(args.include_executable): + return 1 + # Is there a .pre file to run in the build context? docker_pre =3D os.path.splitext(args.dockerfile)[0]+".pre" if os.path.exists(docker_pre): --=20 2.17.1