render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 25790c1e38a02e16182bb8c708af656f82db950a Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <25790c1e38a02e16182bb8c708af656f82db950a@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 23 Jun 2020 12:23:46 +0200
a41c76
Subject: [PATCH] qemublocktest: Extract printing of nodename list
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
There will be multiple places where we'll need to print nodenames from a
a41c76
GSList of virStorageSource for testing purposes. Extract the code into a
a41c76
function.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit 69cacbe5061a82d3207df113d5c845f38f3decca)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
a41c76
Message-Id: <6f3b4a3424a76d6fe788545b0ddffd3cbb372623.1592906423.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 tests/qemublocktest.c | 27 ++++++++++++++++++---------
a41c76
 1 file changed, 18 insertions(+), 9 deletions(-)
a41c76
a41c76
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
a41c76
index 75527ca64b..9d6d871be8 100644
a41c76
--- a/tests/qemublocktest.c
a41c76
+++ b/tests/qemublocktest.c
a41c76
@@ -647,6 +647,23 @@ testQemuDetectBitmaps(const void *opaque)
a41c76
 }
a41c76
 
a41c76
 
a41c76
+static void
a41c76
+testQemuBitmapListPrint(const char *title,
a41c76
+                        GSList *next,
a41c76
+                        virBufferPtr buf)
a41c76
+{
a41c76
+    if (!next)
a41c76
+        return;
a41c76
+
a41c76
+    virBufferAsprintf(buf, "%s\n", title);
a41c76
+
a41c76
+    for (; next; next = next->next) {
a41c76
+        virStorageSourcePtr src = next->data;
a41c76
+        virBufferAsprintf(buf, "%s\n", src->nodeformat);
a41c76
+    }
a41c76
+}
a41c76
+
a41c76
+
a41c76
 static virStorageSourcePtr
a41c76
 testQemuBackupIncrementalBitmapCalculateGetFakeImage(size_t idx)
a41c76
 {
a41c76
@@ -829,7 +846,6 @@ testQemuCheckpointDeleteMerge(const void *opaque)
a41c76
     g_autoptr(virHashTable) nodedata = NULL;
a41c76
     g_autoptr(GSList) reopenimages = NULL;
a41c76
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
a41c76
-    GSList *tmp;
a41c76
 
a41c76
     expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
a41c76
                                  checkpointDeletePrefix, data->name);
a41c76
@@ -858,14 +874,7 @@ testQemuCheckpointDeleteMerge(const void *opaque)
a41c76
         virBufferAddLit(&buf, "NULL\n");
a41c76
     }
a41c76
 
a41c76
-    if (reopenimages) {
a41c76
-        virBufferAddLit(&buf, "reopen nodes:\n");
a41c76
-
a41c76
-        for (tmp = reopenimages; tmp; tmp = tmp->next) {
a41c76
-            virStorageSourcePtr src = tmp->data;
a41c76
-            virBufferAsprintf(&buf, "%s\n", src->nodeformat);
a41c76
-        }
a41c76
-    }
a41c76
+    testQemuBitmapListPrint("reopen nodes:", reopenimages, &buf;;
a41c76
 
a41c76
     actual = virBufferContentAndReset(&buf;;
a41c76
 
a41c76
-- 
a41c76
2.27.0
a41c76