qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Add binfmt wrapper
@ 2014-07-14 14:38 Joakim Tjernlund
  2014-07-14 15:21 ` Alexander Graf
  0 siblings, 1 reply; 22+ messages in thread
From: Joakim Tjernlund @ 2014-07-14 14:38 UTC (permalink / raw)
  To: qemu-devel, Alexander Graf; +Cc: Joakim Tjernlund

The popular binfmt-wrapper patch adds an additional
executable which mangle argv suitable for binfmt flag P.
In a chroot you need the both (statically linked) qemu-$arch
and qemu-$arch-binfmt-wrapper. This is sub optimal and a
better approach is to recognize the -binfmt-wrapper extension
within linux-user(qemu-$arch) and mangle argv there.
This just produces on executable which can be either copied to
the chroot or bind mounted with the appropriate -binfmt-wrapper
suffix.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 linux-user/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/linux-user/main.c b/linux-user/main.c
index 71a33c7..212067a 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3828,6 +3828,19 @@ int main(int argc, char **argv, char **envp)
     int i;
     int ret;
     int execfd;
+    char *binfmt;
+
+    i = strlen( argv[0] ) - strlen ( "-binfmt-wrapper" );
+    binfmt = argv[0] + i;
+    if (i > 0 && strcmp ( binfmt, "-binfmt-wrapper" ) == 0) {
+	if (argc < 3 ) {
+	    fprintf ( stderr, "%s: Please use me through binfmt with P flag\n", argv[0] );
+	    exit(1);
+	}
+	handle_arg_argv0(argv[2]); /* binfmt wrapper */
+	memmove(&argv[2], &argv[3], (argc-2)*sizeof(argv));
+	argc--;
+    }
 
     module_call_init(MODULE_INIT_QOM);
 
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-07-16 11:38 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14 14:38 [Qemu-devel] [PATCH] linux-user: Add binfmt wrapper Joakim Tjernlund
2014-07-14 15:21 ` Alexander Graf
2014-07-14 15:38   ` Joakim Tjernlund
2014-07-14 15:46     ` Alexander Graf
2014-07-14 15:59       ` Joakim Tjernlund
2014-07-14 16:00         ` Alexander Graf
2014-07-14 16:32           ` Joakim Tjernlund
2014-07-14 16:34             ` Alexander Graf
2014-07-14 16:45               ` Joakim Tjernlund
2014-07-14 16:51               ` Joakim Tjernlund
2014-07-14 16:54                 ` Alexander Graf
2014-07-14 17:01                   ` Joakim Tjernlund
2014-07-14 17:08                   ` Joakim Tjernlund
2014-07-14 17:14                     ` Alexander Graf
2014-07-14 16:00         ` Peter Maydell
2014-07-14 16:08           ` Joakim Tjernlund
2014-07-15 14:12     ` Riku Voipio
2014-07-15 14:39       ` Joakim Tjernlund
2014-07-15 15:11       ` Joakim Tjernlund
2014-07-16  6:54         ` Riku Voipio
2014-07-16  7:22           ` Joakim Tjernlund
2014-07-16 11:38           ` Joakim Tjernlund

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).