提交 2136327e 编写于 作者: J Ján Tomko

qemu: escape literal IPv6 address in NBD migration

A literal IPv6 must be escaped, otherwise migration fails with:
unable to execute QEMU command 'drive-mirror': address resolution failed
for f0::0d:5901: Servname not supported for ai_socktype
since QEMU treats everything after the first ':' as the port.
上级 64919d97
......@@ -1193,6 +1193,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
size_t i, lastGood = 0;
char *diskAlias = NULL;
char *nbd_dest = NULL;
char *hoststr = NULL;
unsigned int mirror_flags = VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT;
virErrorPtr err = NULL;
......@@ -1212,6 +1213,16 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
port = mig->nbd->port;
mig->nbd->port = 0;
/* escape literal IPv6 address */
if (strchr(host, ':')) {
if (virAsprintf(&hoststr, "[%s]", host) < 0) {
virReportOOMError();
goto error;
}
} else if (VIR_STRDUP(hoststr, host) < 0) {
goto error;
}
if (*migrate_flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC)
mirror_flags |= VIR_DOMAIN_BLOCK_REBASE_SHALLOW;
......@@ -1228,7 +1239,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
if ((virAsprintf(&diskAlias, "%s%s",
QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) ||
(virAsprintf(&nbd_dest, "nbd:%s:%d:exportname=%s",
host, port, diskAlias) < 0)) {
hoststr, port, diskAlias) < 0)) {
virReportOOMError();
goto error;
}
......@@ -1297,6 +1308,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
cleanup:
VIR_FREE(diskAlias);
VIR_FREE(nbd_dest);
VIR_FREE(hoststr);
return ret;
error:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册