render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
fbe740
From e735d0f163806b34f9e65dacdf5e10b52c0478fd Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <e735d0f163806b34f9e65dacdf5e10b52c0478fd@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Mon, 16 Mar 2020 22:12:29 +0100
fbe740
Subject: [PATCH] qemuDomainBlockCommit: Handle bitmaps on start of commit
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
On start of the commit job, we need to disable any active bitmap in the
fbe740
base. Use qemuBlockBitmapsHandleCommitStart to calculate which and call
fbe740
the appropriate QMP APIs. We use blockdev-reopen to make the 'base'
fbe740
writable to disable the bitmaps.
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Eric Blake <eblake@redhat.com>
fbe740
(cherry picked from commit 2b9091f089279a7bac523095a2ccd146fa20800b)
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
fbe740
Message-Id: <2aca5706f8412d27ff38da69582c522aca058054.1584391727.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_driver.c | 43 +++++++++++++++++++++++++++++++++++++++++-
fbe740
 1 file changed, 42 insertions(+), 1 deletion(-)
fbe740
fbe740
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
fbe740
index 5c2b3cddf1..2f8fee2ef0 100644
fbe740
--- a/src/qemu/qemu_driver.c
fbe740
+++ b/src/qemu/qemu_driver.c
fbe740
@@ -18724,6 +18724,8 @@ qemuDomainBlockCommit(virDomainPtr dom,
fbe740
     const char *nodebase = NULL;
fbe740
     bool persistjob = false;
fbe740
     bool blockdev = false;
fbe740
+    g_autoptr(virJSONValue) bitmapDisableActions = NULL;
fbe740
+    VIR_AUTOSTRINGLIST bitmapDisableList = NULL;
fbe740
 
fbe740
     virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
fbe740
                   VIR_DOMAIN_BLOCK_COMMIT_ACTIVE |
fbe740
@@ -18880,8 +18882,29 @@ qemuDomainBlockCommit(virDomainPtr dom,
fbe740
             goto endjob;
fbe740
     }
fbe740
 
fbe740
+    if (blockdev &&
fbe740
+        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
fbe740
+        g_autoptr(virHashTable) blockNamedNodeData = NULL;
fbe740
+        if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
fbe740
+            goto endjob;
fbe740
+
fbe740
+        if (qemuBlockBitmapsHandleCommitStart(topSource, baseSource,
fbe740
+                                              blockNamedNodeData,
fbe740
+                                              &bitmapDisableActions,
fbe740
+                                              &bitmapDisableList) < 0)
fbe740
+            goto endjob;
fbe740
+
fbe740
+        /* if we don't have terminator on 'base' we can't reopen it */
fbe740
+        if (bitmapDisableActions && !baseSource->backingStore) {
fbe740
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
fbe740
+                           _("can't handle bitmaps on unterminated backing image '%s'"),
fbe740
+                           base);
fbe740
+            goto endjob;
fbe740
+        }
fbe740
+    }
fbe740
+
fbe740
     if (!(job = qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSource,
fbe740
-                                          baseSource, NULL,
fbe740
+                                          baseSource, &bitmapDisableList,
fbe740
                                           flags & VIR_DOMAIN_BLOCK_COMMIT_DELETE,
fbe740
                                           flags)))
fbe740
         goto endjob;
fbe740
@@ -18903,6 +18926,24 @@ qemuDomainBlockCommit(virDomainPtr dom,
fbe740
         if (!backingPath && top_parent &&
fbe740
             !(backingPath = qemuBlockGetBackingStoreString(baseSource)))
fbe740
             goto endjob;
fbe740
+
fbe740
+        if (bitmapDisableActions) {
fbe740
+            int rc;
fbe740
+
fbe740
+            if (qemuBlockReopenReadWrite(vm, baseSource, QEMU_ASYNC_JOB_NONE) < 0)
fbe740
+                goto endjob;
fbe740
+
fbe740
+            qemuDomainObjEnterMonitor(driver, vm);
fbe740
+            rc = qemuMonitorTransaction(priv->mon, &bitmapDisableActions);
fbe740
+            if (qemuDomainObjExitMonitor(driver, vm) < 0)
fbe740
+                goto endjob;
fbe740
+
fbe740
+            if (qemuBlockReopenReadOnly(vm, baseSource, QEMU_ASYNC_JOB_NONE) < 0)
fbe740
+                goto endjob;
fbe740
+
fbe740
+            if (rc < 0)
fbe740
+                goto endjob;
fbe740
+        }
fbe740
     } else {
fbe740
         device = job->name;
fbe740
     }
fbe740
-- 
fbe740
2.25.1
fbe740