All domain jobs other than source migration have only one state - active. Only elapsed time is available for such jobs so let's make it more explicit. Also if in future there will be more stats for such jobs we don't want to mess them with migration stats code. --- src/qemu/qemu_driver.c | 58 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 21e3f9c..acaad8f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13013,6 +13013,34 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED, static int +qemuDomainGetMigrationJobStats(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainJobInfoPtr jobInfo) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + + if (jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE && + jobInfo->status != QEMU_DOMAIN_JOB_STATUS_POSTCOPY) + return 0; + + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT) && + priv->job.current->stats.status) { + int rv; + + qemuDomainObjEnterMonitor(driver, vm); + rv = qemuMonitorGetMigrationStats(priv->mon, &jobInfo->stats); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + return -1; + } + + if (qemuDomainJobInfoUpdateTime(jobInfo) < 0) + return -1; + + return 0; +} + + +static int qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver, virDomainObjPtr vm, bool completed, @@ -13047,29 +13075,17 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver, } *jobInfo = *priv->job.current; - if (jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE && - jobInfo->status != QEMU_DOMAIN_JOB_STATUS_POSTCOPY) { - ret = 0; - goto cleanup; + if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT || + priv->job.asyncJob == QEMU_ASYNC_JOB_SAVE) { + ret = qemuDomainGetMigrationJobStats(driver, vm, jobInfo); + } else { + if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE) { + ret = qemuDomainJobInfoUpdateTime(jobInfo); + } else { + ret = 0; + } } - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT) && - priv->job.current->stats.status) { - int rv; - - qemuDomainObjEnterMonitor(driver, vm); - - rv = qemuMonitorGetMigrationStats(priv->mon, &jobInfo->stats); - - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) - goto cleanup; - } - - if (qemuDomainJobInfoUpdateTime(jobInfo) < 0) - goto cleanup; - - ret = 0; - cleanup: qemuDomainObjEndJob(driver, vm); return ret; -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list