util: use host module suffix when loading drivers

Driver module loaders current hardcode ".so" as the file
extension.  On MacOS, meson uses ".dylib" as a module file extension.
This patch adds VIR_FILE_MODULE_EXT to virfile.h defined as the
hosts module extension, and updates driver module loaders to make
use of it.

Signed-off-by: Scott Shambarger <scott-libvirt@shambarger.net>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Scott Shambarger 2020-08-25 16:47:07 -07:00 committed by Pavel Hrdina
parent 46d88d8dba
commit 89f5b90a5f
5 changed files with 10 additions and 4 deletions

View File

@ -55,7 +55,7 @@ virDriverLoadModule(const char *name,
if (!(modfile = virFileFindResourceFull(name,
"libvirt_driver_",
".so",
VIR_FILE_MODULE_EXT,
abs_top_builddir "/src",
DEFAULT_DRIVER_DIR,
"LIBVIRT_DRIVER_DIR")))

View File

@ -138,7 +138,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
} else {
if (!(modfile = virFileFindResourceFull(name,
NULL,
".so",
VIR_FILE_MODULE_EXT,
abs_top_builddir "/src",
LIBDIR "/libvirt/lock-driver",
"LIBVIRT_LOCK_MANAGER_PLUGIN_DIR")))

View File

@ -91,7 +91,7 @@ virStorageDriverLoadBackendModule(const char *name,
if (!(modfile = virFileFindResourceFull(name,
"libvirt_storage_backend_",
".so",
VIR_FILE_MODULE_EXT,
abs_top_builddir "/src",
STORAGE_BACKEND_MODULE_DIR,
"LIBVIRT_STORAGE_BACKEND_DIR")))

View File

@ -36,6 +36,12 @@ typedef enum {
VIR_FILE_CLOSE_DONT_LOG = 1 << 2,
} virFileCloseFlags;
#ifdef __APPLE__
# define VIR_FILE_MODULE_EXT ".dylib"
#else
# define VIR_FILE_MODULE_EXT ".so"
#endif
ssize_t saferead(int fd, void *buf, size_t count) G_GNUC_WARN_UNUSED_RESULT;
ssize_t safewrite(int fd, const void *buf, size_t count)
G_GNUC_WARN_UNUSED_RESULT;

View File

@ -56,7 +56,7 @@ virStorageFileLoadBackendModule(const char *name,
if (!(modfile = virFileFindResourceFull(name,
"libvirt_storage_file_",
".so",
VIR_FILE_MODULE_EXT,
abs_top_builddir "/src",
STORAGE_FILE_MODULE_DIR,
"LIBVIRT_STORAGE_FILE_DIR")))