- qemu-user: fix previous patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=45
This commit is contained in:
Alexander Graf 2012-02-03 13:30:55 +00:00 committed by Git OBS Bridge
parent b293dfeca0
commit 04e51158a3
2 changed files with 26 additions and 14 deletions

View File

@ -1,4 +1,4 @@
From 8bee58e4c32a1962ae0107fc3db6bafb4ba3f20a Mon Sep 17 00:00:00 2001
From e2e0df8cf7c45e148e96d3d7c5aeb6d70fd0c966 Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Thu, 2 Feb 2012 18:02:33 +0100
Subject: [PATCH] linux-user: binfmt: support host binaries
@ -8,33 +8,39 @@ trying to run, let's just use that instead as it will be a lot faster.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
linux-user/binfmt.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
linux-user/binfmt.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/linux-user/binfmt.c b/linux-user/binfmt.c
index cd1f513..8c294da 100644
index cd1f513..b9e225f 100644
--- a/linux-user/binfmt.c
+++ b/linux-user/binfmt.c
@@ -5,6 +5,10 @@
@@ -5,6 +5,9 @@
#include <string.h>
#include <stdlib.h>
+#define GNEMUL_PATH "/usr/bin/gnemul/qemu-"
+#ifdef __x86_64__
+#define ARCH_NAME "x86_64"
+#endif
int main(int argc, char **argv, char **envp)
{
@@ -25,6 +29,21 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
@@ -28,6 +31,29 @@ int main(int argc, char **argv, char **envp)
binfmt[0] = '\0';
/* Now argv[0] is the real qemu binary name */
+#ifdef ARCH_NAME
+ {
+ char *hostbin;
+ hostbin = malloc(strlen(argv[1] + strlen(GNEMUL_PATH) + 1));
+ sprintf(hostbin, GNEMUL_PATH ARCH_NAME "%s", argv[1]);
+ char *guestarch;
+
+ guestarch = strrchr(argv[0], '-') ;
+ if (!guestarch) {
+ goto skip;
+ }
+ guestarch++;
+ hostbin = malloc(strlen(argv[1] + strlen("/emul/-for-/" ARCH_NAME) + 1));
+ sprintf(hostbin, "/emul/" ARCH_NAME "-for-%s/%s", guestarch, argv[1]);
+ if (!access(hostbin, X_OK)) {
+ /*
+ * We found a host binary replacement for the non-host binary. Let's
@ -43,11 +49,12 @@ index cd1f513..8c294da 100644
+ return execve(hostbin, &argv[2], envp);
+ }
+ }
+skip:
+#endif
+
binfmt[0] = '\0';
/* Now argv[0] is the real qemu binary name */
new_argv = (char **)malloc((argc + 2) * sizeof(*new_argv));
if (argc > 3) {
memcpy(&new_argv[4], &argv[3], (argc - 3) * sizeof(*new_argv));
--
1.6.0.2

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Feb 3 11:49:24 UTC 2012 - agraf@suse.de
- qemu-user: fix previous patch
-------------------------------------------------------------------
Thu Feb 2 15:28:42 UTC 2012 - agraf@suse.de