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

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