qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of


From: Alex Bennée
Subject: Re: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries
Date: Wed, 04 Jul 2018 09:26:06 +0100
User-agent: mu4e 1.1.0; emacs 26.1.50

Laurent Vivier <address@hidden> 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 <address@hidden>
>> ---
>>  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 via email to

[Prev in Thread] Current Thread [Next in Thread]