From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBYWf-0002f4-5l for qemu-devel@nongnu.org; Thu, 06 Feb 2014 18:38:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBYWU-0001Ey-6l for qemu-devel@nongnu.org; Thu, 06 Feb 2014 18:38:33 -0500 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]:34747) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBYWU-0001EQ-02 for qemu-devel@nongnu.org; Thu, 06 Feb 2014 18:38:22 -0500 Received: by mail-ea0-f174.google.com with SMTP id b10so1228692eae.19 for ; Thu, 06 Feb 2014 15:38:19 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 7 Feb 2014 00:38:12 +0100 Message-Id: <1391729892-17783-1-git-send-email-pbonzini@redhat.com> References: Subject: Re: [Qemu-devel] [PATCH v18 00/10] Shared library module support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Maydell Cc: Kevin Wolf , Stefan Hajnoczi , Michael Tokarev , Alex Bligh , Miroslav Rezanina , Lluis Vilanova , Richard Henderson > 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 Date: Wed, 5 Feb 2014 21:15:01 +0100 Subject: [PATCH] oslib: port qemu_exec_dir to Darwin Signed-off-by: Paolo Bonzini --- 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 #include +/* Get declaration of _NSGetExecutablePath on MacOS X 10.2 or newer. */ +#if defined(__APPLE__) && defined(__MACH__) +#define ENUM_DYLD_BOOL +#include +#endif + #ifdef CONFIG_LINUX #include #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