From patchwork Tue Jul 17 19:55:52 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: 142213 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4078558ljj; Tue, 17 Jul 2018 13:06:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdgy2DlGXYYR/B7cONyfz2K6Tp3FnDZNs2RpbzXyLhqkBKf9ktEp1heieJipujTEVA+d1hd X-Received: by 2002:a37:641:: with SMTP id 62-v6mr2904269qkg.227.1531858001535; Tue, 17 Jul 2018 13:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531858001; cv=none; d=google.com; s=arc-20160816; b=cEIUhaSDUYpQTITuX/8bIV+SyhsH3deP49k+CT+Cp0XRKMcDKblvjPqp38h71MUWpF j5awCRUkBEME57ooT/jgY6AcbDxFHkOizo6s9FGR5VBV6KnaNf5YEiYdqjj45zuUSe7X DZFRd5x3CdjrFvfYcWsjf98SOCmngVgkmxQ6Iqhkzx6yaIhKn89XSwKkYMFugJqBelaT 9ZcgZWavCEawKSEzLhf2ACEuOt/Ie42BkVq+VehhR9iwumBKh+VZNVIUpyoSsuWK28da H9icYVWpxvRmTUd6sawNK6P1x9igEpi8TGIEP4ijHpdo9VR3xHfDEd3OEhiJi5cQIF1W a5Mw== 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=Uo3rRHX/CxkGdJt3ZfpfWFyhxy9sw2jyW1uYilOJI94=; b=T9vyRfoNOj2yAta4xo/L9d8DiFsBuEsmzplN0C461/otzfBe7lgjSWsgfaTIk+nJA3 ihB2utz59IBy67ePVBhnhjILF9eJtdZvHRuClv1PnEqLiA5AqY5yS0+ZbY4ewjeT+jaC drwMOh3CvCIp5T055VwjQBzZmrORDzPHmwllXn71X68k3TB0pu19AWBUZIUHKTf+j1Zn xIzxBF7xSRhfpVCLy4sxGBoRyFukzx248wL2doB/COApONDSSkYN6/a6zEDmFFLkLfAk t933VRc4Z01HkQRqxqapMrv8pc5npxCoFbEL7AykNspJmxfnfra2LCNWKiOwlN2bxMy9 E5ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=COn7I6p8; 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 o2-v6si1588580qkf.348.2018.07.17.13.06.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Jul 2018 13:06:41 -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=COn7I6p8; 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]:32975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffWF6-0003Fb-PP for patch@linaro.org; Tue, 17 Jul 2018 16:06:40 -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) 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-Received: by 2002:a5d:514d:: with SMTP id u13-v6mr2349346wrt.162.1531857773583; Tue, 17 Jul 2018 13:02:53 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , qemu-devel@nongnu.org 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 --- tests/docker/docker.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.17.1 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 = 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):