render / rpms / libvirt

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