Blame SOURCES/0006-vddk-Only-print-vddk_library_version-when-we-managed.patch

c47df4
From b8b376cf39d97c9f523a9867612126088b43c523 Mon Sep 17 00:00:00 2001
c47df4
From: "Richard W.M. Jones" <rjones@redhat.com>
c47df4
Date: Sat, 23 Oct 2021 19:50:52 +0100
c47df4
Subject: [PATCH] vddk: Only print vddk_library_version when we managed to load
c47df4
 the library
c47df4
c47df4
Because --dump-plugin calls load_library (false) it won't fail if we
c47df4
didn't manage to load the library.  This results in library_version
c47df4
being 0, which we printed incorrectly.
c47df4
c47df4
Resolve this problem by not printing the vddk_library_version entry in
c47df4
this case.
c47df4
c47df4
Fixes: commit 8700649d147948897f3b97810a1dff37924bdd6e
c47df4
(cherry picked from commit a3fba12c3e9c2113009f556360ae0bd04c45f6bb)
c47df4
---
c47df4
 plugins/vddk/nbdkit-vddk-plugin.pod | 1 +
c47df4
 plugins/vddk/vddk.c                 | 9 ++++++++-
c47df4
 2 files changed, 9 insertions(+), 1 deletion(-)
c47df4
c47df4
diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod
c47df4
index 822b96be..c56faddc 100644
c47df4
--- a/plugins/vddk/nbdkit-vddk-plugin.pod
c47df4
+++ b/plugins/vddk/nbdkit-vddk-plugin.pod
c47df4
@@ -420,6 +420,7 @@ by this build.
c47df4
 =item C<vddk_library_version=...>
c47df4
 
c47df4
 The VDDK major library version: 5, 6, 7, ...
c47df4
+If this is omitted it means the library could not be loaded.
c47df4
 
c47df4
 =item C<vddk_dll=...>
c47df4
 
c47df4
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
c47df4
index 291283f4..96615749 100644
c47df4
--- a/plugins/vddk/vddk.c
c47df4
+++ b/plugins/vddk/vddk.c
c47df4
@@ -482,7 +482,14 @@ vddk_dump_plugin (void)
c47df4
 
c47df4
   printf ("vddk_default_libdir=%s\n", VDDK_LIBDIR);
c47df4
   printf ("vddk_has_nfchostport=1\n");
c47df4
-  printf ("vddk_library_version=%d\n", library_version);
c47df4
+
c47df4
+  /* Because load_library (false) we might not have loaded VDDK, in
c47df4
+   * which case we didn't set library_version.  Note this cannot
c47df4
+   * happen in the normal (non-debug-plugin) path because there we use
c47df4
+   * load_library (true).
c47df4
+   */
c47df4
+  if (library_version > 0)
c47df4
+    printf ("vddk_library_version=%d\n", library_version);
c47df4
 
c47df4
 #if defined(HAVE_DLADDR)
c47df4
   /* It would be nice to print the version of VDDK from the shared
c47df4
-- 
c47df4
2.31.1
c47df4