render / rpms / libvirt

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