|
|
a41c76 |
From 2de41b514449c5ab85a7a0943456a44909122874 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <2de41b514449c5ab85a7a0943456a44909122874@dist-git>
|
|
|
a41c76 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Date: Tue, 4 Feb 2020 15:07:57 +0100
|
|
|
a41c76 |
Subject: [PATCH] qemu: checkpoint: Extract calculation of bitmap merging for
|
|
|
a41c76 |
checkpoint deletion
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
This will allow some testing before refactoring.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit d9dfc1f7de2e54c015504e0a0370e8a89b5e971a)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
|
|
|
a41c76 |
Message-Id: <2b3c69597aa8f99af55e30f71d4496b6ae620d31.1580824112.git.pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/qemu/qemu_checkpoint.c | 72 ++++++++++++++++++++++++--------------
|
|
|
a41c76 |
src/qemu/qemu_checkpoint.h | 7 ++++
|
|
|
a41c76 |
2 files changed, 53 insertions(+), 26 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
|
|
|
a41c76 |
index 1100f6e744..e75cdd0458 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_checkpoint.c
|
|
|
a41c76 |
+++ b/src/qemu/qemu_checkpoint.c
|
|
|
a41c76 |
@@ -148,6 +148,46 @@ qemuCheckpointFindActiveDiskInParent(virDomainObjPtr vm,
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
+int
|
|
|
a41c76 |
+qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src,
|
|
|
a41c76 |
+ const char *delbitmap,
|
|
|
a41c76 |
+ const char *parentbitmap,
|
|
|
a41c76 |
+ bool chkcurrent,
|
|
|
a41c76 |
+ virJSONValuePtr actions)
|
|
|
a41c76 |
+{
|
|
|
a41c76 |
+ if (parentbitmap) {
|
|
|
a41c76 |
+ g_autoptr(virJSONValue) arr = NULL;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (!(arr = virJSONValueNewArray()))
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr,
|
|
|
a41c76 |
+ src->nodeformat,
|
|
|
a41c76 |
+ delbitmap) < 0)
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (chkcurrent) {
|
|
|
a41c76 |
+ if (qemuMonitorTransactionBitmapEnable(actions,
|
|
|
a41c76 |
+ src->nodeformat,
|
|
|
a41c76 |
+ parentbitmap) < 0)
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (qemuMonitorTransactionBitmapMerge(actions,
|
|
|
a41c76 |
+ src->nodeformat,
|
|
|
a41c76 |
+ parentbitmap, &arr) < 0)
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (qemuMonitorTransactionBitmapRemove(actions,
|
|
|
a41c76 |
+ src->nodeformat,
|
|
|
a41c76 |
+ delbitmap) < 0)
|
|
|
a41c76 |
+ return -1;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ return 0;
|
|
|
a41c76 |
+}
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+
|
|
|
a41c76 |
static int
|
|
|
a41c76 |
qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
|
|
|
a41c76 |
virDomainCheckpointDefPtr chkdef,
|
|
|
a41c76 |
@@ -167,6 +207,7 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
|
|
|
a41c76 |
virDomainCheckpointDiskDef *chkdisk = &chkdef->disks[i];
|
|
|
a41c76 |
virDomainDiskDefPtr domdisk = virDomainDiskByTarget(vm->def, chkdisk->name);
|
|
|
a41c76 |
virDomainCheckpointDiskDef *parentchkdisk = NULL;
|
|
|
a41c76 |
+ const char *parentbitmap = NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
/* domdisk can be missing e.g. when it was unplugged */
|
|
|
a41c76 |
if (!domdisk)
|
|
|
a41c76 |
@@ -178,33 +219,12 @@ qemuCheckpointDiscardBitmaps(virDomainObjPtr vm,
|
|
|
a41c76 |
/* If any ancestor checkpoint has a bitmap for the same
|
|
|
a41c76 |
* disk, then this bitmap must be merged to the
|
|
|
a41c76 |
* ancestor. */
|
|
|
a41c76 |
- if ((parentchkdisk = qemuCheckpointFindActiveDiskInParent(vm, parent, chkdisk->name))) {
|
|
|
a41c76 |
- g_autoptr(virJSONValue) arr = NULL;
|
|
|
a41c76 |
+ if ((parentchkdisk = qemuCheckpointFindActiveDiskInParent(vm, parent,
|
|
|
a41c76 |
+ chkdisk->name)))
|
|
|
a41c76 |
+ parentbitmap = parentchkdisk->name;
|
|
|
a41c76 |
|
|
|
a41c76 |
- if (!(arr = virJSONValueNewArray()))
|
|
|
a41c76 |
- return -1;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(arr,
|
|
|
a41c76 |
- domdisk->src->nodeformat,
|
|
|
a41c76 |
- chkdisk->bitmap) < 0)
|
|
|
a41c76 |
- return -1;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- if (chkcurrent) {
|
|
|
a41c76 |
- if (qemuMonitorTransactionBitmapEnable(actions,
|
|
|
a41c76 |
- domdisk->src->nodeformat,
|
|
|
a41c76 |
- parentchkdisk->bitmap) < 0)
|
|
|
a41c76 |
- return -1;
|
|
|
a41c76 |
- }
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- if (qemuMonitorTransactionBitmapMerge(actions,
|
|
|
a41c76 |
- domdisk->src->nodeformat,
|
|
|
a41c76 |
- parentchkdisk->bitmap, &arr) < 0)
|
|
|
a41c76 |
- return -1;
|
|
|
a41c76 |
- }
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- if (qemuMonitorTransactionBitmapRemove(actions,
|
|
|
a41c76 |
- domdisk->src->nodeformat,
|
|
|
a41c76 |
- chkdisk->bitmap) < 0)
|
|
|
a41c76 |
+ if (qemuCheckpointDiscardDiskBitmaps(domdisk->src, chkdisk->bitmap,
|
|
|
a41c76 |
+ parentbitmap, chkcurrent, actions) < 0)
|
|
|
a41c76 |
return -1;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h
|
|
|
a41c76 |
index eb85611ea6..85fd453d50 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_checkpoint.h
|
|
|
a41c76 |
+++ b/src/qemu/qemu_checkpoint.h
|
|
|
a41c76 |
@@ -71,3 +71,10 @@ qemuCheckpointCreateFinalize(virQEMUDriverPtr driver,
|
|
|
a41c76 |
void
|
|
|
a41c76 |
qemuCheckpointRollbackMetadata(virDomainObjPtr vm,
|
|
|
a41c76 |
virDomainMomentObjPtr chk);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+int
|
|
|
a41c76 |
+qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src,
|
|
|
a41c76 |
+ const char *delbitmap,
|
|
|
a41c76 |
+ const char *parentbitmap,
|
|
|
a41c76 |
+ bool chkcurrent,
|
|
|
a41c76 |
+ virJSONValuePtr actions);
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.25.0
|
|
|
a41c76 |
|