From 8b9d017de38ba9ed711d24ed82aeff81a1851db6 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 2 Aug 2017 11:21:12 +0100 Subject: [PATCH] driver: conditionalize use of dlopen functions & use mingw-dlfcn Not every platform is guaranteed to have dlopen/dlsym, so we should conditionalize its use. Suprisingly it is actually present for Win32 via the mingw-dlfcn add on, but we should still conditionalize it. Signed-off-by: Daniel P. Berrange --- mingw-libvirt.spec.in | 2 ++ src/driver.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in index 4efa0ddbfa..183346cf64 100644 --- a/mingw-libvirt.spec.in +++ b/mingw-libvirt.spec.in @@ -54,6 +54,8 @@ BuildRequires: mingw32-libxml2 BuildRequires: mingw64-libxml2 BuildRequires: mingw32-portablexdr BuildRequires: mingw64-portablexdr +BuildRequires: mingw32-dlfcn +BuildRequires: mingw64-dlfcn BuildRequires: pkgconfig # Need native version for msgfmt diff --git a/src/driver.c b/src/driver.c index 2e7dd01df8..04dd0a4431 100644 --- a/src/driver.c +++ b/src/driver.c @@ -34,10 +34,11 @@ VIR_LOG_INIT("driver"); /* XXX re-implement this for other OS, or use libtools helper lib ? */ - -#include #define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver" +#ifdef HAVE_DLFCN_H +# include + static void * virDriverLoadModuleFile(const char *file) @@ -126,6 +127,19 @@ virDriverLoadModuleFull(const char *path, return ret; } +#else /* ! HAVE_DLFCN_H */ +int +virDriverLoadModuleFull(const char *path ATTRIBUTE_UNUSED, + const char *regfunc ATTRIBUTE_UNUSED, + void **handle) +{ + VIR_DEBUG("dlopen not available on this platform"); + if (handle) + *handle = NULL; + return -1; +} +#endif /* ! HAVE_DLFCN_H */ + int virDriverLoadModule(const char *name,