When cancelling the blockjobs as part of failed backup job startup
recover we didn't pass in the correct async job type. Luckily the block
job handler and cancellation code paths use no block job at all
currently so those were correct.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_backup.c | 17 +++++++++++------
src/qemu/qemu_backup.h | 7 +++++--
src/qemu/qemu_blockjob.c | 3 ++-
src/qemu/qemu_driver.c | 2 +-
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index fa9588ef28..1381505d9f 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -661,6 +661,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm,
* @vm: domain object
* @backup: backup definition
* @terminatebackup: flag whether to terminate and unregister the backup
+ * @asyncJob: currently used qemu asynchronous job type
*
* Sends all active blockjobs which are part of @backup of @vm a signal to
* cancel. If @terminatebackup is true qemuBackupJobTerminate is also called
@@ -669,7 +670,8 @@ qemuBackupJobTerminate(virDomainObjPtr vm,
void
qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
virDomainBackupDefPtr backup,
- bool terminatebackup)
+ bool terminatebackup,
+ int asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
size_t i;
@@ -703,7 +705,8 @@ qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
if (backupdisk->state != VIR_DOMAIN_BACKUP_DISK_STATE_RUNNING)
continue;
- qemuDomainObjEnterMonitor(priv->driver, vm);
+ if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
+ return;
rc = qemuMonitorJobCancel(priv->mon, job->name, false);
@@ -869,7 +872,7 @@ qemuBackupBegin(virDomainObjPtr vm,
goto endjob;
if (rc < 0) {
- qemuBackupJobCancelBlockjobs(vm, priv->backup, false);
+ qemuBackupJobCancelBlockjobs(vm, priv->backup, false,
QEMU_ASYNC_JOB_BACKUP);
goto endjob;
}
}
@@ -920,7 +923,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
virDomainDiskDefPtr disk,
qemuBlockjobState state,
unsigned long long cur,
- unsigned long long end)
+ unsigned long long end,
+ int asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
bool has_running = false;
@@ -938,7 +942,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
return;
if (backup->type == VIR_DOMAIN_BACKUP_TYPE_PULL) {
- qemuDomainObjEnterMonitor(priv->driver, vm);
+ if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
+ return;
ignore_value(qemuMonitorNBDServerStop(priv->mon));
if (qemuDomainObjExitMonitor(priv->driver, vm) < 0)
return;
@@ -1011,7 +1016,7 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
if (has_running && (has_failed || has_cancelled)) {
/* cancel the rest of the jobs */
- qemuBackupJobCancelBlockjobs(vm, backup, false);
+ qemuBackupJobCancelBlockjobs(vm, backup, false, asyncJob);
} else if (!has_running && !has_cancelling) {
/* all sub-jobs have stopped */
diff --git a/src/qemu/qemu_backup.h b/src/qemu/qemu_backup.h
index df67b849be..1b8a03612c 100644
--- a/src/qemu/qemu_backup.h
+++ b/src/qemu/qemu_backup.h
@@ -31,14 +31,17 @@ qemuBackupGetXMLDesc(virDomainObjPtr vm,
void
qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
virDomainBackupDefPtr backup,
- bool terminatebackup);
+ bool terminatebackup,
+ int asyncJob);
void
qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
virDomainDiskDefPtr disk,
qemuBlockjobState state,
unsigned long long cur,
- unsigned long long end);
+ unsigned long long end,
+ int asyncJob);
+
int
qemuBackupGetJobInfoStats(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index c536c19bb6..e04fcf69d1 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -1336,7 +1336,8 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriverPtr driver,
g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
g_autoptr(virJSONValue) actions = NULL;
- qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate, progressCurrent,
progressTotal);
+ qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate,
+ progressCurrent, progressTotal, asyncJob);
if (job->data.backup.store &&
!(backend = qemuBlockStorageSourceDetachPrepare(job->data.backup.store,
NULL)))
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ec8faf384c..e493755fb8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14124,7 +14124,7 @@ static int qemuDomainAbortJob(virDomainPtr dom)
break;
case QEMU_ASYNC_JOB_BACKUP:
- qemuBackupJobCancelBlockjobs(vm, priv->backup, true);
+ qemuBackupJobCancelBlockjobs(vm, priv->backup, true, QEMU_ASYNC_JOB_NONE);
ret = 0;
break;
--
2.23.0