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

2024-05-07 Thread Daniel P . Berrangé
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 
> ---
>  tests/domaincapsmock.c | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)

Reviewed-by: Daniel P. Berrangé 


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-le...@lists.libvirt.org


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

2024-05-06 Thread Michal Privoznik
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 
---
 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-le...@lists.libvirt.org