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: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: allow clearing of entries
Date: Tue, 3 Jul 2018 18:57:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

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.

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"?

Thanks,
Laurent





reply via email to

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