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