]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemublocktest: Iterate all nodenames in 'testQemuDetectBitmaps'
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jan 2026 21:49:09 +0000 (22:49 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Feb 2026 14:34:52 +0000 (15:34 +0100)
Rather than looking for 30 specific nodenames (via a loop) iterate
everything in the hash table (in a sorted order). This simplifies the
code and provides more test outputs on previously-ignored nodenames.

The listing of internal snapshots in the output was also missing a
newline, which would now cause problems with multiple images reproted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemublocktest.c
tests/qemublocktestdata/bitmap/basic.out
tests/qemublocktestdata/bitmap/empty.out
tests/qemublocktestdata/bitmap/snapshots-internal.out
tests/qemublocktestdata/bitmap/snapshots.out
tests/qemublocktestdata/bitmap/synthetic.out

index 47746207ccc6de729b685c2e2f732d117727e7b9..51d9268cdda1db83d09183ab2187e1f66f6e16fc 100644 (file)
@@ -575,17 +575,15 @@ testQemuImageCreate(const void *opaque)
 
 static const char *bitmapDetectPrefix = "qemublocktestdata/bitmap/";
 
-static void
-testQemuDetectBitmapsWorker(GHashTable *nodedata,
+static int
+testQemuDetectBitmapsWorker(void *payload,
                             const char *nodename,
-                            virBuffer *buf)
+                            void *opaque)
 {
-    qemuBlockNamedNodeData *data;
+    qemuBlockNamedNodeData *data = payload;
+    virBuffer *buf = opaque;
     size_t i;
 
-    if (!(data = virHashLookup(nodedata, nodename)))
-        return;
-
     virBufferAsprintf(buf, "%s:\n", nodename);
     if (data->qcow2v2)
         virBufferAddLit(buf, " qcow2 v2\n");
@@ -617,9 +615,12 @@ testQemuDetectBitmapsWorker(GHashTable *nodedata,
 
             virBufferAsprintf(buf, " '%s'%s", (const char *) n->key, vms);
         }
+
+        virBufferAddLit(buf, "\n");
     }
 
     virBufferAdjustIndent(buf, -1);
+    return 0;
 }
 
 
@@ -632,7 +633,6 @@ testQemuDetectBitmaps(const void *opaque)
     g_autofree char *actual = NULL;
     g_autofree char *expectpath = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    size_t i;
 
     expectpath = g_strdup_printf("%s/%s%s.out", abs_srcdir,
                                  bitmapDetectPrefix, name);
@@ -646,13 +646,7 @@ testQemuDetectBitmaps(const void *opaque)
         return -1;
     }
 
-    /* we detect for the first 30 nodenames for simplicity */
-    for (i = 0; i < 30; i++) {
-        g_autofree char *nodename = g_strdup_printf("libvirt-%zu-format", i);
-
-        testQemuDetectBitmapsWorker(nodedata, nodename, &buf);
-    }
-
+    virHashForEachSorted(nodedata, testQemuDetectBitmapsWorker, &buf);
     actual = virBufferContentAndReset(&buf);
 
     return virTestCompareToFile(actual, expectpath);
index 5c4c35b3f0deeabdb6f5c5171ec12fb37c5d2eb9..b96ffe3d39b8f550f6cd2663eab2720e22350e26 100644 (file)
@@ -4,3 +4,4 @@ libvirt-1-format:
         c: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         b: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-1-storage:
index 3787cbd354ade16ecdeb3299371ae469eda8729a..c9a5be4f076c457be1242cbed554fb0b131c8986 100644 (file)
@@ -1 +1,2 @@
 libvirt-1-format:
+libvirt-1-storage:
index dbb3cfded4729403bc906b604ddddc0ceaec5378..cf7bde96a54082c4cde71d7561bee9cd79445037 100644 (file)
@@ -1,2 +1,9 @@
 libvirt-1-format:
  internal snapshots: '1727868651'(*) '1727872064'(*)
+libvirt-1-storage:
+libvirt-2-storage:
+libvirt-pflash0-format:
+libvirt-pflash0-storage:
+libvirt-pflash1-format:
+ internal snapshots: '1727868651' '1727872064'
+libvirt-pflash1-storage:
index 24ca27e4d86bf5b872a7155267b5d15f70f632f0..29c586be7e0e73f01bbb426a39e58b6d0f657365 100644 (file)
@@ -4,16 +4,21 @@ libvirt-1-format:
         b: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         c: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
   current: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-1-storage:
 libvirt-2-format:
         c: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         b: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         d: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-2-storage:
 libvirt-3-format:
         a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         b: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         c: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-3-storage:
 libvirt-4-format:
         a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-4-storage:
 libvirt-5-format:
         a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-5-storage:
index 45423903a05dfd1f9719469a5c2d0318e455df1b..2f4ae2b217675601207718d8314774a5a84b29ed 100644 (file)
@@ -6,12 +6,17 @@ libvirt-1-format:
  top-inactive: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
  top-transient: record:1 busy:0 persist:0 inconsist:0 gran:65536 dirty:0
  top-transient-inactive: record:0 busy:0 persist:0 inconsist:0 gran:65536 dirty:0
+libvirt-1-storage:
 libvirt-2-format:
         d: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-2-storage:
 libvirt-3-format:
         b: record:1 busy:0 persist:0 inconsist:0 gran:65536 dirty:0
         c: record:0 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
         d: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-3-storage:
 libvirt-4-format:
+libvirt-4-storage:
 libvirt-5-format:
         a: record:1 busy:0 persist:1 inconsist:0 gran:65536 dirty:0
+libvirt-5-storage: