Blob Blame History Raw
From 7b43137763287b3d79874e27146ea2fecc5f9a17 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 25 Oct 2021 08:36:53 +0100
Subject: [PATCH] vddk: Print one line in --dump-plugin output for each VDDK
 API

Helps when detecting if certain optional features are being used, such
as flush and extents.

(cherry picked from commit 4ee13559e46cf622410d0bdd7db29bb00908b40a)
---
 plugins/vddk/nbdkit-vddk-plugin.pod |  9 +++++++++
 plugins/vddk/vddk.c                 | 10 ++++++++++
 tests/test-vddk-real-dump-plugin.sh |  1 +
 3 files changed, 20 insertions(+)

diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod
index 49e3d75d..0702aa75 100644
--- a/plugins/vddk/nbdkit-vddk-plugin.pod
+++ b/plugins/vddk/nbdkit-vddk-plugin.pod
@@ -432,6 +432,15 @@ If this is omitted it means the library could not be loaded.
 Prints the full path to the VDDK shared library.  Since this requires
 a glibc extension it may not be available in all builds of the plugin.
 
+=item C<VixDiskLib_...=1>
+
+For each VDDK API that the plugin uses I<and> which is present in the
+VDDK library that was loaded, we print the name of the API
+(eg. C<VixDiskLib_Open=1>).  This lets you see which optional APIs are
+available, such as C<VixDiskLib_Flush> and
+C<VixDiskLib_QueryAllocatedBlocks>.  If the library could not be
+loaded then these lines are not printed.
+
 =back
 
 =head1 NOTES
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
index 39a7d261..096b04bf 100644
--- a/plugins/vddk/vddk.c
+++ b/plugins/vddk/vddk.c
@@ -616,6 +616,16 @@ vddk_dump_plugin (void)
     printf ("vddk_dll=%s\n", p);
   }
 #endif
+
+  /* Note we print all VDDK APIs found here, not just the optional
+   * ones.  That is so if we update the baseline VDDK in future and
+   * make optional into required APIs, the output doesn't change.
+   */
+#define STUB(fn,ret,args) if (fn != NULL) printf ("%s=1\n", #fn);
+#define OPTIONAL_STUB(fn,ret,args) STUB(fn,ret,args)
+#include "vddk-stubs.h"
+#undef STUB
+#undef OPTIONAL_STUB
 }
 
 /* The rules on threads and VDDK are here:
diff --git a/tests/test-vddk-real-dump-plugin.sh b/tests/test-vddk-real-dump-plugin.sh
index 0a079c6c..e37c8b54 100755
--- a/tests/test-vddk-real-dump-plugin.sh
+++ b/tests/test-vddk-real-dump-plugin.sh
@@ -65,6 +65,7 @@ grep ^vddk_default_libdir= $out
 grep ^vddk_has_nfchostport= $out
 grep ^vddk_library_version= $out
 grep ^vddk_dll= $out
+grep ^VixDiskLib_Open=1 $out
 
 dll="$(grep ^vddk_dll $out | cut -d= -f2)"
 test -f "$dll"
-- 
2.31.1