From nobody Sun Nov 2 11:43:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509282975241488.7531186813925; Sun, 29 Oct 2017 06:16:15 -0700 (PDT) Received: from localhost ([::1]:36373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8nRk-0007i3-BC for importer@patchew.org; Sun, 29 Oct 2017 09:16:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8nLa-00039W-Au for qemu-devel@nongnu.org; Sun, 29 Oct 2017 09:09:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8nLY-0001y2-PM for qemu-devel@nongnu.org; Sun, 29 Oct 2017 09:09:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42500) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8nLY-0001xI-H5 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 09:09:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6457C03BD52 for ; Sun, 29 Oct 2017 13:09:47 +0000 (UTC) Received: from secure.mitica (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C57600C9; Sun, 29 Oct 2017 13:09:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A6457C03BD52 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Sun, 29 Oct 2017 14:09:29 +0100 Message-Id: <20171029130934.4555-5-quintela@redhat.com> In-Reply-To: <20171029130934.4555-1-quintela@redhat.com> References: <20171029130934.4555-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 29 Oct 2017 13:09:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/9] migration: Make xbzrle_cache_size a migration parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Right now it is a variable in MigrationState instead of a MigrationParameter. The change allows to set it as the rest of the Migration parameters, from the command line, with query_migration_paramters, set_migrate_parameters, etc. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- hmp.c | 14 ++++++++++++++ migration/migration.c | 43 ++++++++++++++++++++++++++++++++----------- migration/migration.h | 1 - migration/ram.c | 7 ------- qapi/migration.json | 26 +++++++++++++++++++++++--- 5 files changed, 69 insertions(+), 22 deletions(-) diff --git a/hmp.c b/hmp.c index 41fcce6f5a..a01be50daa 100644 --- a/hmp.c +++ b/hmp.c @@ -342,6 +342,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUN= T), params->x_multifd_page_count); + monitor_printf(mon, "%s: %" PRId64 "\n", + MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), + params->xbzrle_cache_size); } =20 qapi_free_MigrationParameters(params); @@ -1578,6 +1581,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) Visitor *v =3D string_input_visitor_new(valuestr); MigrateSetParameters *p =3D g_new0(MigrateSetParameters, 1); uint64_t valuebw =3D 0; + uint64_t cache_size; Error *err =3D NULL; int val, ret; =20 @@ -1653,6 +1657,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_x_multifd_page_count =3D true; visit_type_int(v, param, &p->x_multifd_page_count, &err); break; + case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: + p->has_xbzrle_cache_size =3D true; + visit_type_size(v, param, &cache_size, &err); + if (err || cache_size > INT64_MAX + || (size_t)cache_size !=3D cache_size) { + error_setg(&err, "Invalid size %s", valuestr); + break; + } + p->xbzrle_cache_size =3D cache_size; + break; default: assert(0); } diff --git a/migration/migration.c b/migration/migration.c index 6bbd4715d3..4de3b551fe 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -71,7 +71,7 @@ #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10 =20 /* Migration XBZRLE default cache size */ -#define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024) +#define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024) =20 /* The delay time (in ms) between two COLO checkpoints * Note: Please change this default value to 10000 when we support hybrid = mode. @@ -515,6 +515,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->x_multifd_channels =3D s->parameters.x_multifd_channels; params->has_x_multifd_page_count =3D true; params->x_multifd_page_count =3D s->parameters.x_multifd_page_count; + params->has_xbzrle_cache_size =3D true; + params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; =20 return params; } @@ -817,6 +819,16 @@ static bool migrate_params_check(MigrationParameters *= params, Error **errp) return false; } =20 + if (params->has_xbzrle_cache_size && + (params->xbzrle_cache_size < qemu_target_page_size() || + !is_power_of_2(params->xbzrle_cache_size))) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "xbzrle_cache_size", + "is invalid, it should be bigger than target page size" + " and a power of two"); + return false; + } + return true; } =20 @@ -878,9 +890,12 @@ static void migrate_params_test_apply(MigrateSetParame= ters *params, if (params->has_x_multifd_page_count) { dest->x_multifd_page_count =3D params->x_multifd_page_count; } + if (params->has_xbzrle_cache_size) { + dest->xbzrle_cache_size =3D params->xbzrle_cache_size; + } } =20 -static void migrate_params_apply(MigrateSetParameters *params) +static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) { MigrationState *s =3D migrate_get_current(); =20 @@ -946,6 +961,10 @@ static void migrate_params_apply(MigrateSetParameters = *params) if (params->has_x_multifd_page_count) { s->parameters.x_multifd_page_count =3D params->x_multifd_page_coun= t; } + if (params->has_xbzrle_cache_size) { + s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; + xbzrle_cache_resize(params->xbzrle_cache_size, errp); + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) @@ -974,7 +993,7 @@ void qmp_migrate_set_parameters(MigrateSetParameters *p= arams, Error **errp) return; } =20 - migrate_params_apply(params); + migrate_params_apply(params, errp); } =20 =20 @@ -1405,13 +1424,12 @@ void qmp_migrate_continue(MigrationStatus state, Er= ror **errp) =20 void qmp_migrate_set_cache_size(int64_t value, Error **errp) { - MigrationState *s =3D migrate_get_current(); + MigrateSetParameters p =3D { + .has_xbzrle_cache_size =3D true, + .xbzrle_cache_size =3D value, + }; =20 - if (xbzrle_cache_resize(value, errp) < 0) { - return; - } - - s->xbzrle_cache_size =3D value; + qmp_migrate_set_parameters(&p, errp); } =20 int64_t qmp_query_migrate_cache_size(Error **errp) @@ -1587,7 +1605,7 @@ int64_t migrate_xbzrle_cache_size(void) =20 s =3D migrate_get_current(); =20 - return s->xbzrle_cache_size; + return s->parameters.xbzrle_cache_size; } =20 bool migrate_use_block(void) @@ -2405,6 +2423,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_INT64("x-multifd-page-count", MigrationState, parameters.x_multifd_page_count, DEFAULT_MIGRATE_MULTIFD_PAGE_COUNT), + DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, + parameters.xbzrle_cache_size, + DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -2448,7 +2469,6 @@ static void migration_instance_init(Object *obj) MigrationParameters *params =3D &ms->parameters; =20 ms->state =3D MIGRATION_STATUS_NONE; - ms->xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE; ms->mbps =3D -1; qemu_sem_init(&ms->pause_sem, 0); qemu_mutex_init(&ms->error_mutex); @@ -2468,6 +2488,7 @@ static void migration_instance_init(Object *obj) params->has_block_incremental =3D true; params->has_x_multifd_channels =3D true; params->has_x_multifd_page_count =3D true; + params->has_xbzrle_cache_size =3D true; } =20 /* diff --git a/migration/migration.h b/migration/migration.h index 8ccdd7a577..663415fe48 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -107,7 +107,6 @@ struct MigrationState int64_t downtime; int64_t expected_downtime; bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; - int64_t xbzrle_cache_size; int64_t setup_time; =20 /* Flag set once the migration has been asked to enter postcopy */ diff --git a/migration/ram.c b/migration/ram.c index 997340c7c2..8620aa400a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -129,13 +129,6 @@ int xbzrle_cache_resize(int64_t new_size, Error **errp) return -1; } =20 - /* Cache should not be larger than guest ram size */ - if (new_size > ram_bytes_total()) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "exceeds guest ram size"); - return -1; - } - if (new_size =3D=3D migrate_xbzrle_cache_size()) { /* nothing to do */ return 0; diff --git a/qapi/migration.json b/qapi/migration.json index 6ae866e1aa..bbc4671ded 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -483,6 +483,11 @@ # @x-multifd-page-count: Number of pages sent together to a thread. # The default value is 16 (since 2.11) # +# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It +# needs to be a multiple of the target page size +# and a power of 2 +# (Since 2.11) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -490,7 +495,8 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', - 'x-multifd-channels', 'x-multifd-page-count' ] } + 'x-multifd-channels', 'x-multifd-page-count', + 'xbzrle-cache-size' ] } =20 ## # @MigrateSetParameters: @@ -554,6 +560,10 @@ # @x-multifd-page-count: Number of pages sent together to a thread. # The default value is 16 (since 2.11) # +# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It +# needs to be a multiple of the target page size +# and a power of 2 +# (Since 2.11) # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -571,7 +581,8 @@ '*x-checkpoint-delay': 'int', '*block-incremental': 'bool', '*x-multifd-channels': 'int', - '*x-multifd-page-count': 'int' } } + '*x-multifd-page-count': 'int', + '*xbzrle-cache-size': 'size' } } =20 ## # @migrate-set-parameters: @@ -650,6 +661,10 @@ # @x-multifd-page-count: Number of pages sent together to a thread. # The default value is 16 (since 2.11) # +# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It +# needs to be a multiple of the target page size +# and a power of 2 +# (Since 2.11) # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -665,7 +680,8 @@ '*x-checkpoint-delay': 'int', '*block-incremental': 'bool' , '*x-multifd-channels': 'int', - '*x-multifd-page-count': 'int' } } + '*x-multifd-page-count': 'int', + '*xbzrle-cache-size': 'size' } } =20 ## # @query-migrate-parameters: @@ -947,6 +963,8 @@ # # Returns: nothing on success # +# Notes: This command is deprecated in favor of 'migrate-set-parameters' +# # Since: 1.2 # # Example: @@ -965,6 +983,8 @@ # # Returns: XBZRLE cache size in bytes # +# Notes: This command is deprecated in favor of 'query-migrate-parameters' +# # Since: 1.2 # # Example: --=20 2.13.6