mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: Use bitmap with migration capabilities
All calls to qemuMonitorGetMigrationCapability in QEMU driver are replaced with qemuMigrationCapsGet. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
765d9b1245
commit
310287b1c9
@ -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;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -13434,20 +13434,17 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom,
|
|||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
if (!qemuMigrationCapsGet(vm, QEMU_MONITOR_MIGRATION_CAPS_XBZRLE)) {
|
||||||
|
|
||||||
ret = qemuMonitorGetMigrationCapability(
|
|
||||||
priv->mon,
|
|
||||||
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE);
|
|
||||||
if (ret == 0) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("Compressed migration is not supported by "
|
_("Compressed migration is not supported by "
|
||||||
"QEMU binary"));
|
"QEMU binary"));
|
||||||
ret = -1;
|
goto endjob;
|
||||||
} else if (ret > 0) {
|
|
||||||
ret = qemuMonitorGetMigrationCacheSize(priv->mon, cacheSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
|
ret = qemuMonitorGetMigrationCacheSize(priv->mon, cacheSize);
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
@ -13488,20 +13485,17 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
|
|||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
if (!qemuMigrationCapsGet(vm, QEMU_MONITOR_MIGRATION_CAPS_XBZRLE)) {
|
||||||
|
|
||||||
ret = qemuMonitorGetMigrationCapability(
|
|
||||||
priv->mon,
|
|
||||||
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE);
|
|
||||||
if (ret == 0) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("Compressed migration is not supported by "
|
_("Compressed migration is not supported by "
|
||||||
"QEMU binary"));
|
"QEMU binary"));
|
||||||
ret = -1;
|
goto endjob;
|
||||||
} else if (ret > 0) {
|
}
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
VIR_DEBUG("Setting compression cache to %llu B", cacheSize);
|
VIR_DEBUG("Setting compression cache to %llu B", cacheSize);
|
||||||
ret = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize);
|
ret = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize);
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -1274,17 +1274,12 @@ qemuMigrationSetOption(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
|
if (!qemuMigrationCapsGet(vm, capability)) {
|
||||||
return -1;
|
if (!state) {
|
||||||
|
|
||||||
ret = qemuMonitorGetMigrationCapability(priv->mon, capability);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
goto cleanup;
|
|
||||||
} else if (ret == 0 && !state) {
|
|
||||||
/* Unsupported but we want it off anyway */
|
/* Unsupported but we want it off anyway */
|
||||||
goto cleanup;
|
return 0;
|
||||||
} else if (ret == 0) {
|
}
|
||||||
|
|
||||||
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
|
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
|
||||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
|
||||||
_("Migration option '%s' is not supported by "
|
_("Migration option '%s' is not supported by "
|
||||||
@ -1296,15 +1291,17 @@ qemuMigrationSetOption(virQEMUDriverPtr driver,
|
|||||||
"source QEMU binary"),
|
"source QEMU binary"),
|
||||||
qemuMonitorMigrationCapsTypeToString(capability));
|
qemuMonitorMigrationCapsTypeToString(capability));
|
||||||
}
|
}
|
||||||
ret = -1;
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
ret = qemuMonitorSetMigrationCapability(priv->mon, capability, state);
|
ret = qemuMonitorSetMigrationCapability(priv->mon, capability, state);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5928,12 +5925,8 @@ qemuMigrationReset(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
|
for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) {
|
||||||
/* "events" capability is set (when supported) in qemuConnectMonitor
|
if (qemuMigrationCapsGet(vm, cap) &&
|
||||||
* and should never be cleared */
|
qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
|
||||||
if (cap == QEMU_MONITOR_MIGRATION_CAPS_EVENTS)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (qemuMigrationSetOption(driver, vm, cap, false, job) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5994,3 +5987,17 @@ qemuMigrationFetchMirrorStats(virQEMUDriverPtr driver,
|
|||||||
virHashFree(blockinfo);
|
virHashFree(blockinfo);
|
||||||
return 0;
|
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,
|
qemuDomainAsyncJob asyncJob,
|
||||||
qemuDomainJobInfoPtr jobInfo);
|
qemuDomainJobInfoPtr jobInfo);
|
||||||
|
|
||||||
|
bool
|
||||||
|
qemuMigrationCapsGet(virDomainObjPtr vm,
|
||||||
|
qemuMonitorMigrationCaps cap);
|
||||||
|
|
||||||
#endif /* __QEMU_MIGRATION_H__ */
|
#endif /* __QEMU_MIGRATION_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user