[PATCH] qemuxml2argvmock: Deduplicate some code

Michal Privoznik posted 1 patch 2 years, 9 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/e35c77574e8edd2ddb67f58b580b61ad68c13459.1626960670.git.mprivozn@redhat.com
tests/qemuxml2argvmock.c | 15 ---------------
1 file changed, 15 deletions(-)
[PATCH] qemuxml2argvmock: Deduplicate some code
Posted by Michal Privoznik 2 years, 9 months ago
A stub implementation for virQEMUCapsGetKVMSupportsSecureGuest()
was added recently. However, the very same implementation was
added to domaincapsmock.c which is also loaded by
qemuxml2argvtest and thus one occurrence of the stub can be
dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/qemuxml2argvmock.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index d7f77eabf7..9235c785b2 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -302,18 +302,3 @@ virIdentityEnsureSystemToken(void)
 {
     return g_strdup("3de80bcbf22d4833897f1638e01be9b2");
 }
-
-static bool (*real_virQEMUCapsGetKVMSupportsSecureGuest)(virQEMUCaps *qemuCaps);
-
-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)
-        VIR_MOCK_REAL_INIT(virQEMUCapsGetKVMSupportsSecureGuest);
-
-    return real_virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps);
-}
-- 
2.31.1

Re: [PATCH] qemuxml2argvmock: Deduplicate some code
Posted by Jano Tomko 2 years, 9 months ago
On a %A in %Y, Michal Privoznik wrote:
> A stub implementation for virQEMUCapsGetKVMSupportsSecureGuest()
> was added recently. However, the very same implementation was
> added to domaincapsmock.c which is also loaded by
> qemuxml2argvtest and thus one occurrence of the stub can be
> dropped.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tests/qemuxml2argvmock.c | 15 ---------------
>  1 file changed, 15 deletions(-)
> 
Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano