qemu: migrate: Don't require manual URI to specify a port

The xen driver will generate a migration port if only a hostname is passed
in the optional migrate URI, so let's do the same in qemu.
This commit is contained in:
Cole Robinson 2009-10-26 16:08:23 -04:00
parent 64f920d056
commit 33b35313a3

View File

@ -6314,15 +6314,32 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
/* Get the port number. */ /* Get the port number. */
p = strrchr (uri_in, ':'); p = strrchr (uri_in, ':');
p++; /* definitely has a ':' in it, see above */ if (p == strchr(uri_in, ':')) {
this_port = virParseNumber (&p); /* Generate a port */
if (this_port == -1 || p-uri_in != strlen (uri_in)) { this_port = QEMUD_MIGRATION_FIRST_PORT + port++;
qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, if (port == QEMUD_MIGRATION_NUM_PORTS)
"%s", _("URI did not have ':port' at the end")); port = 0;
goto cleanup;
/* Caller frees */
if (virAsprintf(uri_out, "%s:%d", uri_in, this_port) < 0) {
virReportOOMError (dconn);
goto cleanup;
}
} else {
p++; /* definitely has a ':' in it, see above */
this_port = virParseNumber (&p);
if (this_port == -1 || p-uri_in != strlen (uri_in)) {
qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG,
"%s", _("URI ended with incorrect ':port'"));
goto cleanup;
}
} }
} }
if (uri_out && *uri_out)
VIR_DEBUG("Generated uri_out=%s", *uri_out);
/* Parse the domain XML. */ /* Parse the domain XML. */
if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml, if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml,
VIR_DOMAIN_XML_INACTIVE))) { VIR_DOMAIN_XML_INACTIVE))) {