From nobody Tue Apr 23 08:31:49 2024 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 1549380212928141.91831120258496; Tue, 5 Feb 2019 07:23:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2577B2D805; Tue, 5 Feb 2019 15:23:30 +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 AFA0E17CEE; Tue, 5 Feb 2019 15:23:29 +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 BF84918005CB; Tue, 5 Feb 2019 15:23:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNG0v008321 for ; Tue, 5 Feb 2019 10:23:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7611971CBA; Tue, 5 Feb 2019 15:23:16 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A54D71C8D for ; Tue, 5 Feb 2019 15:23:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CEA071001FC; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:04 +0100 Message-Id: <73b06f3edef897571f66ba7e06a587641aeae62b.1549380136.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] qemu: Use C99 initializers for qemuMigrationParamsTPMap 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 05 Feb 2019 15:23:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index e112e790c2..658e785059 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -154,29 +154,29 @@ static const qemuMigrationParamsFlagMapItem qemuMigra= tionParamsFlagMap[] =3D { /* Translation from VIR_MIGRATE_PARAM_* typed parameters to * qemuMigrationParams. */ static const qemuMigrationParamsTPMapItem qemuMigrationParamsTPMap[] =3D { - {VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL, - QEMU_MIGRATION_PARAM_THROTTLE_INITIAL, - QEMU_MIGRATION_SOURCE}, + {.typedParam =3D VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL, + .param =3D QEMU_MIGRATION_PARAM_THROTTLE_INITIAL, + .party =3D QEMU_MIGRATION_SOURCE}, =20 - {VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT, - QEMU_MIGRATION_PARAM_THROTTLE_INCREMENT, - QEMU_MIGRATION_SOURCE}, + {.typedParam =3D VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT, + .param =3D QEMU_MIGRATION_PARAM_THROTTLE_INCREMENT, + .party =3D QEMU_MIGRATION_SOURCE}, =20 - {VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, - QEMU_MIGRATION_PARAM_COMPRESS_LEVEL, - QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + {.typedParam =3D VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, + .param =3D QEMU_MIGRATION_PARAM_COMPRESS_LEVEL, + .party =3D QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, =20 - {VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, - QEMU_MIGRATION_PARAM_COMPRESS_THREADS, - QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + {.typedParam =3D VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, + .param =3D QEMU_MIGRATION_PARAM_COMPRESS_THREADS, + .party =3D QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, =20 - {VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, - QEMU_MIGRATION_PARAM_DECOMPRESS_THREADS, - QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + {.typedParam =3D VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, + .param =3D QEMU_MIGRATION_PARAM_DECOMPRESS_THREADS, + .party =3D QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, =20 - {VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, - QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE, - QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + {.typedParam =3D VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, + .param =3D QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE, + .party =3D QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, }; =20 static const qemuMigrationParamType qemuMigrationParamTypes[] =3D { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 1549380222490742.7481548939312; Tue, 5 Feb 2019 07:23:42 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36463C04BD46; Tue, 5 Feb 2019 15:23:39 +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 A80575D70A; Tue, 5 Feb 2019 15:23:38 +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 1095D18033A4; Tue, 5 Feb 2019 15:23:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNGYD008326 for ; Tue, 5 Feb 2019 10:23:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 99A4871C8D; Tue, 5 Feb 2019 15:23:16 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 474AE69314 for ; Tue, 5 Feb 2019 15:23:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D18B41011C4; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:05 +0100 Message-Id: <79d42c615cb50cbabe3f4234757276d08dad569d.1549380136.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] qemu: Add optional unit to qemuMigrationParamsTPMapItem 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Feb 2019 15:23:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some migration parameters supported by libvirt may use units that differ from the units used by QEMU for the corresponding parameters. For example, libvirt defines migration bandwidth in MiB/s while QEMU expects B/s. Let's add a unit field to qemuMigrationParamsTPMapItem for automatic conversion when translating between libvirt's migration typed parameters and QEMU's migration paramteres. This patch is a preparation for future parameters as the existing VIR_MIGRATE_PARAM_BANDWIDTH parameter is set using "migrate_set_speed" QMP command rather than "migrate-set-parameters" for backward compatibility. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 63 ++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 658e785059..c36bed5744 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -120,6 +120,7 @@ struct _qemuMigrationParamsFlagMapItem { typedef struct _qemuMigrationParamsTPMapItem qemuMigrationParamsTPMapItem; struct _qemuMigrationParamsTPMapItem { const char *typedParam; + unsigned int unit; qemuMigrationParam param; int party; /* bit-wise OR of qemuMigrationParty */ }; @@ -273,7 +274,8 @@ qemuMigrationParamsGetTPInt(qemuMigrationParamsPtr migP= arams, qemuMigrationParam param, virTypedParameterPtr params, int nparams, - const char *name) + const char *name, + unsigned int unit) { int rc; =20 @@ -287,6 +289,17 @@ qemuMigrationParamsGetTPInt(qemuMigrationParamsPtr mig= Params, &migParams->params[param].value.i)) < 0) return -1; =20 + if (unit > 0) { + unsigned int max =3D UINT_MAX / unit; + if (migParams->params[param].value.i > max) { + virReportError(VIR_ERR_OVERFLOW, + _("%s migration parameter must be less than %u"= ), + name, max + 1); + return -1; + } + migParams->params[param].value.i *=3D unit; + } + migParams->params[param].set =3D !!rc; return 0; } @@ -298,16 +311,22 @@ qemuMigrationParamsSetTPInt(qemuMigrationParamsPtr mi= gParams, virTypedParameterPtr *params, int *nparams, int *maxparams, - const char *name) + const char *name, + unsigned int unit) { + int value; + if (qemuMigrationParamsCheckType(param, QEMU_MIGRATION_PARAM_TYPE_INT)= < 0) return -1; =20 if (!migParams->params[param].set) return 0; =20 - return virTypedParamsAddInt(params, nparams, maxparams, name, - migParams->params[param].value.i); + value =3D migParams->params[param].value.i; + if (unit > 0) + value /=3D unit; + + return virTypedParamsAddInt(params, nparams, maxparams, name, value); } =20 =20 @@ -316,7 +335,8 @@ qemuMigrationParamsGetTPULL(qemuMigrationParamsPtr migP= arams, qemuMigrationParam param, virTypedParameterPtr params, int nparams, - const char *name) + const char *name, + unsigned int unit) { int rc; =20 @@ -330,6 +350,17 @@ qemuMigrationParamsGetTPULL(qemuMigrationParamsPtr mig= Params, &migParams->params[param].value.ull)= ) < 0) return -1; =20 + if (unit > 0) { + unsigned long long max =3D ULLONG_MAX / unit; + if (migParams->params[param].value.ull > max) { + virReportError(VIR_ERR_OVERFLOW, + _("%s migration parameter must be less than %ll= u"), + name, max + 1); + return -1; + } + migParams->params[param].value.ull *=3D unit; + } + migParams->params[param].set =3D !!rc; return 0; } @@ -341,16 +372,22 @@ qemuMigrationParamsSetTPULL(qemuMigrationParamsPtr mi= gParams, virTypedParameterPtr *params, int *nparams, int *maxparams, - const char *name) + const char *name, + unsigned int unit) { + unsigned long long value; + if (qemuMigrationParamsCheckType(param, QEMU_MIGRATION_PARAM_TYPE_ULL)= < 0) return -1; =20 if (!migParams->params[param].set) return 0; =20 - return virTypedParamsAddULLong(params, nparams, maxparams, name, - migParams->params[param].value.ull); + value =3D migParams->params[param].value.ull; + if (unit > 0) + value /=3D unit; + + return virTypedParamsAddULLong(params, nparams, maxparams, name, value= ); } =20 =20 @@ -465,13 +502,15 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr par= ams, switch (qemuMigrationParamTypes[item->param]) { case QEMU_MIGRATION_PARAM_TYPE_INT: if (qemuMigrationParamsGetTPInt(migParams, item->param, params, - nparams, item->typedParam) < 0) + nparams, item->typedParam, + item->unit) < 0) goto error; break; =20 case QEMU_MIGRATION_PARAM_TYPE_ULL: if (qemuMigrationParamsGetTPULL(migParams, item->param, params, - nparams, item->typedParam) < 0) + nparams, item->typedParam, + item->unit) < 0) goto error; break; =20 @@ -533,14 +572,14 @@ qemuMigrationParamsDump(qemuMigrationParamsPtr migPar= ams, case QEMU_MIGRATION_PARAM_TYPE_INT: if (qemuMigrationParamsSetTPInt(migParams, item->param, params, nparams, maxparams, - item->typedParam) < 0) + item->typedParam, item->unit) = < 0) return -1; break; =20 case QEMU_MIGRATION_PARAM_TYPE_ULL: if (qemuMigrationParamsSetTPULL(migParams, item->param, params, nparams, maxparams, - item->typedParam) < 0) + item->typedParam, item->unit) = < 0) return -1; break; =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 1549380254261573.3899349110754; Tue, 5 Feb 2019 07:24:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58B4380F6D; Tue, 5 Feb 2019 15:24:11 +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 D041A104811C; Tue, 5 Feb 2019 15:24:10 +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 5A19818033EC; Tue, 5 Feb 2019 15:24:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNHje008338 for ; Tue, 5 Feb 2019 10:23:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2BD5B5D70A; Tue, 5 Feb 2019 15:23:17 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFEC817C46 for ; Tue, 5 Feb 2019 15:23:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D3CC41011C5; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:06 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] qemu: Rework qemuDomainMigrateSetMaxSpeed 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Feb 2019 15:24:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make the code flow easier to follow and get rid of the ugly endjob label inside if branch. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 427c1d02a8..93ec1dacf4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14275,6 +14275,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; + int rc; int ret =3D -1; =20 virCheckFlags(0, -1); @@ -14294,29 +14295,31 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, goto cleanup; } =20 - if (virDomainObjIsActive(vm)) { - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) - goto cleanup; - - if (virDomainObjCheckActive(vm) < 0) - goto endjob; - - VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth); - qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorSetMigrationSpeed(priv->mon, bandwidth); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret =3D -1; - - if (ret =3D=3D 0) - priv->migMaxBandwidth =3D bandwidth; - - endjob: - qemuDomainObjEndJob(driver, vm); - } else { + if (!virDomainObjIsActive(vm)) { priv->migMaxBandwidth =3D bandwidth; ret =3D 0; + goto cleanup; } =20 + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto endjob; + + VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth); + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorSetMigrationSpeed(priv->mon, bandwidth); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + goto endjob; + + priv->migMaxBandwidth =3D bandwidth; + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + cleanup: virDomainObjEndAPI(&vm); return ret; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 1549380227605374.1732641004794; Tue, 5 Feb 2019 07:23:47 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CDC7C057F93; Tue, 5 Feb 2019 15:23:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE1B26B468; Tue, 5 Feb 2019 15:23:44 +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 6C6CA3F602; Tue, 5 Feb 2019 15:23:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNHUC008332 for ; Tue, 5 Feb 2019 10:23:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0EDAE104810C; Tue, 5 Feb 2019 15:23:17 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D360D104811C for ; Tue, 5 Feb 2019 15:23:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D61861011C6; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:07 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] qemu: Make migration params usable outside migration 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 05 Feb 2019 15:23:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" So far migration parameters were changed only at the beginning of migration mostly via an automatic translation from flags and typed parameters. We need to export a few more functions to support APIs which may set migration parameters while migration is already running. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration_params.c | 16 +++++++++++++++- src/qemu/qemu_migration_params.h | 9 +++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index c36bed5744..117ae0e998 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -216,7 +216,7 @@ qemuMigrationParamsGetAlwaysOnCaps(qemuMigrationParty p= arty) } =20 =20 -static qemuMigrationParamsPtr +qemuMigrationParamsPtr qemuMigrationParamsNew(void) { qemuMigrationParamsPtr params; @@ -1039,6 +1039,20 @@ qemuMigrationParamsFetch(virQEMUDriverPtr driver, } =20 =20 +int +qemuMigrationParamsSetULL(qemuMigrationParamsPtr migParams, + qemuMigrationParam param, + unsigned long long value) +{ + if (qemuMigrationParamsCheckType(param, QEMU_MIGRATION_PARAM_TYPE_ULL)= < 0) + return -1; + + migParams->params[param].value.ull =3D value; + migParams->params[param].set =3D true; + return 0; +} + + /** * Returns -1 on error, * 0 on success, diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 709b818dcf..db0745ec28 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -84,8 +84,12 @@ qemuMigrationParamsDump(qemuMigrationParamsPtr migParams, int *maxparams, unsigned long *flags); =20 +qemuMigrationParamsPtr +qemuMigrationParamsNew(void); + void qemuMigrationParamsFree(qemuMigrationParamsPtr migParams); +VIR_DEFINE_AUTOPTR_FUNC(qemuMigrationParams, qemuMigrationParamsFree) =20 int qemuMigrationParamsApply(virQEMUDriverPtr driver, @@ -112,6 +116,11 @@ qemuMigrationParamsFetch(virQEMUDriverPtr driver, int asyncJob, qemuMigrationParamsPtr *migParams); =20 +int +qemuMigrationParamsSetULL(qemuMigrationParamsPtr migParams, + qemuMigrationParam param, + unsigned long long value); + int qemuMigrationParamsGetULL(qemuMigrationParamsPtr migParams, qemuMigrationParam param, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 1549380232905523.389880460518; Tue, 5 Feb 2019 07:23:52 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D14B7F3E7; Tue, 5 Feb 2019 15:23:50 +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 3D46E87C4B; Tue, 5 Feb 2019 15:23:50 +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 D650B18033A3; Tue, 5 Feb 2019 15:23:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNJDS008368 for ; Tue, 5 Feb 2019 10:23:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id C085469314; Tue, 5 Feb 2019 15:23:19 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9519871D4B for ; Tue, 5 Feb 2019 15:23:17 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D871B1011C7; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:08 +0100 Message-Id: <90a1b64b2fc820f03feac0a8e06e3b81fcbba833.1549380136.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] Public API for post-copy migration bandwidth 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Feb 2019 15:23:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This patch adds a new VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY typed parameter for virDomainMigrate3 and virDomainMigrateToURI3 for setting maximum post-copy migration bandwidth. In case the initial VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY value turns out to be suboptimal a new VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY flag for virDomainMigrateSetMaxSpeed and virDomainMigrateGetMaxSpeed may be used to set/get the maximum post-copy migration bandwidth while migration is already running. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- include/libvirt/libvirt-domain.h | 15 +++++++++++++++ src/libvirt-domain.c | 11 ++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 0388911ded..d99f9b690b 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -903,6 +903,15 @@ typedef enum { */ # define VIR_MIGRATE_PARAM_BANDWIDTH "bandwidth" =20 +/** + * VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY: + * + * virDomainMigrate* params field: the maximum bandwidth (in MiB/s) that w= ill + * be used for post-copy phase of a migration as VIR_TYPED_PARAM_ULLONG. I= f set + * to 0 or omitted, post-copy migration speed will not be limited. + */ +# define VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY "bandwidth.postcopy" + /** * VIR_MIGRATE_PARAM_GRAPHICS_URI: * @@ -1062,6 +1071,12 @@ int virDomainMigrateSetCompressionCache(virDomainPtr= domain, unsigned long long cacheSize, unsigned int flags); =20 +/* Domain migration speed flags. */ +typedef enum { + /* Set or get maximum speed of postcopy migration. */ + VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY =3D (1 << 0), +} virDomainMigrateMaxSpeedFlags; + int virDomainMigrateSetMaxSpeed(virDomainPtr domain, unsigned long bandwidth, unsigned int flags); diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 58b4863c8f..7b87b3716a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9036,11 +9036,13 @@ virDomainMigrateSetCompressionCache(virDomainPtr do= main, * virDomainMigrateSetMaxSpeed: * @domain: a domain object * @bandwidth: migration bandwidth limit in MiB/s - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of virDomainMigrateMaxSpeedFlags * * The maximum bandwidth (in MiB/s) that will be used to do migration * can be specified with the bandwidth parameter. Not all hypervisors - * will support a bandwidth cap + * will support a bandwidth cap. When VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY + * is set in @flags, this API sets the maximum bandwidth for the postcopy + * phase of the migration. * * Returns 0 in case of success, -1 otherwise. */ @@ -9077,10 +9079,13 @@ virDomainMigrateSetMaxSpeed(virDomainPtr domain, * virDomainMigrateGetMaxSpeed: * @domain: a domain object * @bandwidth: return value of current migration bandwidth limit in MiB/s - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of virDomainMigrateMaxSpeedFlags * * Get the current maximum bandwidth (in MiB/s) that will be used if the * domain is migrated. Not all hypervisors will support a bandwidth limit. + * When VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY is set in @flags, this API + * gets the current maximum bandwidth for the postcopy phase of the + * migration. * * Returns 0 in case of success, -1 otherwise. */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 1549380255805152.56150975698426; Tue, 5 Feb 2019 07:24:15 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2A5C356C4; Tue, 5 Feb 2019 15:24:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5E4471D5C; Tue, 5 Feb 2019 15:24:13 +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 3C2513F604; Tue, 5 Feb 2019 15:24:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNKd6008378 for ; Tue, 5 Feb 2019 10:23:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id A9FEE17ADC; Tue, 5 Feb 2019 15:23:20 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C7CD179C9 for ; Tue, 5 Feb 2019 15:23:17 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id DAB911011C8; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:09 +0100 Message-Id: <89e97c945fcbfffd263774f0680d104be5e25cc4.1549380136.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/8] qemu: Implement VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 05 Feb 2019 15:24:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This typed parameter for virDomainMigrate3 and virDomainMigrateToURI3 APIs may be used for setting maximum post-copy migration bandwidth. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.h | 1 + src/qemu/qemu_migration_params.c | 7 +++++++ src/qemu/qemu_migration_params.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 976a723d21..ca73d3e467 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -79,6 +79,7 @@ VIR_MIGRATE_PARAM_PERSIST_XML, VIR_TYPED_PARAM_STRING, \ VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL, VIR_TYPED_PARAM_INT, \ VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT, VIR_TYPED_PARAM_INT, \ + VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, VIR_TYPED_PARAM_ULLONG, \ NULL =20 =20 diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 117ae0e998..67070b9d08 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -102,6 +102,7 @@ VIR_ENUM_IMPL(qemuMigrationParam, QEMU_MIGRATION_PARAM_= LAST, "downtime-limit", "block-incremental", "xbzrle-cache-size", + "max-postcopy-bandwidth", ); =20 typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysO= nItem; @@ -178,6 +179,11 @@ static const qemuMigrationParamsTPMapItem qemuMigratio= nParamsTPMap[] =3D { {.typedParam =3D VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, .param =3D QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE, .party =3D QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, + + {.typedParam =3D VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, + .unit =3D 1024 * 1024, /* MB/s */ + .param =3D QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH, + .party =3D QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, }; =20 static const qemuMigrationParamType qemuMigrationParamTypes[] =3D { @@ -192,6 +198,7 @@ static const qemuMigrationParamType qemuMigrationParamT= ypes[] =3D { [QEMU_MIGRATION_PARAM_DOWNTIME_LIMIT] =3D QEMU_MIGRATION_PARAM_TYPE_UL= L, [QEMU_MIGRATION_PARAM_BLOCK_INCREMENTAL] =3D QEMU_MIGRATION_PARAM_TYPE= _BOOL, [QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE] =3D QEMU_MIGRATION_PARAM_TYPE= _ULL, + [QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH] =3D QEMU_MIGRATION_PARAM= _TYPE_ULL, }; verify(ARRAY_CARDINALITY(qemuMigrationParamTypes) =3D=3D QEMU_MIGRATION_PA= RAM_LAST); =20 diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index db0745ec28..2460684a00 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -55,6 +55,7 @@ typedef enum { QEMU_MIGRATION_PARAM_DOWNTIME_LIMIT, QEMU_MIGRATION_PARAM_BLOCK_INCREMENTAL, QEMU_MIGRATION_PARAM_XBZRLE_CACHE_SIZE, + QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BANDWIDTH, =20 QEMU_MIGRATION_PARAM_LAST } qemuMigrationParam; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 154938026023710.51474970641334; Tue, 5 Feb 2019 07:24:20 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 011CDC01DE10; Tue, 5 Feb 2019 15:24:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A40426EE39; Tue, 5 Feb 2019 15:24:17 +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 235C03F607; Tue, 5 Feb 2019 15:24:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNLbr008386 for ; Tue, 5 Feb 2019 10:23:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 727CC7C817; Tue, 5 Feb 2019 15:23:21 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 141AB18863 for ; Tue, 5 Feb 2019 15:23:17 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id DCC611011C9; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:10 +0100 Message-Id: <47e7c33c888b293489cfa1bc4c9f26c4ed7078fd.1549380136.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] qemu: Implement VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY flag 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Feb 2019 15:24:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This flag tells virDomainMigrateSetMaxSpeed and virDomainMigrateGetMaxSpeed APIs to work on post-copy migration bandwidth. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 91 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 93ec1dacf4..06a0560a35 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14275,10 +14275,12 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; - int rc; + bool postcopy =3D !!(flags & VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY); + VIR_AUTOPTR(qemuMigrationParams) migParams =3D NULL; + unsigned long long max; int ret =3D -1; =20 - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY, -1); =20 if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; @@ -14288,14 +14290,18 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, if (virDomainMigrateSetMaxSpeedEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (bandwidth > QEMU_DOMAIN_MIG_BANDWIDTH_MAX) { + if (postcopy) + max =3D ULLONG_MAX / 1024 / 1024; + else + max =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; + + if (bandwidth > max) { virReportError(VIR_ERR_OVERFLOW, - _("bandwidth must be less than %llu"), - QEMU_DOMAIN_MIG_BANDWIDTH_MAX + 1ULL); + _("bandwidth must be less than %llu"), max + 1); goto cleanup; } =20 - if (!virDomainObjIsActive(vm)) { + if (!postcopy && !virDomainObjIsActive(vm)) { priv->migMaxBandwidth =3D bandwidth; ret =3D 0; goto cleanup; @@ -14308,12 +14314,29 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, goto endjob; =20 VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth); - qemuDomainObjEnterMonitor(driver, vm); - rc =3D qemuMonitorSetMigrationSpeed(priv->mon, bandwidth); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) - goto endjob; =20 - priv->migMaxBandwidth =3D bandwidth; + if (postcopy) { + if (!(migParams =3D qemuMigrationParamsNew())) + goto endjob; + + if (qemuMigrationParamsSetULL(migParams, + QEMU_MIGRATION_PARAM_MAX_POSTCOPY_BA= NDWIDTH, + bandwidth * 1024 * 1024) < 0) + goto endjob; + + if (qemuMigrationParamsApply(driver, vm, QEMU_ASYNC_JOB_NONE, + migParams) < 0) + goto endjob; + } else { + int rc; + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorSetMigrationSpeed(priv->mon, bandwidth); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + goto endjob; + + priv->migMaxBandwidth =3D bandwidth; + } =20 ret =3D 0; =20 @@ -14330,11 +14353,13 @@ qemuDomainMigrateGetMaxSpeed(virDomainPtr dom, unsigned long *bandwidth, unsigned int flags) { + virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; + bool postcopy =3D !!(flags & VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY); int ret =3D -1; =20 - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY, -1); =20 if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; @@ -14344,7 +14369,47 @@ qemuDomainMigrateGetMaxSpeed(virDomainPtr dom, if (virDomainMigrateGetMaxSpeedEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - *bandwidth =3D priv->migMaxBandwidth; + if (postcopy) { + VIR_AUTOPTR(qemuMigrationParams) migParams =3D NULL; + unsigned long long bw; + int rc =3D -1; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) =3D=3D 0 && + qemuMigrationParamsFetch(driver, vm, QEMU_ASYNC_JOB_NONE, + &migParams) =3D=3D 0) { + rc =3D qemuMigrationParamsGetULL(migParams, + QEMU_MIGRATION_PARAM_MAX_POSTCO= PY_BANDWIDTH, + &bw); + + /* QEMU reports B/s while we use MiB/s */ + bw /=3D 1024 * 1024; + } + + qemuDomainObjEndJob(driver, vm); + + if (rc < 0) { + goto cleanup; + } else if (rc =3D=3D 1) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("querying maximum post-copy migration speed i= s " + "not supported by QEMU binary")); + goto cleanup; + } if (bw > ULONG_MAX) { + virReportError(VIR_ERR_OVERFLOW, + _("bandwidth %llu is greater than %lu which is = the " + "maximum value supported by this API"), + bw, ULONG_MAX); + goto cleanup; + } + + *bandwidth =3D bw; + } else { + *bandwidth =3D priv->migMaxBandwidth; + } + ret =3D 0; =20 cleanup: --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 08:31:49 2024 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 1549380271728681.3281361657913; Tue, 5 Feb 2019 07:24:31 -0800 (PST) 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 8FD7A883B8; Tue, 5 Feb 2019 15:24:26 +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 2F0DF7C810; Tue, 5 Feb 2019 15:24:25 +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 AE8C318033A6; Tue, 5 Feb 2019 15:24:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15FNLm0008387 for ; Tue, 5 Feb 2019 10:23:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 77F577C818; Tue, 5 Feb 2019 15:23:21 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13A74608C1 for ; Tue, 5 Feb 2019 15:23:17 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id DF0DA1011CA; Tue, 5 Feb 2019 16:23:12 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Feb 2019 16:23:11 +0100 Message-Id: <00b7eada0b39465ae697636b1b19b0663e552b00.1549380136.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] virsh: Add support for setting post-copy migration bandwidth 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: , 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.26]); Tue, 05 Feb 2019 15:24:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 33 +++++++++++++++++++++++++++++++-- tools/virsh.pod | 15 +++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 275ac0c318..db0d5d4dcc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10557,6 +10557,10 @@ static const vshCmdOptDef opts_migrate[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("use TLS for migration") }, + {.name =3D "postcopy-bandwidth", + .type =3D VSH_OT_INT, + .help =3D N_("post-copy migration bandwidth limit in MiB/s") + }, {.name =3D NULL} }; =20 @@ -10753,6 +10757,15 @@ doMigrate(void *opaque) goto save_error; } =20 + if ((rv =3D vshCommandOptULongLong(ctl, cmd, "postcopy-bandwidth", &ul= lOpt)) < 0) { + goto out; + } else if (rv > 0) { + if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, + VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, + ullOpt) < 0) + goto save_error; + } + if (vshCommandOptBool(cmd, "live")) flags |=3D VIR_MIGRATE_LIVE; if (vshCommandOptBool(cmd, "p2p")) @@ -11150,6 +11163,10 @@ static const vshCmdOptDef opts_migrate_setspeed[] = =3D { .flags =3D VSH_OFLAG_REQ, .help =3D N_("migration bandwidth limit in MiB/s") }, + {.name =3D "postcopy", + .type =3D VSH_OT_BOOL, + .help =3D N_("set postcopy migration bandwidth") + }, {.name =3D NULL} }; =20 @@ -11158,6 +11175,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd= *cmd) { virDomainPtr dom =3D NULL; unsigned long bandwidth =3D 0; + unsigned int flags =3D 0; bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) @@ -11166,7 +11184,10 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCm= d *cmd) if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) goto done; =20 - if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) < 0) + if (vshCommandOptBool(cmd, "postcopy")) + flags |=3D VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; + + if (virDomainMigrateSetMaxSpeed(dom, bandwidth, flags) < 0) goto done; =20 ret =3D true; @@ -11191,6 +11212,10 @@ static const vshCmdInfo info_migrate_getspeed[] = =3D { =20 static const vshCmdOptDef opts_migrate_getspeed[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), + {.name =3D "postcopy", + .type =3D VSH_OT_BOOL, + .help =3D N_("get postcopy migration bandwidth") + }, {.name =3D NULL} }; =20 @@ -11199,12 +11224,16 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshC= md *cmd) { virDomainPtr dom =3D NULL; unsigned long bandwidth; + unsigned int flags =3D 0; bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (virDomainMigrateGetMaxSpeed(dom, &bandwidth, 0) < 0) + if (vshCommandOptBool(cmd, "postcopy")) + flags |=3D VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; + + if (virDomainMigrateGetMaxSpeed(dom, &bandwidth, flags) < 0) goto done; =20 vshPrint(ctl, "%lu\n", bandwidth); diff --git a/tools/virsh.pod b/tools/virsh.pod index 59a5900162..67edb57b14 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1903,6 +1903,7 @@ I I [I] [I]= [I] [I] [I<--comp-mt-threads>] [I<--comp-mt-dthreads>] [I<--comp-xbzrle-cache>] [I<--auto-converge>] [I] [I] [I<--persistent-xml> B] [I<--tls>] +[I<--postcopy-bandwidth> B] =20 Migrate domain to another host. Add I<--live> for live migration; <--p2p> for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnel= led> @@ -1933,6 +1934,8 @@ Once migration is running, the user may switch to pos= t-copy using the B command sent from another virsh instance or use I<--postcopy-after-precopy> along with I<--postcopy> to let libvirt automatically switch to post-copy after the first pass of pre-copy is fini= shed. +The maximum bandwidth consumed during the post-copy phase may be limited u= sing +I<--postcopy-bandwidth>. =20 I<--auto-converge> forces convergence during live migration. The initial guest CPU throttling rate can be set with I. If the @@ -2098,17 +2101,21 @@ is supposed to be used while the domain is being li= ve-migrated as a reaction to migration progress and increasing number of compression cache misses obtained from domjobinfo. =20 -=3Ditem B I I +=3Ditem B I I [I<--postcopy>] =20 Set the maximum migration bandwidth (in MiB/s) for a domain which is being migrated to another host. I is interpreted as an unsigned long long value. Specifying a negative value results in an essentially unlimited value being provided to the hypervisor. The hypervisor can choose whether = to -reject the value or convert it to the maximum value allowed. +reject the value or convert it to the maximum value allowed. If the +I<--postcopy> option is specified, the command will set the maximum bandwi= dth +allowed during a post-copy migration phase. =20 -=3Ditem B I +=3Ditem B I [I<--postcopy>] =20 -Get the maximum migration bandwidth (in MiB/s) for a domain. +Get the maximum migration bandwidth (in MiB/s) for a domain. If the +I<--postcopy> option is specified, the command will get the maximum bandwi= dth +allowed during a post-copy migration phase. =20 =3Ditem B I =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list