qemu: Introduce qemuDomainGetJobInfoMigrationStats

Extract out the parts of qemuDomainGetJobStatsInternal that get
the migration stats. We're about to add the ability to get just
dump information.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
John Ferlan 2017-11-20 13:00:43 -05:00
parent 9c27e464e3
commit 3f99bb06d1

View File

@ -13155,6 +13155,37 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static int
qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainJobInfoPtr jobInfo)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
if (events &&
jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE,
jobInfo, NULL) < 0)
return -1;
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
qemuMigrationFetchMirrorStats(driver, vm, QEMU_ASYNC_JOB_NONE,
jobInfo) < 0)
return -1;
if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
return -1;
}
return 0;
}
static int
qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@ -13162,7 +13193,6 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
qemuDomainJobInfoPtr jobInfo)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
int ret = -1;
if (completed) {
@ -13197,25 +13227,9 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
}
*jobInfo = *priv->job.current;
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
if (events &&
jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE,
jobInfo, NULL) < 0)
if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0)
goto cleanup;
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
qemuMigrationFetchMirrorStats(driver, vm, QEMU_ASYNC_JOB_NONE,
jobInfo) < 0)
goto cleanup;
if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
goto cleanup;
}
ret = 0;
cleanup: