render / rpms / libvirt

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