mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-12-04 20:25:57 +03:00
qemuBlockJobProcessEventConcludedBackup: Notify the backup job later
Move the notification to the backup job after finishing the cleanup of the current block job the backup operation consists of. Currently the termination of the blockjob would e.g. delete the scratch files before they are detached from qemu. In later patches the termination of the backup job may cause the qemu process to be killed (if the guest OS shut down but the qemu process was being kept alive to finish the backup) which would cause errors in the monitor commands for dismissing the block job. Since the NBD server still needs to be terminated first as otherwise the scratch files can't be unplugged from qemu we need to split the operation into two. First the NBD server is terminated, then the current block job is finalized and then the backup job is notified. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
@@ -981,6 +981,33 @@ qemuBackupGetXMLDesc(virDomainObj *vm,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qemuBackupNotifyBlockjobEndStopNBD(virDomainObj *vm,
|
||||
int asyncJob)
|
||||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
virDomainBackupDef *backup = priv->backup;
|
||||
|
||||
VIR_DEBUG("vm: '%s'", vm->def->name);
|
||||
|
||||
if (!backup ||
|
||||
backup->type != VIR_DOMAIN_BACKUP_TYPE_PULL ||
|
||||
backup->nbdStopped)
|
||||
return;
|
||||
|
||||
if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
|
||||
return;
|
||||
ignore_value(qemuMonitorNBDServerStop(priv->mon));
|
||||
if (backup->tlsAlias)
|
||||
ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias, false));
|
||||
if (backup->tlsSecretAlias)
|
||||
ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecretAlias, false));
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
|
||||
backup->nbdStopped = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qemuBackupNotifyBlockjobEnd(virDomainObj *vm,
|
||||
const char *diskdst,
|
||||
@@ -1005,20 +1032,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm,
|
||||
if (!backup)
|
||||
return;
|
||||
|
||||
/* update the final statistics with the current job's data */
|
||||
if (backup->type == VIR_DOMAIN_BACKUP_TYPE_PULL) {
|
||||
if (!backup->nbdStopped) {
|
||||
if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
|
||||
return;
|
||||
ignore_value(qemuMonitorNBDServerStop(priv->mon));
|
||||
if (backup->tlsAlias)
|
||||
ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias, false));
|
||||
if (backup->tlsSecretAlias)
|
||||
ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecretAlias, false));
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
backup->nbdStopped = true;
|
||||
}
|
||||
|
||||
/* update the final statistics with the current job's data */
|
||||
backup->pull_tmp_used += cur;
|
||||
backup->pull_tmp_total += end;
|
||||
} else {
|
||||
|
||||
@@ -34,6 +34,10 @@ qemuBackupJobCancelBlockjobs(virDomainObj *vm,
|
||||
bool terminatebackup,
|
||||
int asyncJob);
|
||||
|
||||
void
|
||||
qemuBackupNotifyBlockjobEndStopNBD(virDomainObj *vm,
|
||||
int asyncJob);
|
||||
|
||||
void
|
||||
qemuBackupNotifyBlockjobEnd(virDomainObj *vm,
|
||||
const char *diskdst,
|
||||
|
||||
@@ -1392,8 +1392,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver *driver,
|
||||
if (job->disk)
|
||||
diskdst = job->disk->dst;
|
||||
|
||||
qemuBackupNotifyBlockjobEnd(vm, diskdst, newstate, job->errmsg,
|
||||
progressCurrent, progressTotal, asyncJob);
|
||||
qemuBackupNotifyBlockjobEndStopNBD(vm, asyncJob);
|
||||
|
||||
if (job->data.backup.store &&
|
||||
!(backend = qemuBlockStorageSourceDetachPrepare(job->data.backup.store)))
|
||||
@@ -1415,6 +1414,10 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver *driver,
|
||||
|
||||
if (job->data.backup.store)
|
||||
qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.backup.store);
|
||||
|
||||
qemuBackupNotifyBlockjobEnd(vm, diskdst, newstate, job->errmsg,
|
||||
progressCurrent, progressTotal, asyncJob);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user