[libvirt] [PATCH 2/8] qemu: migration: Properly export backend for NBD storage migration

Peter Krempa posted 8 patches 6 years, 2 months ago
[libvirt] [PATCH 2/8] qemu: migration: Properly export backend for NBD storage migration
Posted by Peter Krempa 6 years, 2 months ago
With -blockdev we must use the nodename as the export but we must keep
the name of the export as it was before to ensure compatiblity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_migration.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index af22dfb48d..2416dbe432 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -392,6 +392,8 @@ qemuMigrationDstStartNBDServer(virQEMUDriverPtr driver,
     for (i = 0; i < vm->def->ndisks; i++) {
         virDomainDiskDefPtr disk = vm->def->disks[i];
         g_autofree char *diskAlias = NULL;
+        const char *exportname = NULL;
+        const char *devicename = NULL;

         /* check whether disk should be migrated */
         if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks))
@@ -407,6 +409,14 @@ qemuMigrationDstStartNBDServer(virQEMUDriverPtr driver,
         if (!(diskAlias = qemuAliasDiskDriveFromDisk(disk)))
             goto cleanup;

+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+            exportname = diskAlias;
+            devicename = disk->src->nodeformat;
+        } else {
+            exportname = NULL;
+            devicename = diskAlias;
+        }
+
         if (qemuDomainObjEnterMonitorAsync(driver, vm,
                                            QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
             goto cleanup;
@@ -422,7 +432,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriverPtr driver,
                 goto exit_monitor;
         }

-        if (qemuMonitorNBDServerAdd(priv->mon, diskAlias, NULL, true, NULL) < 0)
+        if (qemuMonitorNBDServerAdd(priv->mon, devicename, exportname, true, NULL) < 0)
             goto exit_monitor;
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto cleanup;
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/8] qemu: migration: Properly export backend for NBD storage migration
Posted by Eric Blake 6 years, 2 months ago
On 12/6/19 12:09 PM, Peter Krempa wrote:
> With -blockdev we must use the nodename as the export but we must keep
> the name of the export as it was before to ensure compatiblity.

compatibility

Makes sense - this is code on the destination, but we may be migrating 
storage from an older libvirt that wasn't using blockdev, so we must 
export the same name as expected by that older client (our goal is to 
allow migration as a way to upgrade from a -device command line to a 
-blockdev command line, without any guest downtime)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list