Blame SOURCES/libvirt-qemuMigrationCookieAddNBD-Fix-filling-of-capacity-when-blockdev-is-used.patch

a41c76
From 0c415216f2005b3c33379db3b37fb9c03e30a658 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <0c415216f2005b3c33379db3b37fb9c03e30a658@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 4 Feb 2020 15:08:08 +0100
a41c76
Subject: [PATCH] qemuMigrationCookieAddNBD: Fix filling of 'capacity' when
a41c76
 blockdev is used
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
With -blockdev we must look up via the nodename rather than the 'drive'
a41c76
alias which is not present any more.
a41c76
a41c76
This fixes the pre-creation of storage volumes on migration with
a41c76
non-shared storage.
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
(cherry picked from commit b9e87908dbcff23cc3fdf3d8629849560d2e7268)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1793263
a41c76
Message-Id: <60eb81e2479cac5fc9ae3cc40abb106e0a127e6e.1580824112.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_migration_cookie.c | 17 +++++++++++++----
a41c76
 1 file changed, 13 insertions(+), 4 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
a41c76
index 734d95f4f1..a5a9edffc3 100644
a41c76
--- a/src/qemu/qemu_migration_cookie.c
a41c76
+++ b/src/qemu/qemu_migration_cookie.c
a41c76
@@ -455,6 +455,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
a41c76
 {
a41c76
     qemuDomainObjPrivatePtr priv = vm->privateData;
a41c76
     g_autoptr(virHashTable) stats = virHashNew(virHashValueFree);
a41c76
+    bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
a41c76
     size_t i;
a41c76
     int rc;
a41c76
 
a41c76
@@ -474,7 +475,10 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
a41c76
 
a41c76
     if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0)
a41c76
         return -1;
a41c76
-    rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false);
a41c76
+    if (blockdev)
a41c76
+        rc = qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, stats);
a41c76
+    else
a41c76
+        rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false);
a41c76
     if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
a41c76
         return -1;
a41c76
 
a41c76
@@ -482,9 +486,14 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
a41c76
         virDomainDiskDefPtr disk = vm->def->disks[i];
a41c76
         qemuBlockStats *entry;
a41c76
 
a41c76
-        if (!disk->info.alias ||
a41c76
-            !(entry = virHashLookup(stats, disk->info.alias)))
a41c76
-            continue;
a41c76
+        if (blockdev) {
a41c76
+            if (!(entry = virHashLookup(stats, disk->src->nodeformat)))
a41c76
+                continue;
a41c76
+        } else {
a41c76
+            if (!disk->info.alias ||
a41c76
+                !(entry = virHashLookup(stats, disk->info.alias)))
a41c76
+                continue;
a41c76
+        }
a41c76
 
a41c76
         mig->nbd->disks[mig->nbd->ndisks].target = g_strdup(disk->dst);
a41c76
         mig->nbd->disks[mig->nbd->ndisks].capacity = entry->capacity;
a41c76
-- 
a41c76
2.25.0
a41c76