mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
qemu: fix well-formed migration URI formatting
When adding an automatically allocated port to a well-formed migration URI, keep it well-formed: tcp://1.2.3.4/ -> tcp://1.2.3.4/:12345 # wrong tcp://1.2.3.4/ -> tcp://1.2.3.4:12345/ # fixed tcp://1.2.3.4 -> tcp://1.2.3.4:12345 # still works tcp:1.2.3.4 -> tcp:1.2.3.4:12345 # still works (old syntax) Signed-off-by: Michael Chapman <mike@very.puzzling.org>
This commit is contained in:
parent
919374c73e
commit
0883f3ba04
@ -2535,6 +2535,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
|
|||||||
char *uri_str = NULL;
|
char *uri_str = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virURIPtr uri = NULL;
|
virURIPtr uri = NULL;
|
||||||
|
bool well_formed_uri = true;
|
||||||
|
|
||||||
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
|
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
|
||||||
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
|
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
|
||||||
@ -2597,6 +2598,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
/* Convert uri_in to well-formed URI with // after tcp: */
|
/* Convert uri_in to well-formed URI with // after tcp: */
|
||||||
if (!(STRPREFIX(uri_in, "tcp://"))) {
|
if (!(STRPREFIX(uri_in, "tcp://"))) {
|
||||||
|
well_formed_uri = false;
|
||||||
if (virAsprintf(&uri_str, "tcp://%s", p) < 0)
|
if (virAsprintf(&uri_str, "tcp://%s", p) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -2626,9 +2628,17 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Caller frees */
|
if (well_formed_uri) {
|
||||||
if (virAsprintf(uri_out, "%s:%d", uri_in, port) < 0)
|
uri->port = port;
|
||||||
goto cleanup;
|
|
||||||
|
/* Caller frees */
|
||||||
|
if (!(*uri_out = virURIFormat(uri)))
|
||||||
|
goto cleanup;
|
||||||
|
} else {
|
||||||
|
/* Caller frees */
|
||||||
|
if (virAsprintf(uri_out, "%s:%d", uri_in, port) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
port = uri->port;
|
port = uri->port;
|
||||||
|
Loading…
Reference in New Issue
Block a user