On 12/12/19 11:18 AM, Peter Krempa wrote:
Test the extraction of data about changed block tracking bitmaps.
The
first test case adds a simple scenario of multiple bitmaps in one layer.
The test data will be also later reused for testing the code that
determines which bitmaps to merge for an incremental backup.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/qemublocktest.c | 75 ++++++++++++++
+static void
+testQemuDetectBitmapsWorker(virHashTablePtr nodedata,
+ const char *nodename,
+ virBufferPtr buf)
+{
+ qemuBlockNamedNodeDataPtr data;
+ size_t i;
+
+ if (!(data = virHashLookup(nodedata, nodename)))
+ return;
+
+ virBufferAsprintf(buf, "%s:\n", nodename);
+ virBufferAdjustIndent(buf, 1);
+
+ for (i = 0; i < data->nbitmaps; i++) {
+ qemuBlockNamedNodeDataBitmapPtr bitmap = data->bitmaps[i];
+
+ virBufferAsprintf(buf, "%8s: recod:%d busy:%d persist:%d inconist:%d
gran:%llu dirty:%llu\n",
s/recod/record/
s/inconist/inconsist/
+
+ if (!(nodedata = qemuMonitorJSONBlockGetNamedNodeDataJSON(nodedatajson))) {
+ VIR_TEST_VERBOSE("failed to load nodedata JSON\n");
Drop the \n (most VIR_TEST_VERBOSE() does not use it)
+++ b/tests/qemublocktestdata/bitmap/basic.json
@@ -0,0 +1,117 @@
+[
+ {
+ "iops_rd": 0,
+ "detect_zeroes": "off",
+ "image": {
+ "virtual-size": 10485760,
+ "filename": "/tmp/pull4.qcow2",
It might be fun to record in the commit message how you created this
temp file. But not strictly necessary.
+++ b/tests/qemublocktestdata/bitmap/basic.out
@@ -0,0 +1,6 @@
+libvirt-1-format:
+ current: recod:1 busy:0 persist:1 inconist:0 gran:65536 dirty:0
+ d: recod:0 busy:0 persist:1 inconist:0 gran:65536 dirty:0
+ c: recod:0 busy:0 persist:1 inconist:0 gran:65536 dirty:0
+ b: recod:0 busy:0 persist:1 inconist:0 gran:65536 dirty:0
+ a: recod:0 busy:0 persist:1 inconist:0 gran:65536 dirty:0
Fallout here when you fix the earlier output line.
With typos fixed,
Reviewed-by: Eric Blake <eblake(a)redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org