[PATCH 01/13] domaincapsmock: Drop link time dependency on virQEMUCapsGet()

Michal Privoznik posted 13 patches 1 year, 9 months ago
There is a newer version of this series
[PATCH 01/13] domaincapsmock: Drop link time dependency on virQEMUCapsGet()
Posted by Michal Privoznik 1 year, 9 months ago
While Linux linker has no trouble resolving the symbols, valgrind
does. It has probably something to do with the fact that we don't
tell what symbols to export from mock libraries. Anyway, just
resolve the symbol at runtime.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/domaincapsmock.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c
index 6ae0c4ad45..73ff992ebd 100644
--- a/tests/domaincapsmock.c
+++ b/tests/domaincapsmock.c
@@ -49,16 +49,19 @@ virHostCPUGetPhysAddrSize(const virArch hostArch,
 
 #if WITH_QEMU
 static bool (*real_virQEMUCapsGetKVMSupportsSecureGuest)(virQEMUCaps *qemuCaps);
+static bool (*real_virQEMUCapsGet)(virQEMUCaps *qemuCaps, virQEMUCapsFlags flag);
 
 bool
 virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps)
 {
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT) &&
-        virQEMUCapsGet(qemuCaps, QEMU_CAPS_S390_PV_GUEST))
-        return true;
-
-    if (!real_virQEMUCapsGetKVMSupportsSecureGuest)
+    if (!real_virQEMUCapsGet) {
+        VIR_MOCK_REAL_INIT(virQEMUCapsGet);
         VIR_MOCK_REAL_INIT(virQEMUCapsGetKVMSupportsSecureGuest);
+    }
+
+    if (real_virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT) &&
+        real_virQEMUCapsGet(qemuCaps, QEMU_CAPS_S390_PV_GUEST))
+        return true;
 
     return real_virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps);
 }
-- 
2.43.2
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 01/13] domaincapsmock: Drop link time dependency on virQEMUCapsGet()
Posted by Daniel P. Berrangé 1 year, 9 months ago
On Mon, May 06, 2024 at 10:42:58AM +0200, Michal Privoznik wrote:
> While Linux linker has no trouble resolving the symbols, valgrind
> does. It has probably something to do with the fact that we don't
> tell what symbols to export from mock libraries. Anyway, just
> resolve the symbol at runtime.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tests/domaincapsmock.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org