提交 a26669d7 编写于 作者: N Nikolay Shirokovskiy 提交者: Jiri Denemark

migration: refactor: introduce parameter checking function

virDomainMigrateUnmanagedParams is not a good candidate for this functionality
as it is used by migrate family functions too and its have its own checks that
are superset of extracted and we don't need to check twice.

Actually name of the function is slightly misleading as there is also a check
for consistensy of flags parameter alone. So it could be refactored further and
reused by all migrate functions but for now let it be a matter of a different
patchset.

It is *not* a pure refactoring patch as it introduces offline check for older
versions. Looks like it must be done that way and no one will be broken too.
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 06c910ea
master openEuler-20.03-LTS openEuler-20.09 v1.2.21-maint v1.3.0-maint v1.3.1-maint v1.3.2-maint v1.3.3-maint v1.3.4-maint v1.3.5-maint v2.0-maint v2.1-maint v2.2-maint v3.0-maint v3.2-maint v3.7-maint v4.1-maint v4.10-maint v4.2-maint v4.3-maint v4.4-maint v4.5-maint v4.6-maint v4.7-maint v4.8-maint v4.9-maint v5.0-maint v5.1-maint v5.1.0-maint v5.2-maint v5.3-maint v6.5.0-rc2 v6.5.0-rc1 v6.4.0 v6.4.0-rc1 v6.3.0 v6.3.0-rc1 v6.2.0 v6.2.0-rc1 v6.1.0 v6.1.0-rc2 v6.1.0-rc1 v6.0.0 v6.0.0-rc2 v6.0.0-rc1 v5.10.0 v5.10.0-rc2 v5.10.0-rc1 v5.9.0 v5.9.0-rc1 v5.8.0 v5.8.0-rc2 v5.8.0-rc1 v5.7.0 v5.7.0-rc2 v5.7.0-rc1 v5.6.0 v5.6.0-rc2 v5.6.0-rc1 v5.5.0 v5.5.0-rc2 v5.5.0-rc1 v5.4.0 v5.4.0-rc2 v5.4.0-rc1 v5.3.0 v5.3.0-rc2 v5.3.0-rc1 v5.2.0 v5.2.0-rc2 v5.2.0-rc1 v5.1.0 v5.1.0-rc2 v5.1.0-rc1 v5.0.0 v5.0.0-rc2 v5.0.0-rc1 v4.10.0 v4.10.0-rc2 v4.10.0-rc1 v4.9.0 v4.9.0-rc1 v4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139,45 @@ virDomainMigrate3(virDomainPtr domain,
}
static
int virDomainMigrateUnmanagedCheckCompat(virDomainPtr domain,
unsigned int flags)
{
VIR_EXCLUSIVE_FLAGS_RET(VIR_MIGRATE_NON_SHARED_DISK,
VIR_MIGRATE_NON_SHARED_INC,
-1);
if (flags & VIR_MIGRATE_OFFLINE &&
!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
return -1;
}
if (flags & VIR_MIGRATE_PEER2PEER) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_P2P)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("p2p migration is not supported by "
"the source host"));
return -1;
}
} else {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_DIRECT)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("direct migration is not supported by "
"the source host"));
return -1;
}
}
return 0;
}
/**
* virDomainMigrateToURI:
* @domain: a domain object
......@@ -4217,6 +4256,9 @@ virDomainMigrateToURI(virDomainPtr domain,
const char *dname,
unsigned long bandwidth)
{
const char *dconnuri = NULL;
const char *miguri = NULL;
VIR_DOMAIN_DEBUG(domain, "duri=%p, flags=%lx, dname=%s, bandwidth=%lu",
NULLSTR(duri), flags, NULLSTR(dname), bandwidth);
......@@ -4225,49 +4267,19 @@ virDomainMigrateToURI(virDomainPtr domain,
/* First checkout the source */
virCheckDomainReturn(domain, -1);
virCheckReadOnlyGoto(domain->conn->flags, error);
virCheckNonNullArgGoto(duri, error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_MIGRATE_NON_SHARED_DISK,
VIR_MIGRATE_NON_SHARED_INC,
error);
if (flags & VIR_MIGRATE_OFFLINE &&
!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
if (virDomainMigrateUnmanagedCheckCompat(domain, flags) < 0)
goto error;
}
if (flags & VIR_MIGRATE_PEER2PEER) {
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_P2P)) {
VIR_DEBUG("Using peer2peer migration");
if (virDomainMigrateUnmanaged(domain, NULL, flags,
dname, duri, NULL, bandwidth) < 0)
goto error;
} else {
/* No peer to peer migration supported */
virReportUnsupportedError();
goto error;
}
} else {
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_DIRECT)) {
VIR_DEBUG("Using direct migration");
if (virDomainMigrateUnmanaged(domain, NULL, flags,
dname, NULL, duri, bandwidth) < 0)
goto error;
} else {
/* Cannot do a migration with only the perform step */
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("direct migration is not supported by the"
" connection driver"));
goto error;
}
}
if (flags & VIR_MIGRATE_PEER2PEER)
dconnuri = duri;
else
miguri = duri;
if (virDomainMigrateUnmanaged(domain, NULL, flags,
dname, dconnuri, miguri, bandwidth) < 0)
goto error;
return 0;
......@@ -4383,37 +4395,15 @@ virDomainMigrateToURI2(virDomainPtr domain,
virCheckDomainReturn(domain, -1);
virCheckReadOnlyGoto(domain->conn->flags, error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_MIGRATE_NON_SHARED_DISK,
VIR_MIGRATE_NON_SHARED_INC,
error);
if (virDomainMigrateUnmanagedCheckCompat(domain, flags) < 0)
goto error;
if (flags & VIR_MIGRATE_PEER2PEER) {
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_P2P)) {
VIR_DEBUG("Using peer2peer migration");
if (virDomainMigrateUnmanaged(domain, dxml, flags,
dname, dconnuri, miguri, bandwidth) < 0)
goto error;
} else {
/* No peer to peer migration supported */
virReportUnsupportedError();
goto error;
}
} else {
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_DIRECT)) {
VIR_DEBUG("Using direct migration");
if (virDomainMigrateUnmanaged(domain, dxml, flags,
dname, NULL, miguri, bandwidth) < 0)
goto error;
} else {
/* Cannot do a migration with only the perform step */
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("direct migration is not supported by the"
" connection driver"));
goto error;
}
}
if (!(flags & VIR_MIGRATE_PEER2PEER))
dconnuri = NULL;
if (virDomainMigrateUnmanaged(domain, NULL, flags,
dname, dconnuri, miguri, bandwidth) < 0)
goto error;
return 0;
......@@ -4477,37 +4467,15 @@ virDomainMigrateToURI3(virDomainPtr domain,
virCheckDomainReturn(domain, -1);
virCheckReadOnlyGoto(domain->conn->flags, error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_MIGRATE_NON_SHARED_DISK,
VIR_MIGRATE_NON_SHARED_INC,
error);
if (flags & VIR_MIGRATE_PEER2PEER) {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_P2P)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Peer-to-peer migration is not supported by "
"the connection driver"));
goto error;
}
if (virDomainMigrateUnmanagedCheckCompat(domain, flags) < 0)
goto error;
VIR_DEBUG("Using peer2peer migration");
if (virDomainMigrateUnmanagedParams(domain, dconnuri, params, nparams, flags) < 0)
goto error;
} else {
if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_MIGRATION_DIRECT)) {
/* Cannot do a migration with only the perform step */
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Direct migration is not supported by the"
" connection driver"));
goto error;
}
if (!(flags & VIR_MIGRATE_PEER2PEER))
dconnuri = NULL;
VIR_DEBUG("Using direct migration");
if (virDomainMigrateUnmanagedParams(domain, NULL, params,
nparams, flags) < 0)
goto error;
}
if (virDomainMigrateUnmanagedParams(domain, dconnuri,
params, nparams, flags) < -1)
goto error;
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部