libvirt/SOURCES/libvirt-qemuBlockBitmapChainIsValid-Adjust-to-new-semantics-of-bitmaps.patch
2021-10-08 13:11:20 +00:00

96 lines
3.2 KiB
Diff

From 4fcacae366ef35c336a6b9b0ff35cdf0a3c80760 Mon Sep 17 00:00:00 2001
Message-Id: <4fcacae366ef35c336a6b9b0ff35cdf0a3c80760@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 23 Jun 2020 12:23:50 +0200
Subject: [PATCH] qemuBlockBitmapChainIsValid: Adjust to new semantics of
bitmaps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reject duplicates and other problematic bitmaps according to the new
semantics of bitmap use in libvirt.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 3857b073cb3a44c6a54e040f395ed58531f16634)
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
Message-Id: <a35c63c398ab7fa25758567ec73228c97ba1fe6f.1592906423.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_block.c | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index a44774c237..38c8269721 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2835,41 +2835,49 @@ qemuBlockGetNamedNodeData(virDomainObjPtr vm,
/**
* qemuBlockBitmapChainIsValid:
*
- * Validates that the backing chain of @src contains proper consistent bitmap
- * data for a chain of bitmaps named @bitmapname.
+ * Validates that the backing chain of @src contains bitmaps which libvirt will
+ * consider as properly corresponding to a checkpoint named @bitmapname.
*
- * A valid chain:
- * 1) bitmaps of same name are in a consecutive subset of images without gap
- * 2) don't have any inconsistent bitmaps
+ * The bitmaps need to:
+ * 1) start from the top image @src
+ * 2) must be present in consecutive layers
+ * 3) all must be active, persistent and not inconsistent
*/
bool
qemuBlockBitmapChainIsValid(virStorageSourcePtr src,
const char *bitmapname,
virHashTablePtr blockNamedNodeData)
{
- qemuBlockNamedNodeDataBitmapPtr bitmap;
virStorageSourcePtr n;
- bool chain_started = false;
+ bool found = false;
bool chain_ended = false;
- for (n = src; n; n = n->backingStore) {
- if (!(bitmap = qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData, n, bitmapname))) {
- if (chain_started)
- chain_ended = true;
+ for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
+ qemuBlockNamedNodeDataBitmapPtr bitmap;
+
+ if (!(bitmap = qemuBlockNamedNodeDataGetBitmapByName(blockNamedNodeData,
+ n, bitmapname))) {
+ /* rule 1, must start from top */
+ if (!found)
+ return false;
+
+ chain_ended = true;
continue;
}
+ /* rule 2, no-gaps */
if (chain_ended)
return false;
- chain_started = true;
-
- if (bitmap->inconsistent)
+ /* rule 3 */
+ if (bitmap->inconsistent || !bitmap->persistent || !bitmap->recording)
return false;
+
+ found = true;
}
- return chain_started;
+ return found;
}
--
2.27.0