提交 a1b0557e 编写于 作者: J Jiri Denemark

qemu: Set migration capabilities automatically

Most migration capabilities are directly connected with
virDomainMigrateFlags so qemuMigrationParamsFromFlags can automatically
enable them.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 78bd0470
......@@ -2385,18 +2385,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
goto stopjob;
}
if (qemuMigrationParamsSetCapability(vm,
QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
flags & VIR_MIGRATE_RDMA_PIN_ALL,
migParams) < 0)
goto stopjob;
if (qemuMigrationParamsSetCapability(vm,
QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY,
flags & VIR_MIGRATE_POSTCOPY,
migParams) < 0)
goto stopjob;
if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN,
migParams) < 0)
goto stopjob;
......@@ -3341,24 +3329,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
if (qemuMigrationParamsSetCompression(vm, compression, migParams) < 0)
goto error;
if (qemuMigrationParamsSetCapability(vm,
QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE,
flags & VIR_MIGRATE_AUTO_CONVERGE,
migParams) < 0)
goto error;
if (qemuMigrationParamsSetCapability(vm,
QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
flags & VIR_MIGRATE_RDMA_PIN_ALL,
migParams) < 0)
goto error;
if (qemuMigrationParamsSetCapability(vm,
QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY,
flags & VIR_MIGRATE_POSTCOPY,
migParams) < 0)
goto error;
if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
migParams) < 0)
goto error;
......
......@@ -49,6 +49,13 @@ struct _qemuMigrationParamsAlwaysOnItem {
int party; /* bit-wise OR of qemuMigrationParty */
};
typedef struct _qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMapItem;
struct _qemuMigrationParamsFlagMapItem {
virDomainMigrateFlags flag;
qemuMonitorMigrationCaps cap;
int party; /* bit-wise OR of qemuMigrationParty */
};
/* Migration capabilities which should always be enabled as long as they
* are supported by QEMU. */
static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = {
......@@ -56,6 +63,21 @@ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = {
QEMU_MIGRATION_SOURCE},
};
/* Translation from virDomainMigrateFlags to qemuMonitorMigrationCaps. */
static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = {
{VIR_MIGRATE_RDMA_PIN_ALL,
QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
{VIR_MIGRATE_AUTO_CONVERGE,
QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE,
QEMU_MIGRATION_SOURCE},
{VIR_MIGRATE_POSTCOPY,
QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY,
QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
};
static qemuMigrationParamsPtr
qemuMigrationParamsNew(void)
......@@ -97,12 +119,21 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
qemuMigrationParty party)
{
qemuMigrationParamsPtr migParams;
size_t i;
if (!(migParams = qemuMigrationParamsNew()))
return NULL;
if (!params)
return migParams;
for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsFlagMap); i++) {
qemuMonitorMigrationCaps cap = qemuMigrationParamsFlagMap[i].cap;
if (qemuMigrationParamsFlagMap[i].party & party &&
flags & qemuMigrationParamsFlagMap[i].flag) {
VIR_DEBUG("Enabling migration capability '%s'",
qemuMonitorMigrationCapsTypeToString(cap));
ignore_value(virBitmapSetBit(migParams->caps, cap));
}
}
#define GET(PARAM, VAR) \
do { \
......@@ -116,10 +147,12 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
migParams->params.VAR ## _set = true; \
} while (0)
if (params) {
if (party == QEMU_MIGRATION_SOURCE) {
GET(AUTO_CONVERGE_INITIAL, cpuThrottleInitial);
GET(AUTO_CONVERGE_INCREMENT, cpuThrottleIncrement);
}
}
#undef GET
......@@ -197,7 +230,7 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
}
int
static int
qemuMigrationParamsSetCapability(virDomainObjPtr vm ATTRIBUTE_UNUSED,
qemuMonitorMigrationCaps capability,
bool state,
......
......@@ -71,12 +71,6 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver,
int asyncJob,
qemuMigrationParamsPtr migParams);
int
qemuMigrationParamsSetCapability(virDomainObjPtr vm,
qemuMonitorMigrationCaps capability,
bool state,
qemuMigrationParamsPtr migParams);
int
qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver,
virDomainObjPtr vm,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册