From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH 09/10] migration: Make xbzrle_cache_size a migration parameter
Date: Thu, 12 Oct 2017 13:04:33 +0100 [thread overview]
Message-ID: <20171012120432.GC2343@work-vm> (raw)
In-Reply-To: <20171010181542.24168-10-quintela@redhat.com>
* Juan Quintela (quintela@redhat.com) wrote:
> 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 <quintela@redhat.com>
> ---
> hmp.c | 14 ++++++++++++++
> migration/migration.c | 39 ++++++++++++++++++++++++++++++---------
> migration/migration.h | 1 -
> migration/ram.c | 7 -------
> qapi/migration.json | 23 ++++++++++++++++++++---
> 5 files changed, 64 insertions(+), 20 deletions(-)
>
> diff --git a/hmp.c b/hmp.c
> index 739d330f4e..f73232399a 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -342,6 +342,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
> monitor_printf(mon, "%s: %" PRId64 "\n",
> MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT),
> params->x_multifd_page_count);
> + monitor_printf(mon, "%s: %" PRId64 "\n",
> + MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE),
> + params->xbzrle_cache_size);
> }
>
> qapi_free_MigrationParameters(params);
> @@ -1560,6 +1563,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
> Visitor *v = string_input_visitor_new(valuestr);
> MigrateSetParameters *p = g_new0(MigrateSetParameters, 1);
> uint64_t valuebw = 0;
> + uint64_t cache_size;
> Error *err = NULL;
> int val, ret;
>
> @@ -1635,6 +1639,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
> p->has_x_multifd_page_count = true;
> visit_type_int(v, param, &p->x_multifd_page_count, &err);
> break;
> + case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
> + p->has_xbzrle_cache_size = true;
> + visit_type_size(v, param, &cache_size, &err);
> + if (err || cache_size > INT64_MAX
> + || (size_t)cache_size != cache_size) {
> + error_setg(&err, "Invalid size %s", valuestr);
> + break;
> + }
> + p->xbzrle_cache_size = cache_size;
> + break;
> default:
> assert(0);
> }
> diff --git a/migration/migration.c b/migration/migration.c
> index f3d4503ce2..fcc0d64625 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -71,7 +71,7 @@
> #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10
>
> /* Migration XBZRLE default cache size */
> -#define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024)
> +#define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024)
>
> /* The delay time (in ms) between two COLO checkpoints
> * Note: Please change this default value to 10000 when we support hybrid mode.
> @@ -512,6 +512,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
> params->x_multifd_channels = s->parameters.x_multifd_channels;
> params->has_x_multifd_page_count = true;
> params->x_multifd_page_count = s->parameters.x_multifd_page_count;
> + params->has_xbzrle_cache_size = true;
> + params->xbzrle_cache_size = s->parameters.xbzrle_cache_size;
>
> return params;
> }
> @@ -810,6 +812,16 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
> return false;
> }
>
> + 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;
> }
>
> @@ -871,6 +883,9 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
> if (params->has_x_multifd_page_count) {
> dest->x_multifd_page_count = params->x_multifd_page_count;
> }
> + if (params->has_xbzrle_cache_size) {
> + dest->xbzrle_cache_size = params->xbzrle_cache_size;
> + }
> }
>
> static void migrate_params_apply(MigrateSetParameters *params)
> @@ -939,6 +954,10 @@ static void migrate_params_apply(MigrateSetParameters *params)
> if (params->has_x_multifd_page_count) {
> s->parameters.x_multifd_page_count = params->x_multifd_page_count;
> }
> + if (params->has_xbzrle_cache_size) {
> + s->parameters.xbzrle_cache_size = params->xbzrle_cache_size;
> + xbzrle_cache_resize(params->xbzrle_cache_size, NULL);
Not having the errp is a pain; you've just moved all the error
checking into xbzrle_cache_resize, so I think we really need an error
pointer and to do something with it (even if it's just a local report).
> + }
> }
>
> void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
> @@ -1370,13 +1389,12 @@ void qmp_migrate_cancel(Error **errp)
>
> void qmp_migrate_set_cache_size(int64_t value, Error **errp)
> {
> - MigrationState *s = migrate_get_current();
> + MigrateSetParameters p = {
> + .has_xbzrle_cache_size = true,
> + .xbzrle_cache_size = value,
> + };
>
> - if (xbzrle_cache_resize(value, errp) < 0) {
> - return;
> - }
> -
> - s->xbzrle_cache_size = value;
> + qmp_migrate_set_parameters(&p, errp);
> }
>
> int64_t qmp_query_migrate_cache_size(Error **errp)
> @@ -1542,7 +1560,7 @@ int64_t migrate_xbzrle_cache_size(void)
>
> s = migrate_get_current();
>
> - return s->xbzrle_cache_size;
> + return s->parameters.xbzrle_cache_size;
> }
>
> bool migrate_use_block(void)
> @@ -2312,6 +2330,9 @@ static Property migration_properties[] = {
> 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),
>
> /* Migration capabilities */
> DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
> @@ -2353,7 +2374,6 @@ static void migration_instance_init(Object *obj)
> MigrationParameters *params = &ms->parameters;
>
> ms->state = MIGRATION_STATUS_NONE;
> - ms->xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE;
> ms->mbps = -1;
>
> params->tls_hostname = g_strdup("");
> @@ -2371,6 +2391,7 @@ static void migration_instance_init(Object *obj)
> params->has_block_incremental = true;
> params->has_x_multifd_channels = true;
> params->has_x_multifd_page_count = true;
> + params->has_xbzrle_cache_size = true;
> }
>
> /*
> diff --git a/migration/migration.h b/migration/migration.h
> index b83cceadc4..d2a8d319f1 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;
>
> /* Flag set once the migration has been asked to enter postcopy */
> diff --git a/migration/ram.c b/migration/ram.c
> index ed4d3c6295..78e3b80e39 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -128,13 +128,6 @@ int xbzrle_cache_resize(int64_t new_size, Error **errp)
> return -1;
> }
>
> - /* 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 == migrate_xbzrle_cache_size()) {
> /* nothing to do */
> return new_size;
> diff --git a/qapi/migration.json b/qapi/migration.json
> index f8b365e3f5..830b2e4480 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -474,6 +474,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 power of 2
> +# (Since 2.11)
> +#
> # Since: 2.4
> ##
> { 'enum': 'MigrationParameter',
> @@ -481,7 +485,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' ] }
>
> ##
> # @MigrateSetParameters:
> @@ -545,6 +550,9 @@
> # @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
> +# (Since 2.11)
and power of 2
> # Since: 2.4
> ##
> # TODO either fuse back into MigrationParameters, or make
> @@ -562,7 +570,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' } }
>
> ##
> # @migrate-set-parameters:
> @@ -641,6 +650,9 @@
> # @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
> +# (Since 2.11)
and power of 2 (wow this text is repeated a lot)
> # Since: 2.4
> ##
> { 'struct': 'MigrationParameters',
> @@ -656,7 +668,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' } }
>
> ##
> # @query-migrate-parameters:
> @@ -921,6 +934,8 @@
> #
> # Returns: nothing on success
> #
> +# Notes: This command is deprecated in favor of 'migrate-set-parameters'
> +#
> # Since: 1.2
> #
> # Example:
> @@ -939,6 +954,8 @@
> #
> # Returns: XBZRLE cache size in bytes
> #
> +# Notes: This command is deprecated in favor of 'query-migrate-parameters'
> +#
> # Since: 1.2
> #
> # Example:
> --
> 2.13.6
Dave
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-10-12 12:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 18:15 [Qemu-devel] [PATCH 00/10] Make xbzrle_cache_size a migration parameter Juan Quintela
2017-10-10 18:15 ` [Qemu-devel] [PATCH 01/10] migration: Fix migrate_test_apply for multifd parameters Juan Quintela
2017-10-12 5:46 ` Peter Xu
2017-10-18 8:37 ` Juan Quintela
2017-10-10 18:15 ` [Qemu-devel] [PATCH 02/10] migratiom: Remove max_item_age parameter Juan Quintela
2017-10-12 5:46 ` Peter Xu
2017-10-10 18:15 ` [Qemu-devel] [PATCH 03/10] migration: Make cache size elements use the right types Juan Quintela
2017-10-12 10:01 ` Dr. David Alan Gilbert
2017-10-10 18:15 ` [Qemu-devel] [PATCH 04/10] migration: Move xbzrle cache resize error handling to xbzrle_cache_resize Juan Quintela
2017-10-12 5:48 ` Peter Xu
2017-10-10 18:15 ` [Qemu-devel] [PATCH 05/10] migration: Make cache_init() take an error parameter Juan Quintela
2017-10-12 5:55 ` Peter Xu
2017-10-10 18:15 ` [Qemu-devel] [PATCH 06/10] migration: Make sure that we pass the right cache size Juan Quintela
2017-10-12 5:57 ` Peter Xu
2017-10-18 8:45 ` Juan Quintela
2017-10-10 18:15 ` [Qemu-devel] [PATCH 07/10] migration: Don't play games with the requested " Juan Quintela
2017-10-10 18:15 ` [Qemu-devel] [PATCH 08/10] migration: No need to return the size of the cache Juan Quintela
2017-10-10 18:15 ` [Qemu-devel] [PATCH 09/10] migration: Make xbzrle_cache_size a migration parameter Juan Quintela
2017-10-12 12:04 ` Dr. David Alan Gilbert [this message]
2017-10-18 8:50 ` Juan Quintela
2017-10-10 18:15 ` [Qemu-devel] [PATCH 10/10] migration: [RFC] Use proper types in json Juan Quintela
2017-10-11 9:28 ` Daniel P. Berrange
2017-10-11 9:41 ` Juan Quintela
2017-11-06 14:26 ` Markus Armbruster
2017-11-08 9:41 ` Juan Quintela
2017-11-08 10:25 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171012120432.GC2343@work-vm \
--to=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.