render / rpms / libvirt

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