Blame SOURCES/libvirt-qemu-blockjob-Handle-bitmaps-after-finish-of-normal-block-commit.patch

d76c62
From 629629bccbaef81ab1e187fbf5aab4e07d49f350 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <629629bccbaef81ab1e187fbf5aab4e07d49f350@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Mon, 16 Mar 2020 22:12:31 +0100
d76c62
Subject: [PATCH] qemu: blockjob: Handle bitmaps after finish of normal
d76c62
 block-commit
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Merge the bitmaps into base of the block commit after the job finishes.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Eric Blake <eblake@redhat.com>
d76c62
(cherry picked from commit db450a742224fb96d8f4d45fde3d0c19faeabfdb)
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
d76c62
Message-Id: <dcf1a67be965850ccd4b35f3ef4587dee5c77151.1584391727.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_blockjob.c | 52 ++++++++++++++++++++++++++++++++++++++++
d76c62
 1 file changed, 52 insertions(+)
d76c62
d76c62
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
d76c62
index 63f1cc79c3..0b7e1403e6 100644
d76c62
--- a/src/qemu/qemu_blockjob.c
d76c62
+++ b/src/qemu/qemu_blockjob.c
d76c62
@@ -1049,6 +1049,55 @@ qemuBlockJobDeleteImages(virQEMUDriverPtr driver,
d76c62
     }
d76c62
 }
d76c62
 
d76c62
+
d76c62
+/**
d76c62
+ * qemuBlockJobProcessEventCompletedCommitBitmaps:
d76c62
+ *
d76c62
+ * Handles the bitmap changes after commit. This returns -1 on monitor failures.
d76c62
+ */
d76c62
+static int
d76c62
+qemuBlockJobProcessEventCompletedCommitBitmaps(virDomainObjPtr vm,
d76c62
+                                               qemuBlockJobDataPtr job,
d76c62
+                                               qemuDomainAsyncJob asyncJob)
d76c62
+{
d76c62
+    qemuDomainObjPrivatePtr priv = vm->privateData;
d76c62
+    g_autoptr(virHashTable) blockNamedNodeData = NULL;
d76c62
+    g_autoptr(virJSONValue) actions = NULL;
d76c62
+
d76c62
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
d76c62
+        return 0;
d76c62
+
d76c62
+    if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, asyncJob)))
d76c62
+        return -1;
d76c62
+
d76c62
+    if (qemuBlockBitmapsHandleCommitFinish(job->data.commit.top,
d76c62
+                                           job->data.commit.base,
d76c62
+                                           blockNamedNodeData,
d76c62
+                                           &actions,
d76c62
+                                           job->data.commit.disabledBitmapsBase) < 0)
d76c62
+        return 0;
d76c62
+
d76c62
+    if (!actions)
d76c62
+        return 0;
d76c62
+
d76c62
+    if (qemuBlockReopenReadWrite(vm, job->data.commit.base, asyncJob) < 0)
d76c62
+        return -1;
d76c62
+
d76c62
+    if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
d76c62
+        return -1;
d76c62
+
d76c62
+    qemuMonitorTransaction(priv->mon, &actions);
d76c62
+
d76c62
+    if (qemuDomainObjExitMonitor(priv->driver, vm) < 0)
d76c62
+        return -1;
d76c62
+
d76c62
+    if (qemuBlockReopenReadOnly(vm, job->data.commit.base, asyncJob) < 0)
d76c62
+        return -1;
d76c62
+
d76c62
+    return 0;
d76c62
+}
d76c62
+
d76c62
+
d76c62
 /**
d76c62
  * qemuBlockJobProcessEventCompletedCommit:
d76c62
  * @driver: qemu driver object
d76c62
@@ -1106,6 +1155,9 @@ qemuBlockJobProcessEventCompletedCommit(virQEMUDriverPtr driver,
d76c62
     if (!n)
d76c62
         return;
d76c62
 
d76c62
+    if (qemuBlockJobProcessEventCompletedCommitBitmaps(vm, job, asyncJob) < 0)
d76c62
+        return;
d76c62
+
d76c62
     /* revert access to images */
d76c62
     qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.base,
d76c62
                                        true, false, false);
d76c62
-- 
d76c62
2.25.1
d76c62