From patchwork Tue Jul 24 10:51:08 2018 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: 142767 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp7132341ljj; Tue, 24 Jul 2018 04:10:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf7jR/4OBlLSWpp5IzSm5PQ9R6eCRGbIQbdOEz4MoGXGhN9+IzAvjwNleKZIe1OisXnDzQ4 X-Received: by 2002:a0c:cdd1:: with SMTP id a17-v6mr14111221qvn.166.1532430602511; Tue, 24 Jul 2018 04:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532430602; cv=none; d=google.com; s=arc-20160816; b=afrMTR/bEnfPamDfJvyF1HNDhJBZbc2H8XfkS7+hH6sDFrJdYxewhBdTbjpiuyNOxd 8HtZD6boTwNQ+CFcBLIPdOVzhOV1thFJckxFEydYavTPcd/j0CEBgWPdmSsc4N/EgB8u Z/Lq9YzrwguECIxBBYX0oBZFvLlYI/gzIVvF+f9n2ljTkG804H0SkwiIEtuQfVjV0Qio ceE2WljAAejUoanF+8Eksho9OCcHv5N/nYfZyFcCuv+2ZOYB3X0bAYyRyO0AFpKjXzlB l4ShHckby/Z1e3TIP/IiIV9EQIJnSjVbiAF2WnyveQiOZWpGdsM9SKqH0jynfSl7nvol SoVg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=PnFN5FS2xP69E9wMMeQYrIzwdK/U7cqY4mU/KHwg9jw=; b=ZzdpF1XYbIWUlt1ErDwJcMNOm1VzKhuuBIHua/aWPO/uwMx3hweDbh/vUoaqYoJgGU T7L/+iwSMa1e8tmQe0mnUEEqpmSK1tJZJxDrFKKRrBAaLoaAYMmtaXOZaBm+/J7TL7wQ 8ZaU7v56ZHroQg2iR0Gl1xTyfNy0v8L444QGguI35GQXv0MG1GNRaPUa6PxMbm4ivp8+ dsv1CVgcTra77OAOi5kuPg8buSxxRSQnVSIzk074dJQPmjaT0wcBy2tpEF506y6AcnYU eeGwcg9dgCYcw6LFU6546xk5+NYsFBOFiuTjn2HGDFeYhIGlugMzdMCVJbG6kF4EDhrF DdNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FhhdhGR1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h57-v6si3711957qth.279.2018.07.24.04.10.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 24 Jul 2018 04:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FhhdhGR1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:39554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhvCc-0007Ep-1u for patch@linaro.org; Tue, 24 Jul 2018 07:10:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhv1o-0007R3-Ad for qemu-devel@nongnu.org; Tue, 24 Jul 2018 06:58:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhv1n-0000li-E6 for qemu-devel@nongnu.org; Tue, 24 Jul 2018 06:58:52 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:54857) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhv1n-0000lJ-7L for qemu-devel@nongnu.org; Tue, 24 Jul 2018 06:58:51 -0400 Received: by mail-wm0-x22c.google.com with SMTP id c14-v6so2072213wmb.4 for ; Tue, 24 Jul 2018 03:58:51 -0700 (PDT) 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=PnFN5FS2xP69E9wMMeQYrIzwdK/U7cqY4mU/KHwg9jw=; b=FhhdhGR1o+6RImJA81GJHr4ARn11nBbpM7iTWcdl8iUsz7ZIRy9nUxUnRohUajWm7S 8Krmq9ciuWUB8RtY8cCGYJoZwrvUgbN/kpu/7upGRk4m+2ii4QGVDmzoPE71zBiWkTzv 69F+t0T+Y3XCnggUTOi3aecniOqnuuWeXlFo8= 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=PnFN5FS2xP69E9wMMeQYrIzwdK/U7cqY4mU/KHwg9jw=; b=ZDyi+qKA9O6MfJr7Ue/3xQ7ZkhAk9yrrSWve9rLRe/N06heqCPcTuHHXQ5Ykorn7mk ZcLT7uXccakBJLN+FywSwVN/cvjpqmITN2nuZBvbuEy50ApTc0rOAyMhNTOxEJmgDbvM WFq3DWzFWl1N1DLKDKW+5A/aPAlIpXJ/sdI/Xwqp1EiESIkho2caW8hxeB8cqzJdguTm 3oc+ZFhN7U3URImaHyrPKkEMVNQWDLVF6TaJG3Zl/FrBhv7kE7LoA8PBxDTxugmRvlmG JhrPI0mGb5T7GXP5EYAq9P4W5OiWDcgw3Y+zZsRiK4sgohyeeaggmPHK4zB+22dk3Y6F Qutw== X-Gm-Message-State: AOUpUlG7wZLEWE12m12l6MoiFRWDZdE3gUPTFU0uxhmwyEO4KPVk+6Dv w2qOOz/j7+e6HW3jxaNn1y5ldA== X-Received: by 2002:a1c:8a04:: with SMTP id m4-v6mr1592336wmd.137.1532429930068; Tue, 24 Jul 2018 03:58:50 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h5-v6sm8718020wre.46.2018.07.24.03.58.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 03:58:46 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 21EBF3E0719; Tue, 24 Jul 2018 11:51:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 24 Jul 2018 11:51:08 +0100 Message-Id: <20180724105109.8392-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180724105109.8392-1-alex.bennee@linaro.org> References: <20180724105109.8392-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:400c:c09::22c Subject: [Qemu-devel] [PULL 16/17] 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: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reported-by: Richard Henderson -- 2.17.1 diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 2f81c6b13b..d3006d4dae 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 = os.path.dirname(l) _copy_with_mkdir(l , dest_dir, so_path) + +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 = os.path.basename(executable) + binfmt_entry = "/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 = x.read() + + qpath = "/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 = tempfile.mkdtemp(prefix="docker_build") + # 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 = os.path.splitext(args.dockerfile)[0]+".pre" if os.path.exists(docker_pre):