提交 310287b1 编写于 作者: J Jiri Denemark

qemu: Use bitmap with migration capabilities

All calls to qemuMonitorGetMigrationCapability in QEMU driver are
replaced with qemuMigrationCapsGet.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 765d9b12
......@@ -10304,6 +10304,13 @@ qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver,
}
}
/* Migration events capability must always be enabled, clearing it from
* migration capabilities bitmap makes sure it won't be touched anywhere
* else.
*/
ignore_value(virBitmapClearBit(priv->migrationCaps,
QEMU_MONITOR_MIGRATION_CAPS_EVENTS));
ret = 0;
cleanup:
......
......@@ -13434,20 +13434,17 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom,
priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetMigrationCapability(
priv->mon,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE);
if (ret == 0) {
if (!qemuMigrationCapsGet(vm, QEMU_MONITOR_MIGRATION_CAPS_XBZRLE)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Compressed migration is not supported by "
"QEMU binary"));
ret = -1;
} else if (ret > 0) {
ret = qemuMonitorGetMigrationCacheSize(priv->mon, cacheSize);
goto endjob;
}
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetMigrationCacheSize(priv->mon, cacheSize);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
......@@ -13488,21 +13485,18 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetMigrationCapability(
priv->mon,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE);
if (ret == 0) {
if (!qemuMigrationCapsGet(vm, QEMU_MONITOR_MIGRATION_CAPS_XBZRLE)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("Compressed migration is not supported by "
"QEMU binary"));
ret = -1;
} else if (ret > 0) {
VIR_DEBUG("Setting compression cache to %llu B", cacheSize);
ret = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize);
goto endjob;
}
qemuDomainObjEnterMonitor(driver, vm);
VIR_DEBUG("Setting compression cache to %llu B", cacheSize);
ret = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
......
......@@ -1274,17 +1274,12 @@ qemuMigrationSetOption(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret;
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
return -1;
ret = qemuMonitorGetMigrationCapability(priv->mon, capability);
if (!qemuMigrationCapsGet(vm, capability)) {
if (!state) {
/* Unsupported but we want it off anyway */
return 0;
}
if (ret < 0) {
goto cleanup;
} else if (ret == 0 && !state) {
/* Unsupported but we want it off anyway */
goto cleanup;
} else if (ret == 0) {
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
_("Migration option '%s' is not supported by "
......@@ -1296,15 +1291,17 @@ qemuMigrationSetOption(virQEMUDriverPtr driver,
"source QEMU binary"),
qemuMonitorMigrationCapsTypeToString(capability));
}
ret = -1;
goto cleanup;
return -1;
}
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
return -1;
ret = qemuMonitorSetMigrationCapability(priv->mon, capability, state);
cleanup:
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
return ret;
}
......@@ -5928,12 +5925,8 @@ qemuMigrationReset(virQEMUDriverPtr driver,
goto cleanup;
for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
/* "events" capability is set (when supported) in qemuConnectMonitor
* and should never be cleared */
if (cap == QEMU_MONITOR_MIGRATION_CAPS_EVENTS)
continue;
if (qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
if (qemuMigrationCapsGet(vm, cap) &&
qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
goto cleanup;
}
......@@ -5994,3 +5987,17 @@ qemuMigrationFetchMirrorStats(virQEMUDriverPtr driver,
virHashFree(blockinfo);
return 0;
}
bool
qemuMigrationCapsGet(virDomainObjPtr vm,
qemuMonitorMigrationCaps cap)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
bool enabled = false;
if (priv->migrationCaps)
ignore_value(virBitmapGetBit(priv->migrationCaps, cap, &enabled));
return enabled;
}
......@@ -326,4 +326,8 @@ qemuMigrationFetchMirrorStats(virQEMUDriverPtr driver,
qemuDomainAsyncJob asyncJob,
qemuDomainJobInfoPtr jobInfo);
bool
qemuMigrationCapsGet(virDomainObjPtr vm,
qemuMonitorMigrationCaps cap);
#endif /* __QEMU_MIGRATION_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册