소스 검색

qemu-binfmt-conf.sh: add persistent (F) flags

Since kernel commit 948b701a607f
(binfmt_misc: add persistent opened binary handler for containers)
kernel allows to load the interpreter at the configuration time.

In case of chroot, it allows to have the interpreter in the host root
filesystem and not to copy it to the chroot filesystem.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180627205317.10343-3-laurent@vivier.eu>
Laurent Vivier 7 년 전
부모
커밋
01ecd22a29
1개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 13 1
      scripts/qemu-binfmt-conf.sh

+ 13 - 1
scripts/qemu-binfmt-conf.sh

@@ -161,6 +161,7 @@ usage() {
     cat <<EOF
     cat <<EOF
 Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
 Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
                            [--help][--credential yes|no][--exportdir PATH]
                            [--help][--credential yes|no][--exportdir PATH]
+                           [--persistent yes|no]
 
 
        Configure binfmt_misc to use qemu interpreter
        Configure binfmt_misc to use qemu interpreter
 
 
@@ -176,6 +177,9 @@ Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
                      (default: $SYSTEMDDIR or $DEBIANDIR)
                      (default: $SYSTEMDDIR or $DEBIANDIR)
        --credential: if yes, credential and security tokens are
        --credential: if yes, credential and security tokens are
                      calculated according to the binary to interpret
                      calculated according to the binary to interpret
+       --persistent: if yes, the interpreter is loaded when binfmt is
+                     configured and remains in memory. All future uses
+                     are cloned from the open file.
 
 
     To import templates with update-binfmts, use :
     To import templates with update-binfmts, use :
 
 
@@ -245,6 +249,9 @@ qemu_generate_register() {
     if [ "$CREDENTIAL" = "yes" ] ; then
     if [ "$CREDENTIAL" = "yes" ] ; then
         flags="OC"
         flags="OC"
     fi
     fi
+    if [ "$PERSISTENT" = "yes" ] ; then
+        flags="${flags}F"
+    fi
 
 
     echo ":qemu-$cpu:M::$magic:$mask:$qemu:$flags"
     echo ":qemu-$cpu:M::$magic:$mask:$qemu:$flags"
 }
 }
@@ -304,8 +311,9 @@ DEBIANDIR="/usr/share/binfmts"
 
 
 QEMU_PATH=/usr/local/bin
 QEMU_PATH=/usr/local/bin
 CREDENTIAL=no
 CREDENTIAL=no
+PERSISTENT=no
 
 
-options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,credential: -- "$@")
+options=$(getopt -o ds:Q:e:hc:p: -l debian,systemd:,qemu-path:,exportdir:,help,credential:,persistent: -- "$@")
 eval set -- "$options"
 eval set -- "$options"
 
 
 while true ; do
 while true ; do
@@ -353,6 +361,10 @@ while true ; do
         shift
         shift
         CREDENTIAL="$1"
         CREDENTIAL="$1"
         ;;
         ;;
+    -p|--persistent)
+        shift
+        PERSISTENT="$1"
+        ;;
     *)
     *)
         break
         break
         ;;
         ;;