[libvirt] [PATCH] tests: Fix qemucapsprobemock linking

Michal Privoznik mprivozn at redhat.com
Mon May 14 13:59:39 UTC 2018


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 at 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).




More information about the libvir-list mailing list