qemu: Always set migration capabilities

We used to set migration capabilities only when a user asked for them in
flags. This is fine when migration succeeds since the QEMU process is
killed in the end but in case migration fails or if it's cancelled, some
capabilities may remain turned on with no way to turn them off. To fix
that, migration capabilities have to be turned on if requested but
explicitly turned off in case they were not requested but QEMU supports
them.

https://bugzilla.redhat.com/show_bug.cgi?id=1163953
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2014-11-10 14:46:26 +01:00
parent 6b99642f0a
commit ab393383c8
6 changed files with 41 additions and 20 deletions

View File

@ -1805,6 +1805,7 @@ qemuMigrationSetOffline(virQEMUDriverPtr driver,
static int static int
qemuMigrationSetCompression(virQEMUDriverPtr driver, qemuMigrationSetCompression(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
bool state,
qemuDomainAsyncJob job) qemuDomainAsyncJob job)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
@ -1819,6 +1820,9 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
if (ret < 0) { if (ret < 0) {
goto cleanup; goto cleanup;
} else if (ret == 0 && !state) {
/* Unsupported but we want it off anyway */
goto cleanup;
} else if (ret == 0) { } else if (ret == 0) {
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) { if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@ -1835,7 +1839,8 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
ret = qemuMonitorSetMigrationCapability( ret = qemuMonitorSetMigrationCapability(
priv->mon, priv->mon,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE); QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
state);
cleanup: cleanup:
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
@ -1845,6 +1850,7 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
static int static int
qemuMigrationSetAutoConverge(virQEMUDriverPtr driver, qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
bool state,
qemuDomainAsyncJob job) qemuDomainAsyncJob job)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
@ -1859,6 +1865,9 @@ qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
if (ret < 0) { if (ret < 0) {
goto cleanup; goto cleanup;
} else if (ret == 0 && !state) {
/* Unsupported but we want it off anyway */
goto cleanup;
} else if (ret == 0) { } else if (ret == 0) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("Auto-Converge is not supported by " _("Auto-Converge is not supported by "
@ -1869,7 +1878,8 @@ qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
ret = qemuMonitorSetMigrationCapability( ret = qemuMonitorSetMigrationCapability(
priv->mon, priv->mon,
QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE); QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE,
state);
cleanup: cleanup:
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
@ -1880,6 +1890,7 @@ qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
static int static int
qemuMigrationSetPinAll(virQEMUDriverPtr driver, qemuMigrationSetPinAll(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
bool state,
qemuDomainAsyncJob job) qemuDomainAsyncJob job)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
@ -1894,6 +1905,9 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
if (ret < 0) { if (ret < 0) {
goto cleanup; goto cleanup;
} else if (ret == 0 && !state) {
/* Unsupported but we want it off anyway */
goto cleanup;
} else if (ret == 0) { } else if (ret == 0) {
if (job == QEMU_ASYNC_JOB_MIGRATION_IN) { if (job == QEMU_ASYNC_JOB_MIGRATION_IN) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@ -1910,7 +1924,8 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
ret = qemuMonitorSetMigrationCapability( ret = qemuMonitorSetMigrationCapability(
priv->mon, priv->mon,
QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL); QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
state);
cleanup: cleanup:
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
@ -2737,8 +2752,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
dataFD[1] = -1; /* 'st' owns the FD now & will close it */ dataFD[1] = -1; /* 'st' owns the FD now & will close it */
} }
if (flags & VIR_MIGRATE_COMPRESSED && if (qemuMigrationSetCompression(driver, vm,
qemuMigrationSetCompression(driver, vm, flags & VIR_MIGRATE_COMPRESSED,
QEMU_ASYNC_JOB_MIGRATION_IN) < 0) QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
goto stop; goto stop;
@ -2747,8 +2762,9 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
goto stop; goto stop;
} }
if (flags & VIR_MIGRATE_RDMA_PIN_ALL && if (qemuMigrationSetPinAll(driver, vm,
qemuMigrationSetPinAll(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) flags & VIR_MIGRATE_RDMA_PIN_ALL,
QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
goto stop; goto stop;
if (mig->lockState) { if (mig->lockState) {
@ -3572,18 +3588,18 @@ qemuMigrationRun(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
if (flags & VIR_MIGRATE_COMPRESSED && if (qemuMigrationSetCompression(driver, vm,
qemuMigrationSetCompression(driver, vm, flags & VIR_MIGRATE_COMPRESSED,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_MIGRATE_AUTO_CONVERGE && if (qemuMigrationSetAutoConverge(driver, vm,
qemuMigrationSetAutoConverge(driver, vm, flags & VIR_MIGRATE_AUTO_CONVERGE,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_MIGRATE_RDMA_PIN_ALL && if (qemuMigrationSetPinAll(driver, vm,
qemuMigrationSetPinAll(driver, vm, flags & VIR_MIGRATE_RDMA_PIN_ALL,
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup; goto cleanup;

View File

@ -3930,7 +3930,8 @@ int qemuMonitorGetMigrationCapability(qemuMonitorPtr mon,
} }
int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon, int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCaps capability) qemuMonitorMigrationCaps capability,
bool state)
{ {
VIR_DEBUG("mon=%p capability=%d", mon, capability); VIR_DEBUG("mon=%p capability=%d", mon, capability);
@ -3946,7 +3947,7 @@ int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
return -1; return -1;
} }
return qemuMonitorJSONSetMigrationCapability(mon, capability); return qemuMonitorJSONSetMigrationCapability(mon, capability, state);
} }
int qemuMonitorNBDServerStart(qemuMonitorPtr mon, int qemuMonitorNBDServerStart(qemuMonitorPtr mon,

View File

@ -506,7 +506,8 @@ int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
int qemuMonitorGetMigrationCapability(qemuMonitorPtr mon, int qemuMonitorGetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCaps capability); qemuMonitorMigrationCaps capability);
int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon, int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCaps capability); qemuMonitorMigrationCaps capability,
bool state);
typedef enum { typedef enum {
QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0, QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0,

View File

@ -5597,7 +5597,8 @@ qemuMonitorJSONGetMigrationCapability(qemuMonitorPtr mon,
int int
qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon, qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCaps capability) qemuMonitorMigrationCaps capability,
bool state)
{ {
int ret = -1; int ret = -1;
@ -5617,7 +5618,7 @@ qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCapsTypeToString(capability)) < 0) qemuMonitorMigrationCapsTypeToString(capability)) < 0)
goto cleanup; goto cleanup;
if (virJSONValueObjectAppendBoolean(cap, "state", 1) < 0) if (virJSONValueObjectAppendBoolean(cap, "state", state) < 0)
goto cleanup; goto cleanup;
if (virJSONValueArrayAppend(caps, cap) < 0) if (virJSONValueArrayAppend(caps, cap) < 0)

View File

@ -142,7 +142,8 @@ int qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
int qemuMonitorJSONGetMigrationCapability(qemuMonitorPtr mon, int qemuMonitorJSONGetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCaps capability); qemuMonitorMigrationCaps capability);
int qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon, int qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon,
qemuMonitorMigrationCaps capability); qemuMonitorMigrationCaps capability,
bool state);
int qemuMonitorJSONMigrate(qemuMonitorPtr mon, int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
unsigned int flags, unsigned int flags,

View File

@ -1939,7 +1939,8 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapability(const void *data)
} }
if (qemuMonitorJSONSetMigrationCapability(qemuMonitorTestGetMonitor(test), if (qemuMonitorJSONSetMigrationCapability(qemuMonitorTestGetMonitor(test),
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE) < 0) QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
true) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;