From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries
Date: Tue, 3 Jul 2018 17:00:22 +0100 [thread overview]
Message-ID: <20180703160022.10705-1-alex.bennee@linaro.org> (raw)
Currently running the script twice will fail with "sh: echo: I/O
error" as the registration is already complete. Add a new option
--clear to reset the entries to save the user doing it by hand.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
scripts/qemu-binfmt-conf.sh | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index d7eefda0b8..13ef4713e6 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -160,7 +160,7 @@ qemu_get_family() {
usage() {
cat <<EOF
Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
- [--help][--credential yes|no][--exportdir PATH]
+ [--help][--clear][--credential yes|no][--exportdir PATH]
Configure binfmt_misc to use qemu interpreter
@@ -176,6 +176,7 @@ Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
(default: $SYSTEMDDIR or $DEBIANDIR)
--credential: if yes, credential and security tokens are
calculated according to the binary to interpret
+ --clear: clear existing qemu binfmt registrations
To import templates with update-binfmts, use :
@@ -249,6 +250,13 @@ qemu_register_interpreter() {
qemu_generate_register > /proc/sys/fs/binfmt_misc/register
}
+qemu_clear_interpreter() {
+ if [ -e /proc/sys/fs/binfmt_misc/qemu-$cpu ]; then
+ echo "Removing qemu-$cpu as binfmt interpreter for $cpu"
+ echo -1 > /proc/sys/fs/binfmt_misc/qemu-$cpu
+ fi
+}
+
qemu_generate_systemd() {
echo "Setting $qemu as binfmt interpreter for $cpu for systemd-binfmt.service"
qemu_generate_register > "$EXPORTDIR/qemu-$cpu.conf"
@@ -302,7 +310,7 @@ DEBIANDIR="/usr/share/binfmts"
QEMU_PATH=/usr/local/bin
FLAGS=""
-options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,credential: -- "$@")
+options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,clear,credential: -- "$@")
eval set -- "$options"
while true ; do
@@ -354,6 +362,10 @@ while true ; do
FLAGS=""
fi
;;
+ --clear)
+ shift
+ BINFMT_SET=qemu_clear_interpreter
+ ;;
*)
break
;;
--
2.17.1
next reply other threads:[~2018-07-03 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-03 16:00 Alex Bennée [this message]
2018-07-03 16:56 ` [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries no-reply
2018-07-03 16:57 ` Laurent Vivier
2018-07-04 8:26 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180703160022.10705-1-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).