]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix live migration over RDMA with IPv6
authorDavid Dai <zdai@linux.vnet.ibm.com>
Fri, 27 Jan 2017 15:01:43 +0000 (09:01 -0600)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 9 Feb 2017 18:47:09 +0000 (19:47 +0100)
Using libvirt to do live migration over RDMA via IPv6 address failed.

For example:
    rhel73_host1_guest1 qemu+ssh://[deba::2222]/system --verbose
root@deba::2222's password:
error: internal error: unable to execute QEMU command 'migrate': RDMA
ERROR: could not rdma_getaddrinfo address deba

As we can see, the IPv6 address used by rdma_getaddrinfo() has only
"deba" part because we didn't properly enclose the IPv6 address in []
and passed rdma:deba::2222:49152 as the migration URI in
qemuMonitorMigrateToHost.

Signed-off-by: David Dai <zdai@linux.vnet.ibm.com>
src/qemu/qemu_monitor.c

index b7be5e7f47ffe674488aaa7a8a68deb099e0e7d4..1308b6921ea49138a6cdb8de25f635d94383a9b5 100644 (file)
@@ -2577,8 +2577,12 @@ qemuMonitorMigrateToHost(qemuMonitorPtr mon,
 
     QEMU_CHECK_MONITOR(mon);
 
-    if (virAsprintf(&uri, "%s:%s:%d", protocol, hostname, port) < 0)
+    if (strchr(hostname, ':')) {
+        if (virAsprintf(&uri, "%s:[%s]:%d", protocol, hostname, port) < 0)
+            return -1;
+    } else if (virAsprintf(&uri, "%s:%s:%d", protocol, hostname, port) < 0) {
         return -1;
+    }
 
     if (mon->json)
         ret = qemuMonitorJSONMigrate(mon, flags, uri);