render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From fe9aca2a6860fbb84faed53b10fabc95b1c73a7a Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <fe9aca2a6860fbb84faed53b10fabc95b1c73a7a@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 4 Feb 2020 15:08:05 +0100
a41c76
Subject: [PATCH] qemuMigrationCookieAddNBD: Move monitor call out of the loop
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
The data is gathered only once so we can move the whole block which
a41c76
fetches the data out of the loop and get rid of the logic which
a41c76
prevents multiple calls.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
(cherry picked from commit 464345e153b805467a22fca4615350e992e6d470)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
a41c76
Message-Id: <4c88d7cb39985ba204cd126d6adb740f58d19d6f.1580824112.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_migration_cookie.c | 23 +++++++++--------------
a41c76
 1 file changed, 9 insertions(+), 14 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
a41c76
index 1c3de13983..33ab6cb7a5 100644
a41c76
--- a/src/qemu/qemu_migration_cookie.c
a41c76
+++ b/src/qemu/qemu_migration_cookie.c
a41c76
@@ -472,24 +472,19 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
a41c76
     mig->nbd->disks = g_new0(struct qemuMigrationCookieNBDDisk, vm->def->ndisks);
a41c76
     mig->nbd->ndisks = 0;
a41c76
 
a41c76
+    if (!(stats = virHashCreate(10, virHashValueFree)))
a41c76
+        goto cleanup;
a41c76
+
a41c76
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0)
a41c76
+        goto cleanup;
a41c76
+    rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false);
a41c76
+    if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
a41c76
+        goto cleanup;
a41c76
+
a41c76
     for (i = 0; i < vm->def->ndisks; i++) {
a41c76
         virDomainDiskDefPtr disk = vm->def->disks[i];
a41c76
         qemuBlockStats *entry;
a41c76
 
a41c76
-        if (!stats) {
a41c76
-            if (!(stats = virHashCreate(10, virHashValueFree)))
a41c76
-                goto cleanup;
a41c76
-
a41c76
-            if (qemuDomainObjEnterMonitorAsync(driver, vm,
a41c76
-                                               priv->job.asyncJob) < 0)
a41c76
-                goto cleanup;
a41c76
-            rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false);
a41c76
-            if (qemuDomainObjExitMonitor(driver, vm) < 0)
a41c76
-                goto cleanup;
a41c76
-            if (rc < 0)
a41c76
-                goto cleanup;
a41c76
-        }
a41c76
-
a41c76
         if (!disk->info.alias ||
a41c76
             !(entry = virHashLookup(stats, disk->info.alias)))
a41c76
             continue;
a41c76
-- 
a41c76
2.25.0
a41c76