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