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

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