After the individual sub-blockjobs of a backup libvirt job finish we
must detect it and notify the parent job, so that it can be properly
terminated.
Since we update job information to determine success of an blockjob we
can directly report back also statistics of the blockjob.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_blockjob.c | 61 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 8dbb09c30a..3df6ccc068 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -27,6 +27,7 @@
#include "qemu_block.h"
#include "qemu_domain.h"
#include "qemu_alias.h"
+#include "qemu_backup.h"
#include "conf/domain_conf.h"
#include "conf/domain_event.h"
@@ -1269,11 +1270,58 @@ qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver,
}
+static void
+qemuBlockJobProcessEventConcludedBackup(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ qemuBlockJobDataPtr job,
+ qemuDomainAsyncJob asyncJob,
+ qemuBlockjobState newstate,
+ unsigned long long progressCurrent,
+ unsigned long long progressTotal)
+{
+ g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
+ g_autoptr(virJSONValue) actions = NULL;
+
+ qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate, progressCurrent,
progressTotal);
+
+ if (job->data.backup.store &&
+ !(backend = qemuBlockStorageSourceDetachPrepare(job->data.backup.store,
NULL)))
+ return;
+
+ if (job->data.backup.bitmap) {
+ if (!(actions = virJSONValueNewArray()))
+ return;
+
+ if (qemuMonitorTransactionBitmapRemove(actions,
+ job->disk->src->nodeformat,
+ job->data.backup.bitmap) < 0)
+ return;
+ }
+
+ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+ return;
+
+ if (backend)
+ qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), backend);
+
+ if (actions)
+ qemuMonitorTransaction(qemuDomainGetMonitor(vm), &actions);
+
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ return;
+
+ if (job->data.backup.store)
+ qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.backup.store);
+}
+
+
static void
qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job,
virQEMUDriverPtr driver,
virDomainObjPtr vm,
- qemuDomainAsyncJob asyncJob)
+ qemuDomainAsyncJob asyncJob,
+ unsigned long long progressCurrent,
+ unsigned long long progressTotal)
{
bool success = job->newstate == QEMU_BLOCKJOB_STATE_COMPLETED;
@@ -1307,6 +1355,9 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr
job,
break;
case QEMU_BLOCKJOB_TYPE_BACKUP:
+ qemuBlockJobProcessEventConcludedBackup(driver, vm, job, asyncJob,
+ job->newstate, progressCurrent,
+ progressTotal);
break;
case QEMU_BLOCKJOB_TYPE_BROKEN:
@@ -1333,6 +1384,8 @@ qemuBlockJobEventProcessConcluded(qemuBlockJobDataPtr job,
size_t njobinfo = 0;
size_t i;
bool refreshed = false;
+ unsigned long long progressCurrent = 0;
+ unsigned long long progressTotal = 0;
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto cleanup;
@@ -1345,6 +1398,9 @@ qemuBlockJobEventProcessConcluded(qemuBlockJobDataPtr job,
if (STRNEQ_NULLABLE(job->name, jobinfo[i]->id))
continue;
+ progressCurrent = jobinfo[i]->progressCurrent;
+ progressTotal = jobinfo[i]->progressTotal;
+
job->errmsg = g_strdup(jobinfo[i]->error);
if (job->errmsg)
@@ -1377,7 +1433,8 @@ qemuBlockJobEventProcessConcluded(qemuBlockJobDataPtr job,
VIR_DEBUG("handling job '%s' state '%d' newstate
'%d'", job->name, job->state, job->newstate);
- qemuBlockJobEventProcessConcludedTransition(job, driver, vm, asyncJob);
+ qemuBlockJobEventProcessConcludedTransition(job, driver, vm, asyncJob,
+ progressCurrent, progressTotal);
/* unplug the backing chains in case the job inherited them */
if (!job->disk) {
--
2.23.0