mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
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.
This commit is contained in:
parent
64919d978e
commit
2136327e23
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user