qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v18 00/10] Shared library module support


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v18 00/10] Shared library module support
Date: Fri, 7 Feb 2014 00:38:12 +0100

> Looks like we're not getting the executable path
> correctly on MacOS for some reason.

Indeed, there is no code for it.  Can you try the patch below?

> Also, mjt pointed out on IRC that we probably want to allow
> installing binary modules into a path with the arch name in
> it, to allow for multiarch distros.

Isn't --libdir enough?

Paolo

==================== 8< ========================
From: Paolo Bonzini <address@hidden>
Date: Wed, 5 Feb 2014 21:15:01 +0100
Subject: [PATCH] oslib: port qemu_exec_dir to Darwin

Signed-off-by: Paolo Bonzini <address@hidden>
---
 util/oslib-posix.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 372b2f9..590a7d1 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -59,6 +59,12 @@ extern int daemon(int, int);
 #include <sys/mman.h>
 #include <libgen.h>
 
+/* Get declaration of _NSGetExecutablePath on MacOS X 10.2 or newer.  */
+#if defined(__APPLE__) && defined(__MACH__)
+#define ENUM_DYLD_BOOL
+#include <mach-o/dyld.h>
+#endif
+
 #ifdef CONFIG_LINUX
 #include <sys/syscall.h>
 #endif
@@ -303,6 +309,15 @@ char *qemu_exec_dir(const char *argv0)
             p = buf;
         }
     }
+#elif defined(__APPLE__) && defined(__MACH__)
+    {
+        char result[PATH_MAX];
+        uint32_t length = PATH_MAX;
+        if (_NSGetExecutablePath (result, &length) != 0 || result[0] != '/') {
+            return NULL;
+        }
+        p = realpath(result, buf);
+    }
 #endif
     /* If we don't have any way of figuring out the actual executable
        location then try argv[0].  */
-- 
1.8.5.3




reply via email to

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