From patchwork Mon Mar 9 19:18:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251763 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp2B6M9fz9sPF for ; Tue, 10 Mar 2020 06:19:46 +1100 (AEDT) Received: from localhost ([::1]:48354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNwG-0005fS-Kn for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:19:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49217) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNvU-0005BS-Pe for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNvT-00073v-8l for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:18:56 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:55052 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNvS-000737-T8 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:18:55 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 55D086311; Mon, 9 Mar 2020 20:18:53 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BF855A04F; Mon, 9 Mar 2020 20:18:53 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00A895A045; Mon, 9 Mar 2020 20:18:53 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:18:52 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id B1C426311; Mon, 9 Mar 2020 20:18:52 +0100 (CET) Date: Mon, 9 Mar 2020 19:18:46 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 01/10] qemu-binfmt-conf.sh: enforce style consistency Message-ID: <20200309191846.GA65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:18:52 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No-1.035-7.0-31-10 X-imss-scan-details: No-1.035-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10-1.034500-10.000000 X-TMASE-MatchedRID: lk/a9VXHoMTeG4FwcWqAS3/HTU/OBaTGnVQTrXdqB1rGkE1bT11zTEAc 6DyoS2rIX5ZfmW1Ym4Xl7N0S/wu39cyB+MYaW/KQpyEWs4H2Rqc4eGohd7gjNn16C7GFcvkyGgr CtJAREvEaUt/08cthqw6v12u9K+m3SkJz50w3SpFmPsTq8ee41uwlOGZoQVV0DpCUEeEFm7Byw4 qzm86Di79p0+NmFAkoX/2hCeJrRE9ccQ8eam5Eff7E6GNqs6ce3QfwsVk0UbsIoUKaF27lxXGwI NCE/mk/R8y8KLeYInjdxrPoeKsrpx5pnJtYVfsaQql8Qaf6Y2XimFXTfQZc0l/Ysw/eKl1qnvLf ZdcA39zwrovrXlT8pRKGdgr8x4f4BBSv+oarUQsKtuXWKSlXVpNHmClQkxEB+rL5VW+ofZc= X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:18:53 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Spaces are removed before '; then', for consistency with other scripts in the project. Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier Reviewed-by: Eric Blake --- scripts/qemu-binfmt-conf.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 9f1580a91c..c728443ba2 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -215,7 +215,7 @@ EOF } qemu_check_access() { - if [ ! -w "$1" ] ; then + if [ ! -w "$1" ]; then echo "ERROR: cannot write to $1" 1>&2 exit 1 fi @@ -224,12 +224,12 @@ qemu_check_access() { qemu_check_bintfmt_misc() { # load the binfmt_misc module if [ ! -d /proc/sys/fs/binfmt_misc ]; then - if ! /sbin/modprobe binfmt_misc ; then + if ! /sbin/modprobe binfmt_misc; then exit 1 fi fi if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then - if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then + if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc; then exit 1 fi fi @@ -242,16 +242,16 @@ installed_dpkg() { } qemu_check_debian() { - if [ ! -e /etc/debian_version ] ; then + if [ ! -e /etc/debian_version ]; then echo "WARNING: your system is not a Debian based distro" 1>&2 - elif ! installed_dpkg binfmt-support ; then + elif ! installed_dpkg binfmt-support; then echo "WARNING: package binfmt-support is needed" 1>&2 fi qemu_check_access "$EXPORTDIR" } qemu_check_systemd() { - if ! systemctl -q is-enabled systemd-binfmt.service ; then + if ! systemctl -q is-enabled systemd-binfmt.service; then echo "WARNING: systemd-binfmt.service is missing or disabled" 1>&2 fi qemu_check_access "$EXPORTDIR" @@ -259,10 +259,10 @@ qemu_check_systemd() { qemu_generate_register() { flags="" - if [ "$CREDENTIAL" = "yes" ] ; then + if [ "$CREDENTIAL" = "yes" ]; then flags="OC" fi - if [ "$PERSISTENT" = "yes" ] ; then + if [ "$PERSISTENT" = "yes" ]; then flags="${flags}F" fi @@ -295,23 +295,23 @@ qemu_set_binfmts() { # register the interpreter for each cpu except for the native one - for cpu in ${qemu_target_list} ; do + for cpu in ${qemu_target_list}; do magic=$(eval echo \$${cpu}_magic) mask=$(eval echo \$${cpu}_mask) family=$(eval echo \$${cpu}_family) - if [ "$magic" = "" ] || [ "$mask" = "" ] || [ "$family" = "" ] ; then + if [ "$magic" = "" ] || [ "$mask" = "" ] || [ "$family" = "" ]; then echo "INTERNAL ERROR: unknown cpu $cpu" 1>&2 continue fi qemu="$QEMU_PATH/qemu-$cpu" - if [ "$cpu" = "i486" ] ; then + if [ "$cpu" = "i486" ]; then qemu="$QEMU_PATH/qemu-i386" fi qemu="$qemu$QEMU_SUFFIX" - if [ "$host_family" != "$family" ] ; then + if [ "$host_family" != "$family" ]; then $BINFMT_SET fi done @@ -331,7 +331,7 @@ QEMU_SUFFIX="" options=$(getopt -o ds:Q:S:e:hc:p: -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent: -- "$@") eval set -- "$options" -while true ; do +while true; do case "$1" in -d|--debian) CHECK=qemu_check_debian @@ -344,14 +344,14 @@ while true ; do EXPORTDIR=${EXPORTDIR:-$SYSTEMDDIR} shift # check given cpu is in the supported CPU list - if [ "$1" != "ALL" ] ; then - for cpu in ${qemu_target_list} ; do - if [ "$cpu" = "$1" ] ; then + if [ "$1" != "ALL" ]; then + for cpu in ${qemu_target_list}; do + if [ "$cpu" = "$1" ]; then break fi done - if [ "$cpu" = "$1" ] ; then + if [ "$cpu" = "$1" ]; then qemu_target_list="$1" else echo "ERROR: unknown CPU \"$1\"" 1>&2 From patchwork Mon Mar 9 19:19:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251764 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp2L3RXPz9sRN for ; Tue, 10 Mar 2020 06:19:54 +1100 (AEDT) Received: from localhost ([::1]:48358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNwO-0005ld-E1 for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:19:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49392) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNw0-0005j2-Hl for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:19:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNvz-0007P2-5f for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:19:28 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:51905 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNvy-0007O2-TV for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:19:27 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id CDCF35F6F; Mon, 9 Mar 2020 20:19:25 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A734A5A04F; Mon, 9 Mar 2020 20:19:25 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9BA365A045; Mon, 9 Mar 2020 20:19:25 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:19:25 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id 588325F6F; Mon, 9 Mar 2020 20:19:25 +0100 (CET) Date: Mon, 9 Mar 2020 19:19:24 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 02/10] qemu-binfmt-conf.sh: enforce safe tests Message-ID: <20200309191924.GB65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:19:25 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No-0.253-7.0-31-10 X-imss-scan-details: No-0.253-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10-0.252900-10.000000 X-TMASE-MatchedRID: SUQ+NPRnbh2U2+gk9zFq8Wj+pATS/uaDab+ZPXqZNQIRGC0rW8q1XUhq QpzXZe40YNA0HZI8EiGPQi9XuOWoOA719kpOO37PlchF+IvkllOZ2scyRQcer0p12IXZajx5l5E fwglrgibcDDiLNFW0338mA3sDDq0A5MIx11wv+COujVRFkkVsm0r0NWqXwFtCiB5O0Sfffperyi 6SZSetV8cZ0J7yLqpqnjfVSwVbRsuIqhk2ZZ/hxF3P+KLVI//s3dLftEkjrnEl2KDtHVTYMlDwi PJ9vtHU1pHp569Iswjf5J+T5huzBH9c2E6+vBYDhCWCIvLE6iA= X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:19:25 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" All the tests are prefixed with 'x', in order to avoid risky comparisons (i.e. a user deliberately trying to provoke a syntax error). Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier Reviewed-by: Eric Blake --- scripts/qemu-binfmt-conf.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index c728443ba2..98401f4e7c 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -259,10 +259,10 @@ qemu_check_systemd() { qemu_generate_register() { flags="" - if [ "$CREDENTIAL" = "yes" ]; then + if [ "x$CREDENTIAL" = "xyes" ]; then flags="OC" fi - if [ "$PERSISTENT" = "yes" ]; then + if [ "x$PERSISTENT" = "xyes" ]; then flags="${flags}F" fi @@ -300,18 +300,18 @@ qemu_set_binfmts() { mask=$(eval echo \$${cpu}_mask) family=$(eval echo \$${cpu}_family) - if [ "$magic" = "" ] || [ "$mask" = "" ] || [ "$family" = "" ]; then + if [ "x$magic" = "x" ] || [ "x$mask" = "x" ] || [ "x$family" = "x" ]; then echo "INTERNAL ERROR: unknown cpu $cpu" 1>&2 continue fi qemu="$QEMU_PATH/qemu-$cpu" - if [ "$cpu" = "i486" ]; then + if [ "x$cpu" = "xi486" ]; then qemu="$QEMU_PATH/qemu-i386" fi qemu="$qemu$QEMU_SUFFIX" - if [ "$host_family" != "$family" ]; then + if [ "x$host_family" != "x$family" ]; then $BINFMT_SET fi done From patchwork Mon Mar 9 19:19:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp450JhBz9sRN for ; Tue, 10 Mar 2020 06:21:24 +1100 (AEDT) Received: from localhost ([::1]:48394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNxq-0008V7-JW for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49512) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNwV-0006cm-Em for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:20:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNwT-00080l-83 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:19:59 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:40114 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNwS-00080H-SY for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:19:57 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 8B7A55F6F; Mon, 9 Mar 2020 20:19:54 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58D8C5A04F; Mon, 9 Mar 2020 20:19:54 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DC165A045; Mon, 9 Mar 2020 20:19:54 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:19:54 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id 0CC3E5F6F; Mon, 9 Mar 2020 20:19:54 +0100 (CET) Date: Mon, 9 Mar 2020 19:19:52 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 03/10] qemu-binfmt-conf.sh: make opts -p and -c boolean Message-ID: <20200309191952.GC65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:19:54 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No--0.283-7.0-31-10 X-imss-scan-details: No--0.283-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10--0.282600-10.000000 X-TMASE-MatchedRID: 5MYN72agt7osSx1KHZomlKS9pC14MC3C6qG5M9QNAO1CannV/b7f2cEI kNzFiDxLvdz+hjQlBqVqAxBaFFZ85HTKrg3nLjv1A9lly13c/gGOz/LLJUcaHoXfDl+KHKjY2NR c0Z/xVW0vrwXOPzQMJ1WGfFaWlqBcrSKKfw/QqNWK2+RZ4/fWST8ZO44VTPmzabJxhiIFjJnUA8 lgylnZvvJAhJwgr+u9bOUsBbIsdlNDq2SVEk72KAtuKBGekqUpnH7sbImOEBTvbOtfMFISHEyhV JJbcQD9rGssu6wFGXlfwkikVgb9JUKEnWIqoXRFRprNGNVrK9X+pmStTY4u3qozBIzI0vGSNm++ YGJlAxNKU2XuQZXDAUznMHeShSu0p/GSAIsG8Of0jt4HSLaYh18I4oUq5Vga X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:19:54 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch breaks backward compatibility. Both '--persistent' and '--credential' default to 'no'. Hence, '-p no' or '-c no' are redundant. Overall, accepting an argument might be misleading because options are, indeed, boolean. This patch makes both options boolean in getopt, so if any of them is provided the corresponding variable is set to true. Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 98401f4e7c..285ce528d1 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -172,8 +172,8 @@ qemu_get_family() { usage() { cat < X-Patchwork-Id: 1251766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp4M4j3jz9sPJ for ; Tue, 10 Mar 2020 06:21:39 +1100 (AEDT) Received: from localhost ([::1]:48414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNy5-0000h4-H0 for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:21:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49592) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNwv-0007QZ-Sk for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:20:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNwu-0008En-NR for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:20:25 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:2743 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNwu-0008C8-BL for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:20:24 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 213616311; Mon, 9 Mar 2020 20:20:23 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EED655A04F; Mon, 9 Mar 2020 20:20:22 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E35975A045; Mon, 9 Mar 2020 20:20:22 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:20:22 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id A1CD96311; Mon, 9 Mar 2020 20:20:22 +0100 (CET) Date: Mon, 9 Mar 2020 19:20:21 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 04/10] qemu-binfmt-conf.sh: add QEMU_CREDENTIAL and QEMU_PERSISTENT Message-ID: <20200309192021.GD65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:20:22 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No-1.919-7.0-31-10 X-imss-scan-details: No-1.919-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10-1.919100-10.000000 X-TMASE-MatchedRID: /rjjNR0fZCoNdWPTMyGlNn41AgV24XnfVFeUPAjsd8bhmYLRM9m2iEhq QpzXZe40YNA0HZI8EiGPQi9XuOWoOIG9V0kqQ2uQitvkWeP31kk/GTuOFUz5s2mycYYiBYyZ1AP JYMpZ2b45ekiuCWp2reHQaFidrFj3/N0WsxWI4QdDbiUnjRcCmJnaxzJFBx6vrP7fIroeSfN6Ho OzBHN0E+LzNWBegCW2OubYLCVnBVEqyYS0oyUVZvame15MIThR+8CwdiPq88eRQ5ABDkG7qjGgT lf1BRgl1GRbd+6gQEN33qXzE9EBM7W6kOI3g9aLFqondSz7+RyJKj2R/IENdRuJyuskHg4AzM2F BO7i4hJRYW5hfzhEW0CLmZDDvMfd0hli/KDwoy2eqD9WtJkSIw== X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:20:23 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow to set options '--persistent' and/or '--credential' through environment variables. If not defined, defaults are used ('no'). Anyway, command-line arguments have priority over environment variables. Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 285ce528d1..0c28db5ca4 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -190,9 +190,11 @@ Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU] (default: $SYSTEMDDIR or $DEBIANDIR) --credential: if present, credential and security tokens are calculated according to the binary to interpret + (QEMU_CREDENTIAL=yes) --persistent: if present, the interpreter is loaded when binfmt is configured and remains in memory. All future uses are cloned from the open file. + (QEMU_PERSISTENT=yes) To import templates with update-binfmts, use : @@ -259,10 +261,10 @@ qemu_check_systemd() { qemu_generate_register() { flags="" - if [ "x$CREDENTIAL" = "xyes" ]; then + if [ "x$QEMU_CREDENTIAL" = "xyes" ]; then flags="OC" fi - if [ "x$PERSISTENT" = "xyes" ]; then + if [ "x$QEMU_PERSISTENT" = "xyes" ]; then flags="${flags}F" fi @@ -285,7 +287,7 @@ package qemu-$cpu interpreter $qemu magic $magic mask $mask -credential $CREDENTIAL +credential $QEMU_CREDENTIAL EOF } @@ -324,8 +326,10 @@ SYSTEMDDIR="/etc/binfmt.d" DEBIANDIR="/usr/share/binfmts" QEMU_PATH=/usr/local/bin -CREDENTIAL=no -PERSISTENT=no + +QEMU_PERSISTENT="${QEMU_PERSISTENT:-no}" +QEMU_CREDENTIAL="${QEMU_CREDENTIAL:-no}" + QEMU_SUFFIX="" options=$(getopt -o ds:Q:S:e:hcp -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential,persistent -- "$@") @@ -377,10 +381,10 @@ while true; do exit 1 ;; -c|--credential) - CREDENTIAL="yes" + QEMU_CREDENTIAL="yes" ;; -p|--persistent) - PERSISTENT="yes" + QEMU_PERSISTENT="yes" ;; *) break From patchwork Mon Mar 9 19:20:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp581kQRz9sPF for ; Tue, 10 Mar 2020 06:22:20 +1100 (AEDT) Received: from localhost ([::1]:48422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNyk-00027f-0x for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49712) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNxU-00008h-MY for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:21:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNxT-0000JM-5o for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:21:00 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:38067 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNxS-0000GX-Pu for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:20:59 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 3C7365F6F; Mon, 9 Mar 2020 20:20:56 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09BBA5A04F; Mon, 9 Mar 2020 20:20:56 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2EF85A045; Mon, 9 Mar 2020 20:20:55 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:20:55 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id B01F05F6F; Mon, 9 Mar 2020 20:20:55 +0100 (CET) Date: Mon, 9 Mar 2020 19:20:54 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 05/10] qemu-binfmt-conf.sh: use the same presentation format as for qemu-* Message-ID: <20200309192054.GE65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:20:55 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No--0.153-7.0-31-10 X-imss-scan-details: No--0.153-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10--0.153400-10.000000 X-TMASE-MatchedRID: 8TN2djYOGuT9T2Lkmecl6ZJsWTCuaRDiS1zwNuiBtITfUZT83lbkENcP Az195hI2GSFUsm29mSFhPO8j3auvUoG9V0kqQ2uQbWsCUkrA4Em7xmCZDXruteZYcdJgScjxdg1 +34sLG7ZQY4w7oxnsdyNhKgIJyVjTKkPeqGW0ZSPZulfZck3CoStTx/ehjzxgrSZr8U2Z6jx576 my5IxjuqzXIr1dtYg7fyYDewMOrQDkwjHXXC/4I66NVEWSRWybPDNGqiCm2depzO1rJRmINronB TkneCw+XnK1+k57X2j79zN+rtvs6w4+DiJ5y9a7bqYGLiu0geRtqpQlGh0RSqqrtktnamGIUPCI 8n2+0dTWkennr0izCN/kn5PmG7MEf1zYTr68FgO5XBEMs6Idug== X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:20:56 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 63 +++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 0c28db5ca4..870815fb22 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -171,47 +171,48 @@ qemu_get_family() { usage() { cat < X-Patchwork-Id: 1251770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp7n5S6yz9sRN for ; Tue, 10 Mar 2020 06:24:37 +1100 (AEDT) Received: from localhost ([::1]:48464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO0x-0005ON-Lf for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:24:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50086) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNyo-00032t-TM for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNyn-0001Gx-HK for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:22:22 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:46785 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNyn-0001DT-5o for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:22:21 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 08F4465B6; Mon, 9 Mar 2020 20:22:19 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8A895A04F; Mon, 9 Mar 2020 20:22:18 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD88B5A045; Mon, 9 Mar 2020 20:22:18 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:22:18 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id 2F68C5F6F; Mon, 9 Mar 2020 20:22:18 +0100 (CET) Date: Mon, 9 Mar 2020 19:22:17 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 06/10] qemu-binfmt-conf.sh: remove 'qemu' prefix from cli options Message-ID: <20200309192217.GF65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:22:18 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No-0.609-7.0-31-10 X-imss-scan-details: No-0.609-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10-0.609300-10.000000 X-TMASE-MatchedRID: zi/SDN/U4yNXxVT6/C14BeFgDmzNVVKokRkcrpA9poA3ZbGC9oP/OzB9 ccde3hbUf+3yqvQrlggtpxclXgLOJWQZ31TQwyj3YXOD42j+642nU+NxqV3DDV2YKfSY6fzM1jx n/1gr0UiuQih3+HqEP1e9QrNgNMNku1aOOerCaCkoSebb2328i30tCKdnhB58HOI0tZ7A+B36C0 ePs7A07Vg3wwZ5miMr2cOXvTonNPWdHfeCwcL8t/8rdP67VOvYeOinbHU82mz2/oVCAcZOCtknc E4yvAb30DAZ/DlCKGolA3mJ1t7KdEded2413hE4NDDkhDzsQTLp+5dP4kj0S+Fheyow6ZGG0vzW LJp2OfpVyvbTg/runA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:22:19 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This breaks backward compatibility. Options 'qemu-path' and 'qemu-suffix' have the 'qemu-' prefix, which is not present in other option names ('debian', 'systemd', 'persistent', 'credential'...). In order to keep consistency, the prefix is removed. Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 870815fb22..5cc6db6aed 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -171,6 +171,7 @@ qemu_get_family() { usage() { cat < X-Patchwork-Id: 1251768 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp653dFzz9sPF for ; Tue, 10 Mar 2020 06:23:09 +1100 (AEDT) Received: from localhost ([::1]:48438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNzX-0003iW-Ez for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:23:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50185) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNzC-0003fJ-OK for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:22:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNzB-0001bQ-PT for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:22:46 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:23268 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNzB-0001ay-Do for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:22:45 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 6523A65B6; Mon, 9 Mar 2020 20:22:44 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37CEE5A050; Mon, 9 Mar 2020 20:22:44 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B9FB5A045; Mon, 9 Mar 2020 20:22:44 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:22:44 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id DD1F05F6F; Mon, 9 Mar 2020 20:22:43 +0100 (CET) Date: Mon, 9 Mar 2020 19:22:42 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 07/10] qemu-binfmt-conf.sh: honour QEMU_PATH and/or QEMU_SUFFIX Message-ID: <20200309192242.GG65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:22:44 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No-1.584-7.0-31-10 X-imss-scan-details: No-1.584-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10-1.583800-10.000000 X-TMASE-MatchedRID: SUQ+NPRnbh0NdWPTMyGlNi2416nc3bQlcZ9gNqdc/asHZBaLwEXlKGb6 PphVtfZgqZ4KncYE2LPA1r83Ndy7E4G9V0kqQ2uQ2bpX2XJNwqFzHsCOuSqn1gMADm5EdqKWPBz wxTDfHyKE97yr4g+GPn8mA3sDDq0A5MIx11wv+COujVRFkkVsmyu9MWoaIV++oCrkB9D9Rc3SCY H0rJ+PYyaWRAPBnAfOQu5sCWJbCQGvuCSV9Tys1qlBSdyOhbC1Ru9sLwisTQje2feJC1tWylDwi PJ9vtHU1pHp569Iswjf5J+T5huzBH9c2E6+vBYDhCWCIvLE6iA= X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:22:44 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow to set 'path' or 'suffix' through environment variables, consistently with 'persistent' and 'credential'. Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 5cc6db6aed..b1a54aa470 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -181,7 +181,7 @@ Options and associated environment variables: Argument Env-variable Description -h|--help display this usage -Q|--path PATH QEMU_PATH set path to qemu interpreter(s) --F|--suffix SUFFIX add a suffix to the default interpreter name +-F|--suffix SUFFIX QEMU_SUFFIX add a suffix to the default interpreter name -p|--persistent QEMU_PERSISTENT (yes) load the interpreter and keep it in memory; all future uses are cloned from the open file. -c|--credential QEMU_CREDENTIAL (yes) credential and security tokens are calculated according @@ -195,6 +195,7 @@ Argument Env-variable Description Defaults: QEMU_PATH=$QEMU_PATH +QEMU_SUFFIX=$QEMU_SUFFIX QEMU_PERSISTENT=$QEMU_PERSISTENT QEMU_CREDENTIAL=$QEMU_CREDENTIAL @@ -327,13 +328,11 @@ BINFMT_SET=qemu_register_interpreter SYSTEMDDIR="/etc/binfmt.d" DEBIANDIR="/usr/share/binfmts" -QEMU_PATH=/usr/local/bin - +QEMU_PATH="${QEMU_PATH:-/usr/local/bin}" +QEMU_SUFFIX="${QEMU_SUFFIX:-}" QEMU_PERSISTENT="${QEMU_PERSISTENT:-no}" QEMU_CREDENTIAL="${QEMU_CREDENTIAL:-no}" -QEMU_SUFFIX="" - options=$(getopt -o ds:Q:S:e:hcp -l debian,systemd:,path:,suffix:,exportdir:,help,credential,persistent -- "$@") eval set -- "$options" From patchwork Mon Mar 9 19:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp9r0pybz9sPF for ; Tue, 10 Mar 2020 06:26:24 +1100 (AEDT) Received: from localhost ([::1]:48500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO2g-0007xQ-0a for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50375) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBNzp-0004Xg-Uz for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBNzo-0002Ju-Fv for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:23:25 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:37639 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBNzo-0002Ho-43 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:23:24 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id F0C0E5F6F; Mon, 9 Mar 2020 20:23:22 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D41F15A04F; Mon, 9 Mar 2020 20:23:22 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C869D5A045; Mon, 9 Mar 2020 20:23:22 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:23:22 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id 833D16311; Mon, 9 Mar 2020 20:23:22 +0100 (CET) Date: Mon, 9 Mar 2020 19:23:21 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 08/10] qemu-binfmt-conf.sh: generalize to positional [TARGETS] Message-ID: <20200309192321.GH65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:23:22 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No--6.998-7.0-31-10 X-imss-scan-details: No--6.998-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10--6.998000-10.000000 X-TMASE-MatchedRID: YJG9ytXm/s6u1FVcbKqeS31zro62qhdCM0wEwxpnA/6+fWK8N2kAhz7s j+R9FMn6w9YhgVtZ5FSWFZNqBtigagJ5EJtQroRi/Tc2iq45CnupZoxavGZhju9FCyScBaYaxM9 DM4OIRzZQ6yZ033EzWvVjmIj0I4/bgbzQvVJsmAc/ApMPW/xhXlQQ0EgzIoPR33Nl3elSfsq6o5 pOE3X0ptg9dKgWHMAdkb3r+FsnMU10J8anK3Imuujl+xhc/R9QK1PH96GPPGAN+F513KGyq4eEz yqa7HdJl+J1cqvNn071m0jxLTibTlsMX+cJfRDxxi///JpaHQM/pOSL72dTf6tNdpFrZXd82VC1 QWKKKPprZ54ynQshcEC9kO2OSfgdwL+8p4iyg3yeAiCmPx4NwNivpTdmVCR2xEHRux+uk8h+ICq uNi0WJPbpG7TUKe4pjfqqGpq3uSh1s5cd1+UUt5kz/63nPp1bftwZ3X11IV0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:23:22 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This breaks brackward compatibility. Option '--systemd CPU' allows to register binfmt interpreters for a single target architecture or for 'ALL' (of them). This patch generalizes the approach to support it in any mode (default, '--debian' or '--systemd'). To do so, option 'systemd' is changed to be boolean (no args). Then, all the positional arguments are considered to be a list of target architectures. If no positional arguments are provided, all of the architectures in qemu_target_list are registered. Conversely, argument value 'NONE' allows to make a 'dry run' of the script. I.e., checks are executed according to the mode, but no interpreter is registered. Support QEMU_TARGETS environment variable, consistently with 'path', 'suffix', 'persistent' and 'credential', The supported formats are the same as for positional arguments, which have priority. If both the variable and the list of positional arguments are empty, defaults to qemu_target_list. Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 80 +++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index b1a54aa470..538ef4aec0 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -6,6 +6,28 @@ ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \ sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \ microblaze microblazeel or1k x86_64" +# check if given TARGETS is/are in the supported target list +qemu_check_target_list() { + if [ $# -eq 0 ]; then + checked_target_list="$qemu_target_list" + return + fi + unset checked_target_list + for target; do + for cpu in $qemu_target_list; do + if [ "x$cpu" = "x$target" ]; then + checked_target_list="$checked_target_list $target" + break + fi + done + if [ "x$cpu" != "x$target" ]; then + echo "ERROR: unknown CPU \"$target\"" 1>&2 + usage + exit 1 + fi + done +} + i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00' i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' i386_family=i386 @@ -171,14 +193,16 @@ qemu_get_family() { usage() { cat <&2 - usage - exit 1 - fi - fi ;; -Q|--path) shift @@ -394,5 +404,7 @@ while true; do shift done +shift + $CHECK -qemu_set_binfmts +qemu_set_binfmts "$@" From patchwork Mon Mar 9 19:23:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp7g01lqz9sPF for ; Tue, 10 Mar 2020 06:24:24 +1100 (AEDT) Received: from localhost ([::1]:48456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO0k-00051Y-3p for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:24:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50491) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO0K-0004xa-U5 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:23:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBO0J-0002pr-K2 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:23:56 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:60506 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBO0J-0002pO-5o for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:23:55 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id E62F05F6F; Mon, 9 Mar 2020 20:23:53 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A60375A050; Mon, 9 Mar 2020 20:23:53 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A9295A04F; Mon, 9 Mar 2020 20:23:53 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:23:53 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id 56C006311; Mon, 9 Mar 2020 20:23:53 +0100 (CET) Date: Mon, 9 Mar 2020 19:23:52 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 09/10] qemu-binfmt-conf.sh: add option --clear Message-ID: <20200309192352.GI65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:23:53 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No-1.776-7.0-31-10 X-imss-scan-details: No-1.776-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10-1.775800-10.000000 X-TMASE-MatchedRID: YJG9ytXm/s5nuEpLNqEJsme0F1HB9i2hMVx/3ZYby796pt1oU+C/pOwX ofcWCzMeR5VEg2WHb7e6w0blN6o1l/MNTbjUKZM+20204SCJw/rLvfc3C6SWwnO0TctWrlA9dfu huqa4A1AZw5ucm3NLWhvYV6pkN/jgOLzSBOk91M5bF+jvJlkOptxs0lj1L8rvaUoLEaPNsPSl+9 Tl6lXp3K3aC25avUuauxliYAiybD/AHXRKkXCmPIIK2tjTqNotp1Pjcaldww0aVuuTY4OGgweWZ DV/J9uBGHD/KNtC9kNVhnxWlpagXK0iin8P0KjVKrDHzH6zmUXf+zJsO3bf/t9zZd3pUn7KlMa9 Q0Vx5vSl0s9gTN4+NZpBpHnW+wt+Wb1kI9uGZd+eAiCmPx4NwNivpTdmVCR2xEHRux+uk8ifEzJ 5hPndGUR2Aq4Um6WRV1zLC9mTVRhSAsTokdR7WGO0y7D0GVueICk5FL7LDyVdI/LEbhioFrXUoT tgaXn8FB4XFXJmq0QbF0Vx8tSB9AnoQr0aJHnc0egPf++T1T/YdbOkPFfd3aWs8euL9yX5w8g2H BNcF5k= X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:23:53 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is a partial implementation. Allows to remove a single or a list of already registered binfmt interpreters. Valid values are those in qemu_target_list. If TARGETS is empty, all the existing 'qemu-*' interpreters are removed. This is partial because 'debian' and 'systemd' configurations are not supported. The script will exit with error 'option clear not implemented for this mode yet'. Removal is done by printing '-1' as explained at: https://www.kernel.org/doc/Documentation/admin-guide/binfmt-misc.rst Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 538ef4aec0..55224a68e1 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -201,7 +201,7 @@ Options and associated environment variables: Argument Env-variable Description TARGETS QEMU_TARGETS A single arch name or a list of them (see all names below); - if empty, configure all known targets; + if empty, configure/clear all known targets; if 'NONE', no interpreter is configured. -h|--help display this usage -Q|--path PATH QEMU_PATH set path to qemu interpreter(s) @@ -210,6 +210,8 @@ TARGETS QEMU_TARGETS A single arch name or a list of them (see uses are cloned from the open file. -c|--credential QEMU_CREDENTIAL (yes) credential and security tokens are calculated according to the binary to interpret +-r|--clear QEMU_CLEAR (yes) remove registered interpreters for target TARGETS; + then exit. -e|--exportdir PATH define where to write configuration files (default: $SYSTEMDDIR or $DEBIANDIR) -s|--systemd don't write into /proc, generate file(s) for @@ -222,6 +224,7 @@ QEMU_PATH=$QEMU_PATH QEMU_SUFFIX=$QEMU_SUFFIX QEMU_PERSISTENT=$QEMU_PERSISTENT QEMU_CREDENTIAL=$QEMU_CREDENTIAL +QEMU_CLEAR=$QEMU_CLEAR To import templates with update-binfmts, use : @@ -348,8 +351,22 @@ qemu_set_binfmts() { done } +qemu_clear_notimplemented() { + echo "ERROR: option clear not implemented for this mode yet" 1>&2 + usage + exit 1 +} + +qemu_clear_interpreter() { + p="/proc/sys/fs/binfmt_misc/$1" + if [ -f "$p" ]; then + printf %s -1 > "$p" + fi +} + CHECK=qemu_check_bintfmt_misc BINFMT_SET=qemu_register_interpreter +BINFMT_CLEAR=qemu_clear_interpreter SYSTEMDDIR="/etc/binfmt.d" DEBIANDIR="/usr/share/binfmts" @@ -359,20 +376,26 @@ QEMU_PATH="${QEMU_PATH:-/usr/local/bin}" QEMU_SUFFIX="${QEMU_SUFFIX:-}" QEMU_PERSISTENT="${QEMU_PERSISTENT:-no}" QEMU_CREDENTIAL="${QEMU_CREDENTIAL:-no}" +QEMU_CLEAR="${QEMU_CLEAR:-no}" -options=$(getopt -o dsQ:S:e:hcp -l debian,systemd,path:,suffix:,exportdir:,help,credential,persistent -- "$@") +options=$(getopt -o rdsQ:S:e:hcp -l clear,debian,systemd,path:,suffix:,exportdir:,help,credential,persistent -- "$@") eval set -- "$options" while true; do case "$1" in + -r|--clear) + QEMU_CLEAR="yes" + ;; -d|--debian) CHECK=qemu_check_debian BINFMT_SET=qemu_generate_debian + BINFMT_CLEAR=qemu_clear_notimplemented EXPORTDIR=${EXPORTDIR:-$DEBIANDIR} ;; -s|--systemd) CHECK=qemu_check_systemd BINFMT_SET=qemu_generate_systemd + BINFMT_CLEAR=qemu_clear_notimplemented EXPORTDIR=${EXPORTDIR:-$SYSTEMDDIR} ;; -Q|--path) @@ -407,4 +430,13 @@ done shift $CHECK + +if [ "x$QEMU_CLEAR" = "xyes" ]; then + qemu_check_target_list "$@" + for t in $checked_target_list; do + $BINFMT_CLEAR "qemu-$t" + done + exit +fi + qemu_set_binfmts "$@" From patchwork Mon Mar 9 19:24:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Unai Martinez Corral X-Patchwork-Id: 1251771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ehu.eus Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48bp8Y1TW4z9sPJ for ; Tue, 10 Mar 2020 06:25:17 +1100 (AEDT) Received: from localhost ([::1]:48472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO1b-00065a-2y for incoming@patchwork.ozlabs.org; Mon, 09 Mar 2020 15:25:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50724) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBO0w-0005yJ-Is for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:24:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBO0u-0003tf-Bb for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:24:34 -0400 Received: from smtp.lg.ehu.es ([158.227.0.66]:56367 helo=smtp.ehu.eus) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBO0t-0003se-VN for qemu-devel@nongnu.org; Mon, 09 Mar 2020 15:24:32 -0400 Received: from imsva2.lgp.ehu.es (imsva2.lgp.ehu.es [10.0.3.246]) by postfix.smtp2.imsva2 (Postfix) with ESMTPS id 8369A5F6F; Mon, 9 Mar 2020 20:24:30 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CA425A04F; Mon, 9 Mar 2020 20:24:30 +0100 (CET) Received: from imsva2.lgp.ehu.es (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5127D5A045; Mon, 9 Mar 2020 20:24:30 +0100 (CET) Received: from smtp.ehu.eus (unknown [10.0.100.76]) by imsva2.lgp.ehu.es (Postfix) with ESMTPS; Mon, 9 Mar 2020 20:24:30 +0100 (CET) Received: from 669c1c222ef4 (static.187.0.0.81.ibercom.com [81.0.0.187]) by smtp2 (Postfix) with ESMTPSA id 0E6655F6F; Mon, 9 Mar 2020 20:24:30 +0100 (CET) Date: Mon, 9 Mar 2020 19:24:28 +0000 From: Unai Martinez-Corral To: qemu-devel@nongnu.org Subject: [PATCH v10 10/10] qemu-binfmt-conf.sh: add --test Message-ID: <20200309192428.GJ65@669c1c222ef4> References: <20200309191200.GA60@669c1c222ef4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200309191200.GA60@669c1c222ef4> X-Greylist: ACL 191 matched, not delayed by milter-greylist-4.6.2 (smtp2 [10.0.100.76]); Mon, 09 Mar 2020 20:24:30 +0100 (CET) X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1631-8.5.0.1020-25280.002 X-TM-AS-Result: No--2.997-7.0-31-10 X-imss-scan-details: No--2.997-7.0-31-10 X-TMASE-Version: IMSVA-9.1.0.1631-8.5.1020-25280.002 X-TMASE-Result: 10--2.997200-10.000000 X-TMASE-MatchedRID: C2Ox2wkr63hnuEpLNqEJsi2416nc3bQlcZ9gNqdc/asHZBaLwEXlKGb6 PphVtfZgqZ4KncYE2LNLKA6O53vFEgcVh2A5MTJF6OX7GFz9H1DnaaW2UTafyBpW65Njg4aDrr5 TE4GLzk3aw+TzluSPBbpxDH0YWH+IrjwZVDJcDJ81VHP4fCovgg4fD/I06RGBn7jOJQ+rgvE6dE UNf2ygXDTG16mgO0fW4dBoWJ2sWPf83RazFYjhB8zSKGx9g8xhZlQDEANheHGbKItl61J/yX2PY bDNMTe9KrauXd3MZDUICxwHjpo31YoYktjoiBld8EHDYeu6aOx/tQ+DjcDZGP4mk7dfXIjcMrNm uxw7xuQsiMsxQdKpYMoSPqztN/qGizrT0rPamKW745kuiEUqFFi7FP9SiiauF1qISuK4qVqjyqn hL+I3r7JQSBWmvqaR X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-Greylist: Sender IP whitelisted, Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (postfix.smtp2.imsva2 [10.0.100.76]); Mon, 09 Mar 2020 20:24:30 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 158.227.0.66 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: riku.voipio@iki.fi, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Unai Martinez-Corral Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 55224a68e1..21c8f63916 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -201,8 +201,7 @@ Options and associated environment variables: Argument Env-variable Description TARGETS QEMU_TARGETS A single arch name or a list of them (see all names below); - if empty, configure/clear all known targets; - if 'NONE', no interpreter is configured. + if empty, configure/clear all known targets. -h|--help display this usage -Q|--path PATH QEMU_PATH set path to qemu interpreter(s) -F|--suffix SUFFIX QEMU_SUFFIX add a suffix to the default interpreter name @@ -212,6 +211,8 @@ TARGETS QEMU_TARGETS A single arch name or a list of them (see to the binary to interpret -r|--clear QEMU_CLEAR (yes) remove registered interpreters for target TARGETS; then exit. +-t|--test QEMU_TEST (yes) test the setup with the provided arguments, but do not + configure any of the interpreters. -e|--exportdir PATH define where to write configuration files (default: $SYSTEMDDIR or $DEBIANDIR) -s|--systemd don't write into /proc, generate file(s) for @@ -225,6 +226,7 @@ QEMU_SUFFIX=$QEMU_SUFFIX QEMU_PERSISTENT=$QEMU_PERSISTENT QEMU_CREDENTIAL=$QEMU_CREDENTIAL QEMU_CLEAR=$QEMU_CLEAR +QEMU_TEST=$QEMU_TEST To import templates with update-binfmts, use : @@ -323,9 +325,6 @@ qemu_set_binfmts() { # reduce the list of target interpreters to those given in the CLI targets=${@:-$QEMU_TARGET} - if [ "x$targets" = "xNONE" ]; then - return - fi qemu_check_target_list $targets # register the interpreter for each target except for the native one @@ -377,12 +376,16 @@ QEMU_SUFFIX="${QEMU_SUFFIX:-}" QEMU_PERSISTENT="${QEMU_PERSISTENT:-no}" QEMU_CREDENTIAL="${QEMU_CREDENTIAL:-no}" QEMU_CLEAR="${QEMU_CLEAR:-no}" +QEMU_TEST="${QEMU_TEST:-no}" -options=$(getopt -o rdsQ:S:e:hcp -l clear,debian,systemd,path:,suffix:,exportdir:,help,credential,persistent -- "$@") +options=$(getopt -o trdsQ:S:e:hcp -l test,clear,debian,systemd,path:,suffix:,exportdir:,help,credential,persistent -- "$@") eval set -- "$options" while true; do case "$1" in + -t|--test) + QEMU_TEST="yes" + ;; -r|--clear) QEMU_CLEAR="yes" ;; @@ -431,6 +434,11 @@ shift $CHECK +if [ "x$QEMU_TEST" = "xyes" ]; then + BINFMT_SET=: + BINFMT_CLEAR=: +fi + if [ "x$QEMU_CLEAR" = "xyes" ]; then qemu_check_target_list "$@" for t in $checked_target_list; do