]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemumemlocktest: Use 'testQemuInsertRealCaps'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 3 Jul 2023 13:39:58 +0000 (15:39 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 20 Jul 2023 13:23:16 +0000 (15:23 +0200)
Rewrite the capability fetching to use the new helper, thus simplifying
the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemumemlocktest.c

index 7d219fcc40f842431436ba83f14cc93f273153dc..a2888732f75f9b04c021836df2244655b0cfdb47 100644 (file)
@@ -47,14 +47,8 @@ mymain(void)
 {
     g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps();
     g_autoptr(GHashTable) capscache = virHashNew(virObjectUnref);
-    g_autoptr(virQEMUCaps) qemuCaps_x86_64 = NULL;
-    g_autoptr(virQEMUCaps) qemuCaps_ppc64 = NULL;
     int ret = 0;
 
-    if (!(qemuCaps_x86_64 = testQemuGetRealCaps("x86_64", "latest", "", capslatest, capscache, NULL, NULL)) ||
-        !(qemuCaps_ppc64 =  testQemuGetRealCaps("ppc64", "latest", "", capslatest, capscache, NULL, NULL)))
-        return EXIT_FAILURE;
-
     if (qemuTestDriverInit(&driver) < 0)
         return EXIT_FAILURE;
 
@@ -85,11 +79,11 @@ mymain(void)
 
     qemuTestSetHostArch(&driver, VIR_ARCH_X86_64);
 
-    virFileCacheClear(driver.qemuCapsCache);
-    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, qemuCaps_x86_64) < 0) {
+    if (testQemuInsertRealCaps(driver.qemuCapsCache, "x86_64", "latest", "",
+                               capslatest, capscache, NULL, NULL) < 0) {
         ret = -1;
         goto cleanup;
-    };
+    }
 
     DO_TEST("pc-kvm", 0);
     DO_TEST("pc-tcg", 0);
@@ -105,11 +99,12 @@ mymain(void)
     DO_TEST("pc-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED);
 
     qemuTestSetHostArch(&driver, VIR_ARCH_PPC64);
-    virFileCacheClear(driver.qemuCapsCache);
-    if (qemuTestCapsCacheInsert(driver.qemuCapsCache, qemuCaps_ppc64) < 0) {
+
+    if (testQemuInsertRealCaps(driver.qemuCapsCache, "ppc64", "latest", "",
+                               capslatest, capscache, NULL, NULL) < 0) {
         ret = -1;
         goto cleanup;
-    };
+    }
 
     DO_TEST("pseries-kvm", 20971520);
     DO_TEST("pseries-tcg", 0);