qemu: backup: Properly propagate async job type when cancelling the job

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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Peter Krempa 2019-12-20 11:15:47 +01:00
parent 3a98fe9db3
commit bc8b159cb1
4 changed files with 19 additions and 10 deletions

View File

@ -661,6 +661,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm,
* @vm: domain object * @vm: domain object
* @backup: backup definition * @backup: backup definition
* @terminatebackup: flag whether to terminate and unregister the backup * @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 * Sends all active blockjobs which are part of @backup of @vm a signal to
* cancel. If @terminatebackup is true qemuBackupJobTerminate is also called * cancel. If @terminatebackup is true qemuBackupJobTerminate is also called
@ -669,7 +670,8 @@ qemuBackupJobTerminate(virDomainObjPtr vm,
void void
qemuBackupJobCancelBlockjobs(virDomainObjPtr vm, qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
virDomainBackupDefPtr backup, virDomainBackupDefPtr backup,
bool terminatebackup) bool terminatebackup,
int asyncJob)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
size_t i; size_t i;
@ -703,7 +705,8 @@ qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
if (backupdisk->state != VIR_DOMAIN_BACKUP_DISK_STATE_RUNNING) if (backupdisk->state != VIR_DOMAIN_BACKUP_DISK_STATE_RUNNING)
continue; continue;
qemuDomainObjEnterMonitor(priv->driver, vm); if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
return;
rc = qemuMonitorJobCancel(priv->mon, job->name, false); rc = qemuMonitorJobCancel(priv->mon, job->name, false);
@ -868,7 +871,7 @@ qemuBackupBegin(virDomainObjPtr vm,
goto endjob; goto endjob;
if (rc < 0) { if (rc < 0) {
qemuBackupJobCancelBlockjobs(vm, priv->backup, false); qemuBackupJobCancelBlockjobs(vm, priv->backup, false, QEMU_ASYNC_JOB_BACKUP);
goto endjob; goto endjob;
} }
} }
@ -919,7 +922,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
qemuBlockjobState state, qemuBlockjobState state,
unsigned long long cur, unsigned long long cur,
unsigned long long end) unsigned long long end,
int asyncJob)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
bool has_running = false; bool has_running = false;
@ -937,7 +941,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
return; return;
if (backup->type == VIR_DOMAIN_BACKUP_TYPE_PULL) { 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)); ignore_value(qemuMonitorNBDServerStop(priv->mon));
if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) if (qemuDomainObjExitMonitor(priv->driver, vm) < 0)
return; return;
@ -1010,7 +1015,7 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
if (has_running && (has_failed || has_cancelled)) { if (has_running && (has_failed || has_cancelled)) {
/* cancel the rest of the jobs */ /* cancel the rest of the jobs */
qemuBackupJobCancelBlockjobs(vm, backup, false); qemuBackupJobCancelBlockjobs(vm, backup, false, asyncJob);
} else if (!has_running && !has_cancelling) { } else if (!has_running && !has_cancelling) {
/* all sub-jobs have stopped */ /* all sub-jobs have stopped */

View File

@ -31,14 +31,17 @@ qemuBackupGetXMLDesc(virDomainObjPtr vm,
void void
qemuBackupJobCancelBlockjobs(virDomainObjPtr vm, qemuBackupJobCancelBlockjobs(virDomainObjPtr vm,
virDomainBackupDefPtr backup, virDomainBackupDefPtr backup,
bool terminatebackup); bool terminatebackup,
int asyncJob);
void void
qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
qemuBlockjobState state, qemuBlockjobState state,
unsigned long long cur, unsigned long long cur,
unsigned long long end); unsigned long long end,
int asyncJob);
int int
qemuBackupGetJobInfoStats(virQEMUDriverPtr driver, qemuBackupGetJobInfoStats(virQEMUDriverPtr driver,

View File

@ -1336,7 +1336,8 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriverPtr driver,
g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL; g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL;
g_autoptr(virJSONValue) actions = 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 && if (job->data.backup.store &&
!(backend = qemuBlockStorageSourceDetachPrepare(job->data.backup.store, NULL))) !(backend = qemuBlockStorageSourceDetachPrepare(job->data.backup.store, NULL)))

View File

@ -14121,7 +14121,7 @@ static int qemuDomainAbortJob(virDomainPtr dom)
break; break;
case QEMU_ASYNC_JOB_BACKUP: case QEMU_ASYNC_JOB_BACKUP:
qemuBackupJobCancelBlockjobs(vm, priv->backup, true); qemuBackupJobCancelBlockjobs(vm, priv->backup, true, QEMU_ASYNC_JOB_NONE);
ret = 0; ret = 0;
break; break;