a41c76
From 8e5be603c7e3ab3679af498a30cc510177c20514 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <8e5be603c7e3ab3679af498a30cc510177c20514@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:32 +0100
a41c76
Subject: [PATCH] qemu: blockjob: Re-enable bitmaps after failed block-commit
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
If a block-commit fails we should at least re-enable the bitmaps so that
a41c76
the operation can be re-tried.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit 4a39b25c81d40d8d2b5d4e33c53b3660aa4c9fda)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
a41c76
Message-Id: <34dd58f94ac59b5ef970070c07a36ced6bbe77af.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_blockjob.c | 42 ++++++++++++++++++++++++++++++++++++++--
a41c76
 1 file changed, 40 insertions(+), 2 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
a41c76
index 0b7e1403e6..21a043d369 100644
a41c76
--- a/src/qemu/qemu_blockjob.c
a41c76
+++ b/src/qemu/qemu_blockjob.c
a41c76
@@ -1345,6 +1345,40 @@ qemuBlockJobProcessEventFailedActiveCommit(virQEMUDriverPtr driver,
a41c76
 }
a41c76
 
a41c76
 
a41c76
+static void
a41c76
+qemuBlockJobProcessEventFailedCommitCommon(virDomainObjPtr vm,
a41c76
+                                           qemuBlockJobDataPtr job,
a41c76
+                                           qemuDomainAsyncJob asyncJob)
a41c76
+{
a41c76
+    qemuDomainObjPrivatePtr priv = vm->privateData;
a41c76
+    g_autoptr(virJSONValue) actions = virJSONValueNewArray();
a41c76
+    char **disabledBitmaps = job->data.commit.disabledBitmapsBase;
a41c76
+
a41c76
+    if (!disabledBitmaps || !*disabledBitmaps)
a41c76
+        return;
a41c76
+
a41c76
+    for (; *disabledBitmaps; disabledBitmaps++) {
a41c76
+        qemuMonitorTransactionBitmapEnable(actions,
a41c76
+                                           job->data.commit.base->nodeformat,
a41c76
+                                           *disabledBitmaps);
a41c76
+    }
a41c76
+
a41c76
+    if (qemuBlockReopenReadWrite(vm, job->data.commit.base, asyncJob) < 0)
a41c76
+        return;
a41c76
+
a41c76
+    if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
a41c76
+        return;
a41c76
+
a41c76
+    qemuMonitorTransaction(priv->mon, &actions);
a41c76
+
a41c76
+    if (qemuDomainObjExitMonitor(priv->driver, vm) < 0)
a41c76
+        return;
a41c76
+
a41c76
+    if (qemuBlockReopenReadOnly(vm, job->data.commit.base, asyncJob) < 0)
a41c76
+        return;
a41c76
+}
a41c76
+
a41c76
+
a41c76
 static void
a41c76
 qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver,
a41c76
                                         virDomainObjPtr vm,
a41c76
@@ -1452,13 +1486,17 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job,
a41c76
     case QEMU_BLOCKJOB_TYPE_COMMIT:
a41c76
         if (success)
a41c76
             qemuBlockJobProcessEventCompletedCommit(driver, vm, job, asyncJob);
a41c76
+        else
a41c76
+            qemuBlockJobProcessEventFailedCommitCommon(vm, job, asyncJob);
a41c76
         break;
a41c76
 
a41c76
     case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
a41c76
-        if (success)
a41c76
+        if (success) {
a41c76
             qemuBlockJobProcessEventCompletedActiveCommit(driver, vm, job, asyncJob);
a41c76
-        else
a41c76
+        } else {
a41c76
             qemuBlockJobProcessEventFailedActiveCommit(driver, vm, job);
a41c76
+            qemuBlockJobProcessEventFailedCommitCommon(vm, job, asyncJob);
a41c76
+        }
a41c76
         break;
a41c76
 
a41c76
     case QEMU_BLOCKJOB_TYPE_CREATE:
a41c76
-- 
a41c76
2.25.1
a41c76