a41c76
From e0454c4801452c031856681c68bf5d154440bbb0 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <e0454c4801452c031856681c68bf5d154440bbb0@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:09 +0100
a41c76
Subject: [PATCH] qemublocktest: Load QMP schema earlier
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Multiple tests require the schema. Extract the loading into a separate
a41c76
variable to avoid issues with ownership of the pointer.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 1262cdede447a2566b6e8cb99434b767a4ef67da)
a41c76
a41c76
 Conflicts:
a41c76
	tests/qemublocktest.c
a41c76
        QMP schema loading for non-x86_64 qemus was not backported.
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
a41c76
Message-Id: <d8a7b2d9987175b106363d781df23d313a02d870.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 tests/qemublocktest.c | 16 ++++++++++------
a41c76
 1 file changed, 10 insertions(+), 6 deletions(-)
a41c76
a41c76
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
a41c76
index 3057db6930..f805265c93 100644
a41c76
--- a/tests/qemublocktest.c
a41c76
+++ b/tests/qemublocktest.c
a41c76
@@ -863,6 +863,7 @@ mymain(void)
a41c76
     struct testQemuBlockBitmapBlockcopyData blockbitmapblockcopydata;
a41c76
     char *capslatest_x86_64 = NULL;
a41c76
     virQEMUCapsPtr caps_x86_64 = NULL;
a41c76
+    g_autoptr(virHashTable) qmp_schema_x86_64 = NULL;
a41c76
     g_autoptr(virStorageSource) bitmapSourceChain = NULL;
a41c76
 
a41c76
     if (qemuTestDriverInit(&driver) < 0)
a41c76
@@ -885,6 +886,11 @@ mymain(void)
a41c76
     diskxmljsondata.qemuCaps = caps_x86_64;
a41c76
     imagecreatedata.qemuCaps = caps_x86_64;
a41c76
 
a41c76
+    if (!(qmp_schema_x86_64 = testQEMUSchemaLoad())) {
a41c76
+        ret = -1;
a41c76
+        goto cleanup;
a41c76
+    }
a41c76
+
a41c76
     virTestCounterReset("qemu storage source xml->json->xml ");
a41c76
 
a41c76
 #define TEST_JSON_FORMAT(tpe, xmlstr) \
a41c76
@@ -983,10 +989,7 @@ mymain(void)
a41c76
 
a41c76
 #define TEST_DISK_TO_JSON(nme) TEST_DISK_TO_JSON_FULL(nme, false)
a41c76
 
a41c76
-    if (!(diskxmljsondata.schema = testQEMUSchemaLoad())) {
a41c76
-        ret = -1;
a41c76
-        goto cleanup;
a41c76
-    }
a41c76
+    diskxmljsondata.schema = qmp_schema_x86_64;
a41c76
 
a41c76
     if (virQEMUQAPISchemaPathGet("blockdev-add/arg-type",
a41c76
                                  diskxmljsondata.schema,
a41c76
@@ -1045,7 +1048,9 @@ mymain(void)
a41c76
                        &imagecreatedata) < 0) \
a41c76
             ret = -1; \
a41c76
     } while (0)
a41c76
-    imagecreatedata.schema = diskxmljsondata.schema;
a41c76
+
a41c76
+    imagecreatedata.schema = qmp_schema_x86_64;
a41c76
+
a41c76
     if (virQEMUQAPISchemaPathGet("blockdev-create/arg-type/options",
a41c76
                                  imagecreatedata.schema,
a41c76
                                  &imagecreatedata.schemaroot) < 0 ||
a41c76
@@ -1198,7 +1203,6 @@ mymain(void)
a41c76
     TEST_BITMAP_BLOCKCOPY("snapshots-deep", false, "snapshots");
a41c76
 
a41c76
  cleanup:
a41c76
-    virHashFree(diskxmljsondata.schema);
a41c76
     qemuTestDriverFree(&driver);
a41c76
     VIR_FREE(capslatest_x86_64);
a41c76
     virObjectUnref(caps_x86_64);
a41c76
-- 
a41c76
2.25.1
a41c76