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