qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Laurent Vivier <laurent@vivier.eu>
Cc: qemu-devel@nongnu.org, Riku Voipio <riku.voipio@iki.fi>
Subject: Re: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries
Date: Wed, 04 Jul 2018 09:26:06 +0100	[thread overview]
Message-ID: <8736wz9zkx.fsf@linaro.org> (raw)
In-Reply-To: <bd71ddfb-1f94-605a-ac94-bd372d34bddd@vivier.eu>


Laurent Vivier <laurent@vivier.eu> writes:

> Le 03/07/2018 à 18:00, Alex Bennée a écrit:
>> 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
>
> You should use qemu_check_access()
>
>> +        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
>>          ;;
>>
>
> if you use --debian or --systemd, you don't have the problem because
> update-binfmts and systemd-binfmt.service update /proc from the
> generated files for you.

Usually I just "apt install qemu-user" and be done with it but I was
writing up a blog post and trying to keep it as distro agnostic as
possible.

>
> But you're right there is no command to undo what we have done.
> You manage only the /proc case, I think it would be also useful to
> remove the files from $EXPORTDIR.
>
> So could you also manage something like "--debian --clear" and
> "--systemd CPU --clear"?

Sure, I'll look into it.

>
> Thanks,
> Laurent


--
Alex Bennée

      reply	other threads:[~2018-07-04  8:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 16:00 [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries Alex Bennée
2018-07-03 16:56 ` no-reply
2018-07-03 16:57 ` Laurent Vivier
2018-07-04  8:26   ` Alex Bennée [this message]

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=8736wz9zkx.fsf@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).