Blame SOURCES/libvirt-qemuMigrationCookieAddNBD-Use-virHashNew-and-automatic-freeing-of-virHashTablePtr.patch

d76c62
From 3e6ecac77da1e9f302f81a68dded6bd226430682 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <3e6ecac77da1e9f302f81a68dded6bd226430682@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Tue, 4 Feb 2020 15:08:06 +0100
d76c62
Subject: [PATCH] qemuMigrationCookieAddNBD: Use virHashNew and automatic
d76c62
 freeing of virHashTablePtr
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Swithc to the helper which doesn't require checking of the return value.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
d76c62
(cherry picked from commit 45eefb2c78cfe2b14d5bc5fb150ffbed18991fde)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
d76c62
Message-Id: <06db6f97ebb2266ea197ce13cbc9051e4c839fdf.1580824112.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_migration_cookie.c | 6 +-----
d76c62
 1 file changed, 1 insertion(+), 5 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
d76c62
index 33ab6cb7a5..968a9b589c 100644
d76c62
--- a/src/qemu/qemu_migration_cookie.c
d76c62
+++ b/src/qemu/qemu_migration_cookie.c
d76c62
@@ -454,7 +454,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
d76c62
                           virDomainObjPtr vm)
d76c62
 {
d76c62
     qemuDomainObjPrivatePtr priv = vm->privateData;
d76c62
-    virHashTablePtr stats = NULL;
d76c62
+    g_autoptr(virHashTable) stats = virHashNew(virHashValueFree);
d76c62
     size_t i;
d76c62
     int ret = -1, rc;
d76c62
 
d76c62
@@ -472,9 +472,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
d76c62
     mig->nbd->disks = g_new0(struct qemuMigrationCookieNBDDisk, vm->def->ndisks);
d76c62
     mig->nbd->ndisks = 0;
d76c62
 
d76c62
-    if (!(stats = virHashCreate(10, virHashValueFree)))
d76c62
-        goto cleanup;
d76c62
-
d76c62
     if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0)
d76c62
         goto cleanup;
d76c62
     rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false);
d76c62
@@ -496,7 +493,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
d76c62
 
d76c62
     ret = 0;
d76c62
  cleanup:
d76c62
-    virHashFree(stats);
d76c62
     return ret;
d76c62
 }
d76c62
 
d76c62
-- 
d76c62
2.25.0
d76c62