mirror of https://gitee.com/openkylin/libvirt.git
qemu: migration: Extract reporting of disk migration error
The same message is reported in 3 distinct places. Move it out into a single function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d1a44634ac
commit
10c99feb05
|
@ -463,6 +463,21 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuMigrationNBDReportMirrorError(virDomainDiskDefPtr disk,
|
||||||
|
const char *errmsg)
|
||||||
|
{
|
||||||
|
if (errmsg) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
_("migration of disk %s failed: %s"),
|
||||||
|
disk->dst, errmsg);
|
||||||
|
} else {
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
_("migration of disk %s failed"), disk->dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuMigrationSrcNBDStorageCopyReady:
|
* qemuMigrationSrcNBDStorageCopyReady:
|
||||||
* @vm: domain
|
* @vm: domain
|
||||||
|
@ -492,15 +507,7 @@ qemuMigrationSrcNBDStorageCopyReady(virDomainObjPtr vm,
|
||||||
|
|
||||||
status = qemuBlockJobUpdateDisk(vm, asyncJob, disk, &error);
|
status = qemuBlockJobUpdateDisk(vm, asyncJob, disk, &error);
|
||||||
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
|
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
|
||||||
if (error) {
|
qemuMigrationNBDReportMirrorError(disk, error);
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("migration of disk %s failed: %s"),
|
|
||||||
disk->dst, error);
|
|
||||||
VIR_FREE(error);
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("migration of disk %s failed"), disk->dst);
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(error);
|
VIR_FREE(error);
|
||||||
|
@ -553,14 +560,7 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObjPtr vm,
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
||||||
if (check) {
|
if (check) {
|
||||||
if (error) {
|
qemuMigrationNBDReportMirrorError(disk, error);
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("migration of disk %s failed: %s"),
|
|
||||||
disk->dst, error);
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("migration of disk %s failed"), disk->dst);
|
|
||||||
}
|
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
ATTRIBUTE_FALLTHROUGH;
|
ATTRIBUTE_FALLTHROUGH;
|
||||||
|
@ -635,14 +635,7 @@ qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver,
|
||||||
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
||||||
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
|
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
|
||||||
if (failNoJob) {
|
if (failNoJob) {
|
||||||
if (error) {
|
qemuMigrationNBDReportMirrorError(disk, error);
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("migration of disk %s failed: %s"),
|
|
||||||
disk->dst, error);
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("migration of disk %s failed"), disk->dst);
|
|
||||||
}
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ATTRIBUTE_FALLTHROUGH;
|
ATTRIBUTE_FALLTHROUGH;
|
||||||
|
|
Loading…
Reference in New Issue