Re: Bug#931641: perl: FTBFS under qemu-user

John Paul Adrian Glaubitz <[email protected]>
Newsgroups gmane.linux.debian.ports.superh,gmane.linux.debian.ports.68k
Message-ID <[email protected]>
Hi!

On 7/10/19 7:45 PM, John Paul Adrian Glaubitz wrote:
> Laurent helped me debugging and the problem is that Debian has its own binfmt-support
> packages which competes with systemd-binfmt with the former not setting the preserve
> flag.

It works for me with the attached patch by Laurent Vivier.

Activate with:

# apt purge binfmt-support
# rm /usr/bin/qemu-m68k-static
# cp -av m68k-linux-user/qemu-m68k /usr/bin/qemu-m68k-static
# ./scripts/qemu-binfmt-conf.sh --systemd m68k --qemu-path /usr/bin --qemu-suffix -static --credential yes --persistent yes

Then just rebooted the machine and it worked.

systemd-binfmt works better for me than Debian's own binfmt-support.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
0001-linux-user-manage-binfmt-misc-preserve-arg-0-flag.patch (text/x-patch, 1.8 KB)
>From 30b70d1e6dd1267214aaf960f5154bba8c5f2f99 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <[email protected]>
Date: Thu, 11 Jul 2019 00:26:04 +0200
Subject: [PATCH] linux-user: manage binfmt-misc preserve-arg[0] flag

---
 linux-user/main.c           | 16 ++++++++++++++++
 scripts/qemu-binfmt-conf.sh |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index a59ae9439d..0e923e150d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -649,6 +649,9 @@ int main(int argc, char **argv, char **envp)
 
     init_qemu_uname_release();
 
+    /*
+     * Manage binfmt-misc open-binary flag
+     */
     execfd = qemu_getauxval(AT_EXECFD);
     if (execfd == 0) {
         execfd = open(filename, O_RDONLY);
@@ -656,6 +659,19 @@ int main(int argc, char **argv, char **envp)
             printf("Error while loading %s: %s\n", filename, strerror(errno));
             _exit(EXIT_FAILURE);
         }
+    } else {
+        /*
+         * Manage binfmt-misc preserve-arg[0] flag
+         *    argv[optind]     full path to the binary
+         *    argv[optind + 1] original argv[0]
+         */
+        if (optind + 1 < argc) {
+            /*
+             * argv0 with an empty string will set argv[optind + 1]
+             * as target_argv[0]
+             */
+            optind++;
+        }
     }
 
     if (cpu_model == NULL) {
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index b5a16742a1..af07a0a186 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -256,7 +256,7 @@ qemu_check_systemd() {
 qemu_generate_register() {
     flags=""
     if [ "$CREDENTIAL" = "yes" ] ; then
-        flags="OC"
+        flags="OCP"
     fi
     if [ "$PERSISTENT" = "yes" ] ; then
         flags="${flags}F"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.