The job error can be safely accessed in the job structure, so we don't need to propagate it through qemuBlockJobUpdateDisk. Drop the propagation and refactor any caller that pased non-NULL error. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_blockjob.c | 12 ++---------- src/qemu/qemu_blockjob.h | 3 +-- src/qemu/qemu_driver.c | 6 +++--- src/qemu/qemu_migration.c | 28 +++++++++++----------------- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index e778e5b7ce..7aaa439791 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -342,23 +342,15 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver, int qemuBlockJobUpdateDisk(virDomainObjPtr vm, int asyncJob, - virDomainDiskDefPtr disk, - char **error) + virDomainDiskDefPtr disk) { qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob; qemuDomainObjPrivatePtr priv = vm->privateData; int state = job->newstate; - if (error) - *error = NULL; - if (state != -1) { qemuBlockJobEventProcessLegacy(priv->driver, vm, job, asyncJob); job->newstate = -1; - if (error) - VIR_STEAL_PTR(*error, job->errmsg); - else - VIR_FREE(job->errmsg); } return state; @@ -408,6 +400,6 @@ qemuBlockJobSyncEndDisk(virDomainObjPtr vm, virDomainDiskDefPtr disk) { VIR_DEBUG("disk=%s", disk->dst); - qemuBlockJobUpdateDisk(vm, asyncJob, disk, NULL); + qemuBlockJobUpdateDisk(vm, asyncJob, disk); QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob->synchronous = false; } diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 67b9c94b64..4527ee2a93 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -97,8 +97,7 @@ qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job); int qemuBlockJobUpdateDisk(virDomainObjPtr vm, int asyncJob, - virDomainDiskDefPtr disk, - char **error); + virDomainDiskDefPtr disk); void qemuBlockJobSyncBegin(qemuBlockJobDataPtr job); void qemuBlockJobSyncEndDisk(virDomainObjPtr vm, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f203f89521..2e47ec021a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4739,7 +4739,7 @@ processBlockJobEvent(virQEMUDriverPtr driver, job->newstate = status; - qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk, NULL); + qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk); endjob: qemuBlockJobStartupFinalize(job); @@ -17397,13 +17397,13 @@ qemuDomainBlockJobAbort(virDomainPtr dom, * do the waiting while still holding the VM job, to prevent newly * scheduled block jobs from confusing us. */ if (!async) { - qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk, NULL); + qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk); while (qemuBlockJobIsRunning(job)) { if (virDomainObjWait(vm) < 0) { ret = -1; goto endjob; } - qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk, NULL); + qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk); } } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1ce7863460..ac3c609067 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -464,13 +464,14 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver, static void -qemuMigrationNBDReportMirrorError(virDomainDiskDefPtr disk, - const char *errmsg) +qemuMigrationNBDReportMirrorError(virDomainDiskDefPtr disk) { - if (errmsg) { + qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob; + + if (job->errmsg) { virReportError(VIR_ERR_OPERATION_FAILED, _("migration of disk %s failed: %s"), - disk->dst, errmsg); + disk->dst, job->errmsg); } else { virReportError(VIR_ERR_OPERATION_FAILED, _("migration of disk %s failed"), disk->dst); @@ -500,17 +501,15 @@ qemuMigrationSrcNBDStorageCopyReady(virDomainObjPtr vm, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - char *error = NULL; if (!diskPriv->migrating) continue; - status = qemuBlockJobUpdateDisk(vm, asyncJob, disk, &error); + status = qemuBlockJobUpdateDisk(vm, asyncJob, disk); if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) { - qemuMigrationNBDReportMirrorError(disk, error); + qemuMigrationNBDReportMirrorError(disk); return -1; } - VIR_FREE(error); if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) notReady++; @@ -551,16 +550,15 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObjPtr vm, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - char *error = NULL; if (!diskPriv->migrating) continue; - status = qemuBlockJobUpdateDisk(vm, asyncJob, disk, &error); + status = qemuBlockJobUpdateDisk(vm, asyncJob, disk); switch (status) { case VIR_DOMAIN_BLOCK_JOB_FAILED: if (check) { - qemuMigrationNBDReportMirrorError(disk, error); + qemuMigrationNBDReportMirrorError(disk); failed = true; } ATTRIBUTE_FALLTHROUGH; @@ -576,8 +574,6 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObjPtr vm, if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED) completed++; - - VIR_FREE(error); } /* Updating completed block job drops the lock thus we have to recheck @@ -625,17 +621,16 @@ qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver, { qemuDomainObjPrivatePtr priv = vm->privateData; char *diskAlias = NULL; - char *error = NULL; int ret = -1; int status; int rv; - status = qemuBlockJobUpdateDisk(vm, asyncJob, disk, &error); + status = qemuBlockJobUpdateDisk(vm, asyncJob, disk); switch (status) { case VIR_DOMAIN_BLOCK_JOB_FAILED: case VIR_DOMAIN_BLOCK_JOB_CANCELED: if (failNoJob) { - qemuMigrationNBDReportMirrorError(disk, error); + qemuMigrationNBDReportMirrorError(disk); goto cleanup; } ATTRIBUTE_FALLTHROUGH; @@ -659,7 +654,6 @@ qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver, cleanup: VIR_FREE(diskAlias); - VIR_FREE(error); return ret; } -- 2.19.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list