render / rpms / libvirt

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