mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
qemu: blockjob: Remove error propagation from qemuBlockJobUpdateDisk
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
10c99feb05
commit
8ca9fcec24
@ -343,23 +343,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;
|
||||
@ -410,6 +402,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;
|
||||
}
|
||||
|
@ -98,8 +98,7 @@ qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job);
|
||||
|
||||
int qemuBlockJobUpdateDisk(virDomainObjPtr vm,
|
||||
int asyncJob,
|
||||
virDomainDiskDefPtr disk,
|
||||
char **error);
|
||||
virDomainDiskDefPtr disk);
|
||||
|
||||
void qemuBlockJobSyncBegin(qemuBlockJobDataPtr job);
|
||||
void qemuBlockJobSyncEndDisk(virDomainObjPtr vm,
|
||||
|
@ -4740,7 +4740,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);
|
||||
@ -17445,13 +17445,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user