提交 35820ad5 编写于 作者: J Jiri Denemark

Adapt virDomainMigratePeer2Peer for extensible migration APIs

上级 fa8b7c6a
...@@ -5075,73 +5075,69 @@ virDomainMigrateVersion3(virDomainPtr domain, ...@@ -5075,73 +5075,69 @@ virDomainMigrateVersion3(virDomainPtr domain,
* only talks to the source libvirtd instance. The source libvirtd * only talks to the source libvirtd instance. The source libvirtd
* then opens its own connection to the destination and co-ordinates * then opens its own connection to the destination and co-ordinates
* migration itself. * migration itself.
*
* If useParams is true, params and nparams contain migration parameters and
* we know it's safe to call the API which supports extensible parameters.
* Otherwise, we have to use xmlin, dname, uri, and bandwidth and pass them
* to the old-style APIs.
*/ */
static int static int
virDomainMigratePeer2Peer(virDomainPtr domain, virDomainMigratePeer2PeerFull(virDomainPtr domain,
const char *xmlin, const char *dconnuri,
unsigned long flags, const char *xmlin,
const char *dname, const char *dname,
const char *dconnuri, const char *uri,
const char *uri, unsigned long long bandwidth,
unsigned long bandwidth) virTypedParameterPtr params,
int nparams,
bool useParams,
unsigned int flags)
{ {
virURIPtr tempuri = NULL; virURIPtr tempuri = NULL;
VIR_DOMAIN_DEBUG(domain, "xmlin=%s, flags=%lx, dname=%s, "
"dconnuri=%s, uri=%s, bandwidth=%lu",
NULLSTR(xmlin), flags, NULLSTR(dname),
NULLSTR(dconnuri), NULLSTR(uri), bandwidth);
if (!domain->conn->driver->domainMigratePerform) { VIR_DOMAIN_DEBUG(domain,
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); "dconnuri=%s, xmlin=%s, dname=%s, uri=%s, bandwidth=%llu "
virDispatchError(domain->conn); "params=%p, nparams=%d, useParams=%d, flags=%x",
return -1; dconnuri, NULLSTR(xmlin), NULLSTR(dname), NULLSTR(uri),
} bandwidth, params, nparams, useParams, flags);
VIR_TYPED_PARAMS_DEBUG(params, nparams);
if (!(tempuri = virURIParse(dconnuri))) { if ((useParams && !domain->conn->driver->domainMigratePerform3Params) ||
virDispatchError(domain->conn); (!useParams &&
!domain->conn->driver->domainMigratePerform &&
!domain->conn->driver->domainMigratePerform3)) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
return -1; return -1;
} }
if (!tempuri->server) { if (!(tempuri = virURIParse(dconnuri)))
virReportInvalidArg(dconnuri,
_("unable to parse server from dconnuri in %s"),
__FUNCTION__);
virDispatchError(domain->conn);
virURIFree(tempuri);
return -1; return -1;
} if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) {
if (STRPREFIX(tempuri->server, "localhost")) {
virReportInvalidArg(dconnuri, virReportInvalidArg(dconnuri,
_("unable to parse server from dconnuri in %s"), _("unable to parse server from dconnuri in %s"),
__FUNCTION__); __FUNCTION__);
virDispatchError(domain->conn);
virURIFree(tempuri); virURIFree(tempuri);
return -1; return -1;
} }
virURIFree(tempuri); virURIFree(tempuri);
/* Perform the migration. The driver isn't supposed to return if (useParams) {
* until the migration is complete. VIR_DEBUG("Using migration protocol 3 with extensible parameters");
*/ return domain->conn->driver->domainMigratePerform3Params
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, (domain, dconnuri, params, nparams,
VIR_DRV_FEATURE_MIGRATION_V3)) { NULL, 0, NULL, NULL, flags);
} else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_V3)) {
VIR_DEBUG("Using migration protocol 3"); VIR_DEBUG("Using migration protocol 3");
return domain->conn->driver->domainMigratePerform3(domain, return domain->conn->driver->domainMigratePerform3
xmlin, (domain, xmlin, NULL, 0, NULL, NULL, dconnuri,
NULL, /* cookiein */ uri, flags, dname, bandwidth);
0, /* cookieinlen */
NULL, /* cookieoutlen */
NULL, /* cookieoutlen */
dconnuri,
uri,
flags,
dname,
bandwidth);
} else { } else {
VIR_DEBUG("Using migration protocol 2"); VIR_DEBUG("Using migration protocol 2");
if (xmlin) { if (xmlin) {
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s", virLibConnError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Unable to change target guest XML during migration")); _("Unable to change target guest XML "
"during migration"));
return -1; return -1;
} }
if (uri) { if (uri) {
...@@ -5149,16 +5145,24 @@ virDomainMigratePeer2Peer(virDomainPtr domain, ...@@ -5149,16 +5145,24 @@ virDomainMigratePeer2Peer(virDomainPtr domain,
_("Unable to override peer2peer migration URI")); _("Unable to override peer2peer migration URI"));
return -1; return -1;
} }
return domain->conn->driver->domainMigratePerform(domain, return domain->conn->driver->domainMigratePerform
NULL, /* cookie */ (domain, NULL, 0, dconnuri, flags, dname, bandwidth);
0, /* cookielen */
dconnuri,
flags,
dname,
bandwidth);
} }
} }
static int
virDomainMigratePeer2Peer(virDomainPtr domain,
const char *xmlin,
unsigned long flags,
const char *dname,
const char *dconnuri,
const char *uri,
unsigned long bandwidth)
{
return virDomainMigratePeer2PeerFull(domain, dconnuri, xmlin, dname, uri,
bandwidth, NULL, 0, false, flags);
}
/* /*
* In normal migration, the libvirt client co-ordinates communication * In normal migration, the libvirt client co-ordinates communication
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册