}
}
+ /* 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:
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;
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;
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 "
"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;
}
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;
}
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;
+}
qemuDomainAsyncJob asyncJob,
qemuDomainJobInfoPtr jobInfo);
+bool
+qemuMigrationCapsGet(virDomainObjPtr vm,
+ qemuMonitorMigrationCaps cap);
+
#endif /* __QEMU_MIGRATION_H__ */