|
|
d76c62 |
From c71d50132b3ac8dcfefc1acc11ab5d5bd7bc024a Mon Sep 17 00:00:00 2001
|
|
|
d76c62 |
Message-Id: <c71d50132b3ac8dcfefc1acc11ab5d5bd7bc024a@dist-git>
|
|
|
d76c62 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Date: Tue, 4 Feb 2020 15:08:09 +0100
|
|
|
d76c62 |
Subject: [PATCH] tests: qemublock: Add test for checkpoint deletion bitmap
|
|
|
d76c62 |
merge
|
|
|
d76c62 |
MIME-Version: 1.0
|
|
|
d76c62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d76c62 |
Content-Transfer-Encoding: 8bit
|
|
|
d76c62 |
|
|
|
d76c62 |
Add test infrastructure and a basic test for bitmap deletion.
|
|
|
d76c62 |
|
|
|
d76c62 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
(cherry picked from commit 25f74899720afce52dcf01f230da5c816deaea71)
|
|
|
d76c62 |
|
|
|
d76c62 |
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
|
|
|
d76c62 |
Message-Id: <50b8789a34b762114b6ea2f87bba1a130be206de.1580824112.git.pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
---
|
|
|
d76c62 |
tests/qemublocktest.c | 59 +++++++++++++++++++
|
|
|
d76c62 |
.../checkpointdelete/basic-noparent-out.json | 9 +++
|
|
|
d76c62 |
2 files changed, 68 insertions(+)
|
|
|
d76c62 |
create mode 100644 tests/qemublocktestdata/checkpointdelete/basic-noparent-out.json
|
|
|
d76c62 |
|
|
|
d76c62 |
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
|
|
|
d76c62 |
index 7ff6a6b17b..80355d1340 100644
|
|
|
d76c62 |
--- a/tests/qemublocktest.c
|
|
|
d76c62 |
+++ b/tests/qemublocktest.c
|
|
|
d76c62 |
@@ -27,6 +27,7 @@
|
|
|
d76c62 |
#include "qemu/qemu_qapi.h"
|
|
|
d76c62 |
#include "qemu/qemu_monitor_json.h"
|
|
|
d76c62 |
#include "qemu/qemu_backup.h"
|
|
|
d76c62 |
+#include "qemu/qemu_checkpoint.h"
|
|
|
d76c62 |
|
|
|
d76c62 |
#include "qemu/qemu_command.h"
|
|
|
d76c62 |
|
|
|
d76c62 |
@@ -696,6 +697,50 @@ testQemuBackupIncrementalBitmapCalculate(const void *opaque)
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
|
|
|
d76c62 |
+static const char *checkpointDeletePrefix = "qemublocktestdata/checkpointdelete/";
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+struct testQemuCheckpointDeleteMergeData {
|
|
|
d76c62 |
+ const char *name;
|
|
|
d76c62 |
+ virStorageSourcePtr chain;
|
|
|
d76c62 |
+ const char *deletebitmap;
|
|
|
d76c62 |
+ const char *parentbitmap;
|
|
|
d76c62 |
+};
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+static int
|
|
|
d76c62 |
+testQemuCheckpointDeleteMerge(const void *opaque)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ const struct testQemuCheckpointDeleteMergeData *data = opaque;
|
|
|
d76c62 |
+ g_autofree char *actual = NULL;
|
|
|
d76c62 |
+ g_autofree char *expectpath = NULL;
|
|
|
d76c62 |
+ g_autoptr(virJSONValue) actions = NULL;
|
|
|
d76c62 |
+ bool currentcheckpoint;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
|
|
|
d76c62 |
+ checkpointDeletePrefix, data->name);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (!(actions = virJSONValueNewArray()))
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ /* hack to get the 'current' state until the function stops accepting it */
|
|
|
d76c62 |
+ currentcheckpoint = STREQ("current", data->deletebitmap);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (qemuCheckpointDiscardDiskBitmaps(data->chain,
|
|
|
d76c62 |
+ data->deletebitmap,
|
|
|
d76c62 |
+ data->parentbitmap,
|
|
|
d76c62 |
+ currentcheckpoint,
|
|
|
d76c62 |
+ actions) < 0) {
|
|
|
d76c62 |
+ VIR_TEST_VERBOSE("failed to generate checkpoint delete transaction\n");
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (!(actual = virJSONValueToString(actions, true)))
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ return virTestCompareToFile(actual, expectpath);
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
static int
|
|
|
d76c62 |
mymain(void)
|
|
|
d76c62 |
{
|
|
|
d76c62 |
@@ -705,6 +750,7 @@ mymain(void)
|
|
|
d76c62 |
struct testQemuDiskXMLToJSONData diskxmljsondata;
|
|
|
d76c62 |
struct testQemuImageCreateData imagecreatedata;
|
|
|
d76c62 |
struct testQemuBackupIncrementalBitmapCalculateData backupbitmapcalcdata;
|
|
|
d76c62 |
+ struct testQemuCheckpointDeleteMergeData checkpointdeletedata;
|
|
|
d76c62 |
char *capslatest_x86_64 = NULL;
|
|
|
d76c62 |
virQEMUCapsPtr caps_x86_64 = NULL;
|
|
|
d76c62 |
g_autoptr(virStorageSource) bitmapSourceChain = NULL;
|
|
|
d76c62 |
@@ -941,6 +987,19 @@ mymain(void)
|
|
|
d76c62 |
TEST_BACKUP_BITMAP_CALCULATE("snapshot-intermediate", bitmapSourceChain, "d", "snapshots");
|
|
|
d76c62 |
TEST_BACKUP_BITMAP_CALCULATE("snapshot-deep", bitmapSourceChain, "a", "snapshots");
|
|
|
d76c62 |
|
|
|
d76c62 |
+#define TEST_CHECKPOINT_DELETE_MERGE(testname, delbmp, parbmp) \
|
|
|
d76c62 |
+ do { \
|
|
|
d76c62 |
+ checkpointdeletedata.name = testname; \
|
|
|
d76c62 |
+ checkpointdeletedata.chain = bitmapSourceChain; \
|
|
|
d76c62 |
+ checkpointdeletedata.deletebitmap = delbmp; \
|
|
|
d76c62 |
+ checkpointdeletedata.parentbitmap = parbmp; \
|
|
|
d76c62 |
+ if (virTestRun("checkpoint delete " testname, \
|
|
|
d76c62 |
+ testQemuCheckpointDeleteMerge, &checkpointdeletedata) < 0) \
|
|
|
d76c62 |
+ ret = -1; \
|
|
|
d76c62 |
+ } while (0)
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ TEST_CHECKPOINT_DELETE_MERGE("basic-noparent", "a", NULL);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
cleanup:
|
|
|
d76c62 |
virHashFree(diskxmljsondata.schema);
|
|
|
d76c62 |
qemuTestDriverFree(&driver);
|
|
|
d76c62 |
diff --git a/tests/qemublocktestdata/checkpointdelete/basic-noparent-out.json b/tests/qemublocktestdata/checkpointdelete/basic-noparent-out.json
|
|
|
d76c62 |
new file mode 100644
|
|
|
d76c62 |
index 0000000000..e87382fdb4
|
|
|
d76c62 |
--- /dev/null
|
|
|
d76c62 |
+++ b/tests/qemublocktestdata/checkpointdelete/basic-noparent-out.json
|
|
|
d76c62 |
@@ -0,0 +1,9 @@
|
|
|
d76c62 |
+[
|
|
|
d76c62 |
+ {
|
|
|
d76c62 |
+ "type": "block-dirty-bitmap-remove",
|
|
|
d76c62 |
+ "data": {
|
|
|
d76c62 |
+ "node": "libvirt-1-format",
|
|
|
d76c62 |
+ "name": "a"
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+]
|
|
|
d76c62 |
--
|
|
|
d76c62 |
2.25.0
|
|
|
d76c62 |
|