[libvirt] [PATCH v3 REBASE 11/16] qemu: always get job condition on getting job stats

Nikolay Shirokovskiy posted 16 patches 7 years, 8 months ago
There is a newer version of this series
[libvirt] [PATCH v3 REBASE 11/16] qemu: always get job condition on getting job stats
Posted by Nikolay Shirokovskiy 7 years, 8 months ago
Looks like it is more simple to drop this optimization as we are
going to add getting disks stats during migration via quering qemu
process and checking if we have to acquire job condition becomes
more complicate.
---
 src/qemu/qemu_driver.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e8c0d83..20ae879 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12903,7 +12903,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
                               qemuDomainJobInfoPtr jobInfo)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    bool fetch = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
+    bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
     int ret = -1;
 
     if (completed) {
@@ -12923,12 +12923,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
         return -1;
     }
 
-    /* Do not ask QEMU if migration is not even running yet  */
-    if (!priv->job.current ||
-        priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
-        fetch = false;
-
-    if (fetch && qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
         return -1;
 
     if (!virDomainObjIsActive(vm)) {
@@ -12947,7 +12942,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
     if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-        if (fetch &&
+
+        if (events && jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
             qemuMigrationFetchMigrationStats(driver, vm, QEMU_ASYNC_JOB_NONE,
                                              &jobInfo->stats, false) < 0)
             goto cleanup;
@@ -12959,8 +12955,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
     ret = 0;
 
  cleanup:
-    if (fetch)
-        qemuDomainObjEndJob(driver, vm);
+    qemuDomainObjEndJob(driver, vm);
     return ret;
 }
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 REBASE 11/16] qemu: always get job condition on getting job stats
Posted by Jiri Denemark 7 years, 8 months ago
On Thu, Aug 24, 2017 at 09:56:48 +0300, Nikolay Shirokovskiy wrote:
> Looks like it is more simple to drop this optimization as we are
> going to add getting disks stats during migration via quering qemu
> process and checking if we have to acquire job condition becomes
> more complicate.
...
> @@ -12947,7 +12942,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
>      if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
>          jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
>          jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
> -        if (fetch &&
> +

Remove the empty line here

> +        if (events && jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&

and break this line after the first "&&".

>              qemuMigrationFetchMigrationStats(driver, vm, QEMU_ASYNC_JOB_NONE,
>                                               &jobInfo->stats, false) < 0)
>              goto cleanup;

ACK with the trivial change.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list