From nobody Wed May 14 13:48:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523457790009350.3996191431073; Wed, 11 Apr 2018 07:43:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BE35313772F; Wed, 11 Apr 2018 14:43:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D0BFA099C; Wed, 11 Apr 2018 14:43:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DAE3D181B9FF; Wed, 11 Apr 2018 14:43:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3BEgFsu008744 for ; Wed, 11 Apr 2018 10:42:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 261F110B0F39; Wed, 11 Apr 2018 14:42:15 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C259310B0F3A for ; Wed, 11 Apr 2018 14:42:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 584B91005EF; Wed, 11 Apr 2018 16:42:10 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:41:16 +0200 Message-Id: <5d0d3b2e876b3c97463daa77d7bfa622119ad776.1523456479.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 26/73] qemu: Set migration caps via migration params APIs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 11 Apr 2018 14:43:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Migration capabilities are closely related to migration parameters and it makes sense to keep them in a single data structure. Similarly to migration parameters the capabilities are all send to QEMU at once in qemuMigrationParamsApply, all other APIs operate on the qemuMigrationParams structure. Signed-off-by: Jiri Denemark Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_migration.c | 100 ++++++------------------------- src/qemu/qemu_migration.h | 7 --- src/qemu/qemu_migration_params.c | 99 +++++++++++++++++++++++------- src/qemu/qemu_migration_params.h | 11 ++++ 4 files changed, 107 insertions(+), 110 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 602ccdfdd5..e01c2a209d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1174,66 +1174,6 @@ qemuMigrationAnyPostcopyFailed(virQEMUDriverPtr driv= er, } =20 =20 -int -qemuMigrationOptionSet(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuMonitorMigrationCaps capability, - bool state, - qemuDomainAsyncJob job) -{ - qemuDomainObjPrivatePtr priv =3D vm->privateData; - int ret; - - if (!qemuMigrationCapsGet(vm, capability)) { - if (!state) { - /* Unsupported but we want it off anyway */ - return 0; - } - - if (job =3D=3D QEMU_ASYNC_JOB_MIGRATION_IN) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, - _("Migration option '%s' is not supported by " - "target QEMU binary"), - qemuMonitorMigrationCapsTypeToString(capability= )); - } else { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, - _("Migration option '%s' is not supported by " - "source QEMU binary"), - qemuMonitorMigrationCapsTypeToString(capability= )); - } - return -1; - } - - if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0) - return -1; - - ret =3D qemuMonitorSetMigrationCapability(priv->mon, capability, state= ); - - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret =3D -1; - - return ret; -} - - -static int -qemuMigrationOptionSetPostCopy(virQEMUDriverPtr driver, - virDomainObjPtr vm, - bool state, - qemuDomainAsyncJob job) -{ - qemuDomainObjPrivatePtr priv =3D vm->privateData; - - if (qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY, - state, job) < 0) - return -1; - - priv->job.postcopyEnabled =3D state; - return 0; -} - - static int qemuMigrationSrcWaitForSpice(virDomainObjPtr vm) { @@ -2465,15 +2405,14 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, goto stopjob; } =20 - if (qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, - flags & VIR_MIGRATE_RDMA_PIN_ALL, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) + if (qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_RDMA_= PIN_ALL, + flags & VIR_MIGRATE_RDMA_PIN_ALL, + migParams) < 0) goto stopjob; =20 - if (qemuMigrationOptionSetPostCopy(driver, vm, - flags & VIR_MIGRATE_POSTCOPY, - QEMU_ASYNC_JOB_MIGRATION_IN) < 0) + if (qemuMigrationParamsSetPostCopy(vm, flags & VIR_MIGRATE_POSTCOPY, + migParams) < 0) goto stopjob; =20 if (qemuMigrationParamsApply(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, @@ -3448,27 +3387,26 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, compression, migParams) < 0) goto error; =20 - if (qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE, - flags & VIR_MIGRATE_AUTO_CONVERGE, - QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) + if (qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_AUTO_= CONVERGE, + flags & VIR_MIGRATE_AUTO_CONVERGE, + migParams) < 0) goto error; =20 - if (qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL, - flags & VIR_MIGRATE_RDMA_PIN_ALL, - QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) + if (qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_RDMA_= PIN_ALL, + flags & VIR_MIGRATE_RDMA_PIN_ALL, + migParams) < 0) goto error; =20 - if (qemuMigrationOptionSetPostCopy(driver, vm, - flags & VIR_MIGRATE_POSTCOPY, - QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) + if (qemuMigrationParamsSetPostCopy(vm, flags & VIR_MIGRATE_POSTCOPY, + migParams) < 0) goto error; =20 if (qemuMigrationCapsGet(vm, QEMU_MONITOR_MIGRATION_CAPS_PAUSE_BEFORE_= SWITCHOVER) && - qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_PAUSE_BEFORE_SW= ITCHOVER, - true, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) + qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_PAUSE= _BEFORE_SWITCHOVER, + true, migParams) < 0) goto error; =20 if (qemuMigrationParamsApply(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index e59296fd63..fc81eb5016 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -273,11 +273,4 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driv= er, qemuDomainAsyncJob asyncJob, qemuDomainJobInfoPtr jobInfo); =20 -int -qemuMigrationOptionSet(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuMonitorMigrationCaps capability, - bool state, - qemuDomainAsyncJob job); - #endif /* __QEMU_MIGRATION_H__ */ diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 4ca49d942e..d934a93086 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -39,6 +39,7 @@ VIR_LOG_INIT("qemu.qemu_migration_params"); #define QEMU_MIGRATION_TLS_ALIAS_BASE "libvirt_migrate" =20 struct _qemuMigrationParams { + virBitmapPtr caps; qemuMonitorMigrationParams params; }; =20 @@ -51,7 +52,15 @@ qemuMigrationParamsNew(void) if (VIR_ALLOC(params) < 0) return NULL; =20 + params->caps =3D virBitmapNew(QEMU_MONITOR_MIGRATION_CAPS_LAST); + if (!params->caps) + goto error; + return params; + + error: + qemuMigrationParamsFree(params); + return NULL; } =20 =20 @@ -61,6 +70,7 @@ qemuMigrationParamsFree(qemuMigrationParamsPtr migParams) if (!migParams) return; =20 + virBitmapFree(migParams->caps); VIR_FREE(migParams->params.tlsCreds); VIR_FREE(migParams->params.tlsHostname); VIR_FREE(migParams); @@ -136,6 +146,10 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; =20 + if (qemuMonitorSetMigrationCapabilities(priv->mon, priv->migrationCaps, + migParams->caps) < 0) + goto cleanup; + if (qemuMonitorSetMigrationParams(priv->mon, &migParams->params) < 0) goto cleanup; =20 @@ -149,6 +163,50 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, } =20 =20 +int +qemuMigrationParamsSetCapability(virDomainObjPtr vm, + qemuMonitorMigrationCaps capability, + bool state, + qemuMigrationParamsPtr migParams) +{ + if (!qemuMigrationCapsGet(vm, capability)) { + if (!state) { + /* Unsupported but we want it off anyway */ + return 0; + } + + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("Migration option '%s' is not supported by QEMU b= inary"), + qemuMonitorMigrationCapsTypeToString(capability)); + return -1; + } + + if (state) + ignore_value(virBitmapSetBit(migParams->caps, capability)); + else + ignore_value(virBitmapClearBit(migParams->caps, capability)); + + return 0; +} + + +int +qemuMigrationParamsSetPostCopy(virDomainObjPtr vm, + bool state, + qemuMigrationParamsPtr migParams) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_POSTC= OPY, + state, migParams) < 0) + return -1; + + priv->job.postcopyEnabled =3D state; + return 0; +} + + /* qemuMigrationParamsEnableTLS * @driver: pointer to qemu driver * @vm: domain object @@ -272,18 +330,18 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr dr= iver, int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 - if (qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_XBZRLE, - compression->methods & - (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE), - asyncJob) < 0) + if (qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_XBZRL= E, + compression->methods & + (1ULL << QEMU_MIGRATION_COMPRESS_= XBZRLE), + migParams) < 0) return -1; =20 - if (qemuMigrationOptionSet(driver, vm, - QEMU_MONITOR_MIGRATION_CAPS_COMPRESS, - compression->methods & - (1ULL << QEMU_MIGRATION_COMPRESS_MT), - asyncJob) < 0) + if (qemuMigrationParamsSetCapability(vm, + QEMU_MONITOR_MIGRATION_CAPS_COMPR= ESS, + compression->methods & + (1ULL << QEMU_MIGRATION_COMPRESS_= MT), + migParams) < 0) return -1; =20 if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -369,6 +427,11 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver, if (!(origParams =3D qemuMigrationParamsNew())) goto cleanup; =20 + /* + * We want to disable all migration capabilities after migration, no n= eed + * to ask QEMU for their current settings. + */ + if (qemuMonitorGetMigrationParams(priv->mon, &origParams->params) < 0) goto cleanup; =20 @@ -398,25 +461,17 @@ qemuMigrationParamsReset(virQEMUDriverPtr driver, int asyncJob, qemuMigrationParamsPtr origParams) { - qemuMonitorMigrationCaps cap; virErrorPtr err =3D virSaveLastError(); =20 VIR_DEBUG("Resetting migration parameters %p", origParams); =20 - if (!virDomainObjIsActive(vm)) + if (!virDomainObjIsActive(vm) || !origParams) goto cleanup; =20 - if (origParams) { - if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams) < 0) - goto cleanup; - qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams); - } + if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams) < 0) + goto cleanup; =20 - for (cap =3D 0; cap < QEMU_MONITOR_MIGRATION_CAPS_LAST; cap++) { - if (qemuMigrationCapsGet(vm, cap) && - qemuMigrationOptionSet(driver, vm, cap, false, asyncJob) < 0) - goto cleanup; - } + qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams); =20 cleanup: if (err) { diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 37e528f36c..e341f73900 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -68,6 +68,17 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, int asyncJob, qemuMigrationParamsPtr migParams); =20 +int +qemuMigrationParamsSetCapability(virDomainObjPtr vm, + qemuMonitorMigrationCaps capability, + bool state, + qemuMigrationParamsPtr migParams); + +int +qemuMigrationParamsSetPostCopy(virDomainObjPtr vm, + bool state, + qemuMigrationParamsPtr migParams); + int qemuMigrationParamsEnableTLS(virQEMUDriverPtr driver, virDomainObjPtr vm, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list