[libvirt] [PATCH] tests: Fix qemucapsprobemock linking

Martin Kletzander posted 1 patch 5 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/f4097bece110545c3ff2aea482c51180dfd55328.1525986010.git.mkletzan@redhat.com
Test syntax-check passed
tests/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] tests: Fix qemucapsprobemock linking
Posted by Martin Kletzander 5 years, 11 months ago
Add libvirt.la into qemucapsprobemock_la_LIBADD because that mock uses bunch of
libvirt internal functions.  Without this patch the following error occurs:

  $ ./qemucapsprobe /usr/bin/qemu-system-x86_64
  ...
  warning : virQEMUCapsLogProbeFailure:4204 : Failed to probe capabilities for
  /usr/bin/qemu-system-x86_64: internal error: Failed to probe QEMU binary with
  QMP: /usr/bin/qemu-system-x86_64: symbol lookup error:
  .../qemucapsprobemock.so: undefined symbol: virJSONValueObjectHasKey

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---

TBH I didn't go into details why this is needed.  It still seems fishy to me.
Not only that I get that error above as a libvirt error, but if i add just
libvirt_util.la in there, I get:

  .../qemucapsprobe: symbol lookup error: .../qemucapsprobemock.so:
  undefined symbol: libvirt_event_poll_update_handle_semaphore

If anyone has a better idea how this should be fixed, please suggest that.

 tests/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 05db6b1192a4..24ea41f5176c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -619,7 +619,7 @@ qemucapsprobe_LDADD = \
 qemucapsprobemock_la_SOURCES = \
 	qemucapsprobemock.c
 qemucapsprobemock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
-qemucapsprobemock_la_LIBADD = $(MOCKLIBS_LIBS)
+qemucapsprobemock_la_LIBADD = $(MOCKLIBS_LIBS) ../src/libvirt.la
 
 qemucommandutiltest_SOURCES = \
 	qemucommandutiltest.c \
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: Fix qemucapsprobemock linking
Posted by Michal Privoznik 5 years, 11 months ago
On 05/10/2018 11:13 PM, Martin Kletzander wrote:
> Add libvirt.la into qemucapsprobemock_la_LIBADD because that mock uses bunch of
> libvirt internal functions.  Without this patch the following error occurs:
> 
>   $ ./qemucapsprobe /usr/bin/qemu-system-x86_64
>   ...
>   warning : virQEMUCapsLogProbeFailure:4204 : Failed to probe capabilities for
>   /usr/bin/qemu-system-x86_64: internal error: Failed to probe QEMU binary with
>   QMP: /usr/bin/qemu-system-x86_64: symbol lookup error:
>   .../qemucapsprobemock.so: undefined symbol: virJSONValueObjectHasKey
> 
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
> 
> TBH I didn't go into details why this is needed.  It still seems fishy to me.
> Not only that I get that error above as a libvirt error, but if i add just
> libvirt_util.la in there, I get:
> 
>   .../qemucapsprobe: symbol lookup error: .../qemucapsprobemock.so:
>   undefined symbol: libvirt_event_poll_update_handle_semaphore

This is because libvirt_utils is built WITH_DTRACE_PROBES enabled.
Therefore it requires libvirt_probes.lo. So adding these two should be
enough.

However, I'm unable to reproduce this. But what I am able to reproduce is:

  libvirt.git/tests $ ../run valgrind --trace-children=yes ./qemuxml2argvtest

  Missing symbol 'virFileCanonicalizePath'
  Aborted (core dumped)

This points to merely the same problem. In our mocks we are/want to use
our internal APIs. Therefore instead of relying on program that links
with the mock at runtime (VIR_TEST_MAIN_PRELOAD macro) being already
linked with libvirt.so I think we should link our mocks with it:

diff --git i/tests/Makefile.am w/tests/Makefile.am
index 621480dd0c..ac92190845 100644
--- i/tests/Makefile.am
+++ w/tests/Makefile.am
@@ -81,7 +81,8 @@ LDADDS = \
        ../src/libvirt.la
 
 MOCKLIBS_LIBS = \
-       $(GNULIB_LIBS)
+       $(GNULIB_LIBS) \
+       ../src/libvirt.la
 
 EXTRA_DIST = \
        .valgrind.supp \

Michal


P.S. This opened a pandora box for me when I tried running qemucapsprobe
over the latest qemu compiled from git only to find that qemu has a
regression when it does not accept -no-user-config on the command line
anymore. Patch proposed upstream (link not yet available because their
list is very slow).

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list