fbe740
From 8528b76210e54f664f2098e0127dac811f12800a Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <8528b76210e54f664f2098e0127dac811f12800a@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Tue, 23 Jun 2020 12:23:59 +0200
fbe740
Subject: [PATCH] qemublocktest: Add 'snapshots' tests for backup bitmap
fbe740
 handling
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
The 'snapshots' case has multiple layers so we need to make sure that
fbe740
the bitmaps are merged with the appropriate temporary bitmaps formatted
fbe740
from the allocation bitmap for any backing chain layer above.
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Eric Blake <eblake@redhat.com>
fbe740
(cherry picked from commit b630cf4c0d8446a301fd23e87c9e8d60d547b5e8)
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
fbe740
Message-Id: <3ef354322f829f47c91738060dd6557462e6d6d5.1592906423.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 tests/qemublocktest.c                         |  4 ++
fbe740
 .../backupmerge/snapshots-deep-out.json       | 41 +++++++++++++++++++
fbe740
 .../backupmerge/snapshots-flat-out.json       | 25 +++++++++++
fbe740
 .../snapshots-intermediate-out.json           | 29 +++++++++++++
fbe740
 4 files changed, 99 insertions(+)
fbe740
 create mode 100644 tests/qemublocktestdata/backupmerge/snapshots-deep-out.json
fbe740
 create mode 100644 tests/qemublocktestdata/backupmerge/snapshots-flat-out.json
fbe740
 create mode 100644 tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json
fbe740
fbe740
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
fbe740
index 7a0159f659..8ce878f15b 100644
fbe740
--- a/tests/qemublocktest.c
fbe740
+++ b/tests/qemublocktest.c
fbe740
@@ -1266,6 +1266,10 @@ mymain(void)
fbe740
     TEST_BACKUP_BITMAP_CALCULATE("basic-intermediate", bitmapSourceChain, "d", "basic");
fbe740
     TEST_BACKUP_BITMAP_CALCULATE("basic-deep", bitmapSourceChain, "a", "basic");
fbe740
 
fbe740
+    TEST_BACKUP_BITMAP_CALCULATE("snapshots-flat", bitmapSourceChain, "current", "snapshots");
fbe740
+    TEST_BACKUP_BITMAP_CALCULATE("snapshots-intermediate", bitmapSourceChain, "d", "snapshots");
fbe740
+    TEST_BACKUP_BITMAP_CALCULATE("snapshots-deep", bitmapSourceChain, "a", "snapshots");
fbe740
+
fbe740
 #define TEST_CHECKPOINT_DELETE(testname, delbmp, named) \
fbe740
     do { \
fbe740
         checkpointdeletedata.name = testname; \
fbe740
diff --git a/tests/qemublocktestdata/backupmerge/snapshots-deep-out.json b/tests/qemublocktestdata/backupmerge/snapshots-deep-out.json
fbe740
new file mode 100644
fbe740
index 0000000000..d678507b85
fbe740
--- /dev/null
fbe740
+++ b/tests/qemublocktestdata/backupmerge/snapshots-deep-out.json
fbe740
@@ -0,0 +1,41 @@
fbe740
+[
fbe740
+  {
fbe740
+    "type": "block-dirty-bitmap-add",
fbe740
+    "data": {
fbe740
+      "node": "target_node",
fbe740
+      "name": "target-bitmap-name",
fbe740
+      "persistent": false,
fbe740
+      "disabled": true,
fbe740
+      "granularity": 65536
fbe740
+    }
fbe740
+  },
fbe740
+  {
fbe740
+    "type": "block-dirty-bitmap-merge",
fbe740
+    "data": {
fbe740
+      "node": "target_node",
fbe740
+      "target": "target-bitmap-name",
fbe740
+      "bitmaps": [
fbe740
+        {
fbe740
+          "node": "libvirt-1-format",
fbe740
+          "name": "a"
fbe740
+        },
fbe740
+        {
fbe740
+          "node": "libvirt-2-format",
fbe740
+          "name": "a"
fbe740
+        },
fbe740
+        {
fbe740
+          "node": "libvirt-3-format",
fbe740
+          "name": "a"
fbe740
+        },
fbe740
+        {
fbe740
+          "node": "libvirt-4-format",
fbe740
+          "name": "a"
fbe740
+        },
fbe740
+        {
fbe740
+          "node": "libvirt-5-format",
fbe740
+          "name": "a"
fbe740
+        }
fbe740
+      ]
fbe740
+    }
fbe740
+  }
fbe740
+]
fbe740
diff --git a/tests/qemublocktestdata/backupmerge/snapshots-flat-out.json b/tests/qemublocktestdata/backupmerge/snapshots-flat-out.json
fbe740
new file mode 100644
fbe740
index 0000000000..4637bbc377
fbe740
--- /dev/null
fbe740
+++ b/tests/qemublocktestdata/backupmerge/snapshots-flat-out.json
fbe740
@@ -0,0 +1,25 @@
fbe740
+[
fbe740
+  {
fbe740
+    "type": "block-dirty-bitmap-add",
fbe740
+    "data": {
fbe740
+      "node": "target_node",
fbe740
+      "name": "target-bitmap-name",
fbe740
+      "persistent": false,
fbe740
+      "disabled": true,
fbe740
+      "granularity": 65536
fbe740
+    }
fbe740
+  },
fbe740
+  {
fbe740
+    "type": "block-dirty-bitmap-merge",
fbe740
+    "data": {
fbe740
+      "node": "target_node",
fbe740
+      "target": "target-bitmap-name",
fbe740
+      "bitmaps": [
fbe740
+        {
fbe740
+          "node": "libvirt-1-format",
fbe740
+          "name": "current"
fbe740
+        }
fbe740
+      ]
fbe740
+    }
fbe740
+  }
fbe740
+]
fbe740
diff --git a/tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json b/tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json
fbe740
new file mode 100644
fbe740
index 0000000000..30d8bcd8b7
fbe740
--- /dev/null
fbe740
+++ b/tests/qemublocktestdata/backupmerge/snapshots-intermediate-out.json
fbe740
@@ -0,0 +1,29 @@
fbe740
+[
fbe740
+  {
fbe740
+    "type": "block-dirty-bitmap-add",
fbe740
+    "data": {
fbe740
+      "node": "target_node",
fbe740
+      "name": "target-bitmap-name",
fbe740
+      "persistent": false,
fbe740
+      "disabled": true,
fbe740
+      "granularity": 65536
fbe740
+    }
fbe740
+  },
fbe740
+  {
fbe740
+    "type": "block-dirty-bitmap-merge",
fbe740
+    "data": {
fbe740
+      "node": "target_node",
fbe740
+      "target": "target-bitmap-name",
fbe740
+      "bitmaps": [
fbe740
+        {
fbe740
+          "node": "libvirt-1-format",
fbe740
+          "name": "d"
fbe740
+        },
fbe740
+        {
fbe740
+          "node": "libvirt-2-format",
fbe740
+          "name": "d"
fbe740
+        }
fbe740
+      ]
fbe740
+    }
fbe740
+  }
fbe740
+]
fbe740
-- 
fbe740
2.27.0
fbe740