diff options
author | Juan Quintela <quintela@redhat.com> | 2017-10-05 21:30:10 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2017-10-29 14:06:15 +0100 |
commit | 73af8dd8d75a3e1f13e6c5d2a509fa56eb406519 (patch) | |
tree | e6bf9e86d603baca9bc4ef18483cf273388c63f1 /migration | |
parent | c9dede2d482676440cb6e826ebe87450965fe679 (diff) |
migration: Make xbzrle_cache_size a migration parameter
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>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'migration')
-rw-r--r-- | migration/migration.c | 43 | ||||
-rw-r--r-- | migration/migration.h | 1 | ||||
-rw-r--r-- | migration/ram.c | 7 |
3 files changed, 32 insertions, 19 deletions
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 /* 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. @@ -515,6 +515,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; } @@ -817,6 +819,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; } @@ -878,9 +890,12 @@ 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) +static void migrate_params_apply(MigrateSetParameters *params, Error **errp) { MigrationState *s = migrate_get_current(); @@ -946,6 +961,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, errp); + } } void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) @@ -974,7 +993,7 @@ void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) return; } - migrate_params_apply(params); + migrate_params_apply(params, errp); } @@ -1405,13 +1424,12 @@ void qmp_migrate_continue(MigrationStatus state, Error **errp) void qmp_migrate_set_cache_size(int64_t value, Error **errp) { - MigrationState *s = migrate_get_current(); - - if (xbzrle_cache_resize(value, errp) < 0) { - return; - } + MigrateSetParameters p = { + .has_xbzrle_cache_size = true, + .xbzrle_cache_size = value, + }; - s->xbzrle_cache_size = value; + qmp_migrate_set_parameters(&p, errp); } int64_t qmp_query_migrate_cache_size(Error **errp) @@ -1587,7 +1605,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) @@ -2405,6 +2423,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), @@ -2448,7 +2469,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; 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 = 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 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; /* 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; } - /* 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 0; |