|
|
6661d0 |
From 01f3fb69c8cdb730b74c36d0e5909adc7c50b35e Mon Sep 17 00:00:00 2001
|
|
|
7084e2 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
7084e2 |
Date: Sat, 23 Oct 2021 16:16:39 +0100
|
|
|
7084e2 |
Subject: [PATCH] vddk: Include VDDK major library version in --dump-plugin
|
|
|
7084e2 |
output
|
|
|
7084e2 |
|
|
|
7084e2 |
Although it doesn't seem to be possible to get the precise VDDK
|
|
|
7084e2 |
version, With a relatively simple change we can at least return the
|
|
|
7084e2 |
VDDK major version. Currently this can be 5, 6 or 7.
|
|
|
7084e2 |
|
|
|
7084e2 |
(cherry picked from commit 8700649d147948897f3b97810a1dff37924bdd6e)
|
|
|
7084e2 |
---
|
|
|
7084e2 |
plugins/vddk/nbdkit-vddk-plugin.pod | 4 ++++
|
|
|
7084e2 |
plugins/vddk/vddk.c | 29 +++++++++++++++++++----------
|
|
|
7084e2 |
tests/test-vddk-real-dump-plugin.sh | 2 ++
|
|
|
7084e2 |
3 files changed, 25 insertions(+), 10 deletions(-)
|
|
|
7084e2 |
|
|
|
7084e2 |
diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod
|
|
|
7084e2 |
index 5a426135..bc3c3c94 100644
|
|
|
7084e2 |
--- a/plugins/vddk/nbdkit-vddk-plugin.pod
|
|
|
7084e2 |
+++ b/plugins/vddk/nbdkit-vddk-plugin.pod
|
|
|
7084e2 |
@@ -422,6 +422,10 @@ at runtime.
|
|
|
7084e2 |
If this is printed then the C<nfchostport=PORT> parameter is supported
|
|
|
7084e2 |
by this build.
|
|
|
7084e2 |
|
|
|
7084e2 |
+=item C<vddk_library_version=...>
|
|
|
7084e2 |
+
|
|
|
7084e2 |
+The VDDK major library version: 5, 6, 7, ...
|
|
|
7084e2 |
+
|
|
|
7084e2 |
=item C<vddk_dll=...>
|
|
|
7084e2 |
|
|
|
7084e2 |
Prints the full path to the VDDK shared library. Since this requires
|
|
|
7084e2 |
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
|
|
|
7084e2 |
index 993f2d76..d74a484d 100644
|
|
|
7084e2 |
--- a/plugins/vddk/vddk.c
|
|
|
7084e2 |
+++ b/plugins/vddk/vddk.c
|
|
|
7084e2 |
@@ -81,6 +81,7 @@ NBDKIT_DLL_PUBLIC int vddk_debug_stats;
|
|
|
7084e2 |
static void *dl; /* dlopen handle */
|
|
|
7084e2 |
static bool init_called; /* was InitEx called */
|
|
|
7084e2 |
static __thread int error_suppression; /* threadlocal error suppression */
|
|
|
7084e2 |
+static int library_version; /* VDDK major: 5, 6, 7, ... */
|
|
|
7084e2 |
|
|
|
7084e2 |
static enum { NONE = 0, ZLIB, FASTLZ, SKIPZ } compression; /* compression */
|
|
|
7084e2 |
static char *config; /* config */
|
|
|
7084e2 |
@@ -405,7 +406,10 @@ vddk_config (const char *key, const char *value)
|
|
|
7084e2 |
static void
|
|
|
7084e2 |
load_library (bool load_error_is_fatal)
|
|
|
7084e2 |
{
|
|
|
7084e2 |
- static const char *sonames[] = {
|
|
|
7084e2 |
+ static struct {
|
|
|
7084e2 |
+ const char *soname;
|
|
|
7084e2 |
+ int library_version;
|
|
|
7084e2 |
+ } libs[] = {
|
|
|
7084e2 |
/* Prefer the newest library in case multiple exist. Check two
|
|
|
7084e2 |
* possible directories: the usual VDDK installation puts .so
|
|
|
7084e2 |
* files in an arch-specific subdirectory of $libdir (our minimum
|
|
|
7084e2 |
@@ -413,12 +417,13 @@ load_library (bool load_error_is_fatal)
|
|
|
7084e2 |
* but our testsuite is easier to write if we point libdir
|
|
|
7084e2 |
* directly to a stub .so.
|
|
|
7084e2 |
*/
|
|
|
7084e2 |
- "lib64/libvixDiskLib.so.7",
|
|
|
7084e2 |
- "libvixDiskLib.so.7",
|
|
|
7084e2 |
- "lib64/libvixDiskLib.so.6",
|
|
|
7084e2 |
- "libvixDiskLib.so.6",
|
|
|
7084e2 |
- "lib64/libvixDiskLib.so.5",
|
|
|
7084e2 |
- "libvixDiskLib.so.5",
|
|
|
7084e2 |
+ { "lib64/libvixDiskLib.so.7", 7 },
|
|
|
7084e2 |
+ { "libvixDiskLib.so.7", 7 },
|
|
|
7084e2 |
+ { "lib64/libvixDiskLib.so.6", 6 },
|
|
|
7084e2 |
+ { "libvixDiskLib.so.6", 6 },
|
|
|
7084e2 |
+ { "lib64/libvixDiskLib.so.5", 5 },
|
|
|
7084e2 |
+ { "libvixDiskLib.so.5", 5 },
|
|
|
7084e2 |
+ { NULL }
|
|
|
7084e2 |
};
|
|
|
7084e2 |
size_t i;
|
|
|
7084e2 |
CLEANUP_FREE char *orig_error = NULL;
|
|
|
7084e2 |
@@ -431,19 +436,20 @@ load_library (bool load_error_is_fatal)
|
|
|
7084e2 |
}
|
|
|
7084e2 |
}
|
|
|
7084e2 |
|
|
|
7084e2 |
- for (i = 0; i < sizeof sonames / sizeof sonames[0]; ++i) {
|
|
|
7084e2 |
+ for (i = 0; libs[i].soname != NULL; ++i) {
|
|
|
7084e2 |
CLEANUP_FREE char *path;
|
|
|
7084e2 |
|
|
|
7084e2 |
/* Set the full path so that dlopen will preferentially load the
|
|
|
7084e2 |
* system libraries from the same directory.
|
|
|
7084e2 |
*/
|
|
|
7084e2 |
- if (asprintf (&path, "%s/%s", libdir, sonames[i]) == -1) {
|
|
|
7084e2 |
+ if (asprintf (&path, "%s/%s", libdir, libs[i].soname) == -1) {
|
|
|
7084e2 |
nbdkit_error ("asprintf: %m");
|
|
|
7084e2 |
exit (EXIT_FAILURE);
|
|
|
7084e2 |
}
|
|
|
7084e2 |
|
|
|
7084e2 |
dl = dlopen (path, RTLD_NOW);
|
|
|
7084e2 |
if (dl != NULL) {
|
|
|
7084e2 |
+ library_version = libs[i].library_version;
|
|
|
7084e2 |
/* Now that we found the library, ensure that LD_LIBRARY_PATH
|
|
|
7084e2 |
* includes its directory for all future loads. This may modify
|
|
|
7084e2 |
* path in-place and/or re-exec nbdkit, but that's okay.
|
|
|
7084e2 |
@@ -464,10 +470,12 @@ load_library (bool load_error_is_fatal)
|
|
|
7084e2 |
"If '%s' is located on a non-standard path you may need to\n"
|
|
|
7084e2 |
"set libdir=/path/to/vmware-vix-disklib-distrib.\n\n"
|
|
|
7084e2 |
"See nbdkit-vddk-plugin(1) man page section \"LIBRARY LOCATION\" for details.",
|
|
|
7084e2 |
- orig_error ? : "(unknown error)", sonames[0]);
|
|
|
7084e2 |
+ orig_error ? : "(unknown error)", libs[0].soname);
|
|
|
7084e2 |
exit (EXIT_FAILURE);
|
|
|
7084e2 |
}
|
|
|
7084e2 |
|
|
|
7084e2 |
+ assert (library_version >= 5);
|
|
|
7084e2 |
+
|
|
|
7084e2 |
/* Load symbols. */
|
|
|
7084e2 |
#define STUB(fn,ret,args) \
|
|
|
7084e2 |
do { \
|
|
|
7084e2 |
@@ -583,6 +591,7 @@ vddk_dump_plugin (void)
|
|
|
7084e2 |
|
|
|
7084e2 |
printf ("vddk_default_libdir=%s\n", VDDK_LIBDIR);
|
|
|
7084e2 |
printf ("vddk_has_nfchostport=1\n");
|
|
|
7084e2 |
+ printf ("vddk_library_version=%d\n", library_version);
|
|
|
7084e2 |
|
|
|
7084e2 |
#if defined(HAVE_DLADDR)
|
|
|
7084e2 |
/* It would be nice to print the version of VDDK from the shared
|
|
|
7084e2 |
diff --git a/tests/test-vddk-real-dump-plugin.sh b/tests/test-vddk-real-dump-plugin.sh
|
|
|
7084e2 |
index 2cb7724e..0a079c6c 100755
|
|
|
7084e2 |
--- a/tests/test-vddk-real-dump-plugin.sh
|
|
|
7084e2 |
+++ b/tests/test-vddk-real-dump-plugin.sh
|
|
|
7084e2 |
@@ -58,10 +58,12 @@ rm -f $files
|
|
|
7084e2 |
cleanup_fn rm -f $files
|
|
|
7084e2 |
|
|
|
7084e2 |
nbdkit -f -v vddk libdir="$vddkdir" --dump-plugin > $out
|
|
|
7084e2 |
+cat $out
|
|
|
7084e2 |
|
|
|
7084e2 |
# Check the vddk_* entries are set.
|
|
|
7084e2 |
grep ^vddk_default_libdir= $out
|
|
|
7084e2 |
grep ^vddk_has_nfchostport= $out
|
|
|
7084e2 |
+grep ^vddk_library_version= $out
|
|
|
7084e2 |
grep ^vddk_dll= $out
|
|
|
7084e2 |
|
|
|
7084e2 |
dll="$(grep ^vddk_dll $out | cut -d= -f2)"
|
|
|
7084e2 |
--
|
|
|
7084e2 |
2.31.1
|
|
|
7084e2 |
|