render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 44d255b6cc7315537e66f1d97e4893e321b694b8 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <44d255b6cc7315537e66f1d97e4893e321b694b8@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 4 Feb 2020 15:08:02 +0100
a41c76
Subject: [PATCH] qemuMigrationCookieAddNBD: Exit early if there are no disks
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Refactor the logic to skip the body of the function if there's nothing
a41c76
to do.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
(cherry picked from commit bdff9d4513694da8d9b2bb60a1f808fb1c286388)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
a41c76
Message-Id: <b12c9b8c4ca78e848e43ab4ae7706a5694cfb49c.1580824112.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_migration_cookie.c | 12 +++++++-----
a41c76
 1 file changed, 7 insertions(+), 5 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
a41c76
index 299bf17c9e..73ae815818 100644
a41c76
--- a/src/qemu/qemu_migration_cookie.c
a41c76
+++ b/src/qemu/qemu_migration_cookie.c
a41c76
@@ -464,8 +464,13 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
a41c76
     if (VIR_ALLOC(mig->nbd) < 0)
a41c76
         return -1;
a41c76
 
a41c76
-    if (vm->def->ndisks &&
a41c76
-        VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0)
a41c76
+    mig->nbd->port = priv->nbdPort;
a41c76
+    mig->flags |= QEMU_MIGRATION_COOKIE_NBD;
a41c76
+
a41c76
+    if (vm->def->ndisks == 0)
a41c76
+        return 0;
a41c76
+
a41c76
+    if (VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0)
a41c76
         return -1;
a41c76
     mig->nbd->ndisks = 0;
a41c76
 
a41c76
@@ -496,9 +501,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
a41c76
         mig->nbd->ndisks++;
a41c76
     }
a41c76
 
a41c76
-    mig->nbd->port = priv->nbdPort;
a41c76
-    mig->flags |= QEMU_MIGRATION_COOKIE_NBD;
a41c76
-
a41c76
     ret = 0;
a41c76
  cleanup:
a41c76
     virHashFree(stats);
a41c76
-- 
a41c76
2.25.0
a41c76