From 78bd04707513f511eac4bb6994c6e8298f708f24 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 7 Mar 2018 15:59:42 +0100 Subject: [PATCH] qemu: Set always-on migration caps in ParamsCheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some migration capabilities are always enabled if QEMU supports them. We can just drop the explicit code for them and let qemuMigrationParamsCheck automatically set such capabilities. QEMU_MONITOR_MIGRATION_CAPS_EVENTS would normally be one of the always on features, but it is the only feature we want to enable even for other jobs which internally use migration (such as save and snapshot). Hence this capability is set very early after libvirtd connects to QEMU monitor. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- src/qemu/qemu_migration.c | 6 ------ src/qemu/qemu_migration_params.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 400eb0710c..0446003f47 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3359,12 +3359,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, migParams) < 0) goto error; - if (qemuMigrationCapsGet(vm, QEMU_MONITOR_MIGRATION_CAPS_PAUSE_BEFORE_SWITCHOVER) && - qemuMigrationParamsSetCapability(vm, - QEMU_MONITOR_MIGRATION_CAPS_PAUSE_BEFORE_SWITCHOVER, - true, migParams) < 0) - goto error; - if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, migParams) < 0) goto error; diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index bf95fb4f59..03056eed09 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -43,6 +43,19 @@ struct _qemuMigrationParams { qemuMonitorMigrationParams params; }; +typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOnItem; +struct _qemuMigrationParamsAlwaysOnItem { + 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[] = { + {QEMU_MONITOR_MIGRATION_CAPS_PAUSE_BEFORE_SWITCHOVER, + QEMU_MIGRATION_SOURCE}, +}; + static qemuMigrationParamsPtr qemuMigrationParamsNew(void) @@ -399,8 +412,15 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; qemuMigrationParamsPtr origParams = NULL; qemuMonitorMigrationCaps cap; + qemuMigrationParty party; + size_t i; int ret = -1; + if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) + party = QEMU_MIGRATION_SOURCE; + else + party = QEMU_MIGRATION_DESTINATION; + for (cap = 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) { bool state = false; @@ -414,6 +434,17 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver, } } + for (i = 0; i < ARRAY_CARDINALITY(qemuMigrationParamsAlwaysOn); i++) { + cap = qemuMigrationParamsAlwaysOn[i].cap; + + if (qemuMigrationParamsAlwaysOn[i].party & party && + qemuMigrationCapsGet(vm, cap)) { + VIR_DEBUG("Enabling migration capability '%s'", + qemuMonitorMigrationCapsTypeToString(cap)); + ignore_value(virBitmapSetBit(migParams->caps, cap)); + } + } + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1;