Commit 741d4086 authored by Juan Quintela's avatar Juan Quintela
Browse files

migration: Use proper types in json



We use int for everything (int64_t), and then we check that value is
between 0 and 255.  Change it to the valid types.

This change only happens for HMP.  QMP always use bytes and similar.

Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
parent fd06527b
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -293,23 +293,23 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)

    if (params) {
        assert(params->has_compress_level);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL),
            params->compress_level);
        assert(params->has_compress_threads);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS),
            params->compress_threads);
        assert(params->has_decompress_threads);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS),
            params->decompress_threads);
        assert(params->has_cpu_throttle_initial);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL),
            params->cpu_throttle_initial);
        assert(params->has_cpu_throttle_increment);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT),
            params->cpu_throttle_increment);
        assert(params->has_tls_creds);
@@ -321,28 +321,28 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
            MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME),
            params->tls_hostname);
        assert(params->has_max_bandwidth);
        monitor_printf(mon, "%s: %" PRId64 " bytes/second\n",
        monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n",
            MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH),
            params->max_bandwidth);
        assert(params->has_downtime_limit);
        monitor_printf(mon, "%s: %" PRId64 " milliseconds\n",
        monitor_printf(mon, "%s: %" PRIu64 " milliseconds\n",
            MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),
            params->downtime_limit);
        assert(params->has_x_checkpoint_delay);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY),
            params->x_checkpoint_delay);
        assert(params->has_block_incremental);
        monitor_printf(mon, "%s: %s\n",
            MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL),
            params->block_incremental ? "on" : "off");
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS),
            params->x_multifd_channels);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %u\n",
            MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT),
            params->x_multifd_page_count);
        monitor_printf(mon, "%s: %" PRId64 "\n",
        monitor_printf(mon, "%s: %" PRIu64 "\n",
            MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE),
            params->xbzrle_cache_size);
    }
+20 −29
Original line number Diff line number Diff line
@@ -741,22 +741,20 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
static bool migrate_params_check(MigrationParameters *params, Error **errp)
{
    if (params->has_compress_level &&
        (params->compress_level < 0 || params->compress_level > 9)) {
        (params->compress_level > 9)) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
                   "is invalid, it should be in the range of 0 to 9");
        return false;
    }

    if (params->has_compress_threads &&
        (params->compress_threads < 1 || params->compress_threads > 255)) {
    if (params->has_compress_threads && (params->compress_threads < 1)) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                   "compress_threads",
                   "is invalid, it should be in the range of 1 to 255");
        return false;
    }

    if (params->has_decompress_threads &&
        (params->decompress_threads < 1 || params->decompress_threads > 255)) {
    if (params->has_decompress_threads && (params->decompress_threads < 1)) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                   "decompress_threads",
                   "is invalid, it should be in the range of 1 to 255");
@@ -781,30 +779,23 @@ static bool migrate_params_check(MigrationParameters *params, Error **errp)
        return false;
    }

    if (params->has_max_bandwidth &&
        (params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) {
    if (params->has_max_bandwidth && (params->max_bandwidth > SIZE_MAX)) {
        error_setg(errp, "Parameter 'max_bandwidth' expects an integer in the"
                         " range of 0 to %zu bytes/second", SIZE_MAX);
        return false;
    }

    if (params->has_downtime_limit &&
        (params->downtime_limit < 0 ||
         params->downtime_limit > MAX_MIGRATE_DOWNTIME)) {
        (params->downtime_limit > MAX_MIGRATE_DOWNTIME)) {
        error_setg(errp, "Parameter 'downtime_limit' expects an integer in "
                         "the range of 0 to %d milliseconds",
                         MAX_MIGRATE_DOWNTIME);
        return false;
    }

    if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay < 0)) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                    "x_checkpoint_delay",
                    "is invalid, it should be positive");
        return false;
    }
    if (params->has_x_multifd_channels &&
        (params->x_multifd_channels < 1 || params->x_multifd_channels > 255)) {
    /* x_checkpoint_delay is now always positive */

    if (params->has_x_multifd_channels && (params->x_multifd_channels < 1)) {
        error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                   "multifd_channels",
                   "is invalid, it should be in the range of 1 to 255");
@@ -2394,33 +2385,33 @@ static Property migration_properties[] = {
                     send_section_footer, true),

    /* Migration parameters */
    DEFINE_PROP_INT64("x-compress-level", MigrationState,
    DEFINE_PROP_UINT8("x-compress-level", MigrationState,
                      parameters.compress_level,
                      DEFAULT_MIGRATE_COMPRESS_LEVEL),
    DEFINE_PROP_INT64("x-compress-threads", MigrationState,
    DEFINE_PROP_UINT8("x-compress-threads", MigrationState,
                      parameters.compress_threads,
                      DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT),
    DEFINE_PROP_INT64("x-decompress-threads", MigrationState,
    DEFINE_PROP_UINT8("x-decompress-threads", MigrationState,
                      parameters.decompress_threads,
                      DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT),
    DEFINE_PROP_INT64("x-cpu-throttle-initial", MigrationState,
    DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState,
                      parameters.cpu_throttle_initial,
                      DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL),
    DEFINE_PROP_INT64("x-cpu-throttle-increment", MigrationState,
    DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState,
                      parameters.cpu_throttle_increment,
                      DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT),
    DEFINE_PROP_INT64("x-max-bandwidth", MigrationState,
    DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState,
                      parameters.max_bandwidth, MAX_THROTTLE),
    DEFINE_PROP_INT64("x-downtime-limit", MigrationState,
    DEFINE_PROP_UINT64("x-downtime-limit", MigrationState,
                      parameters.downtime_limit,
                      DEFAULT_MIGRATE_SET_DOWNTIME),
    DEFINE_PROP_INT64("x-checkpoint-delay", MigrationState,
    DEFINE_PROP_UINT32("x-checkpoint-delay", MigrationState,
                      parameters.x_checkpoint_delay,
                      DEFAULT_MIGRATE_X_CHECKPOINT_DELAY),
    DEFINE_PROP_INT64("x-multifd-channels", MigrationState,
    DEFINE_PROP_UINT8("x-multifd-channels", MigrationState,
                      parameters.x_multifd_channels,
                      DEFAULT_MIGRATE_MULTIFD_CHANNELS),
    DEFINE_PROP_INT64("x-multifd-page-count", MigrationState,
    DEFINE_PROP_UINT32("x-multifd-page-count", MigrationState,
                      parameters.x_multifd_page_count,
                      DEFAULT_MIGRATE_MULTIFD_PAGE_COUNT),
    DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState,
+10 −10
Original line number Diff line number Diff line
@@ -668,19 +668,19 @@
# Since: 2.4
##
{ 'struct': 'MigrationParameters',
  'data': { '*compress-level': 'int',
            '*compress-threads': 'int',
            '*decompress-threads': 'int',
            '*cpu-throttle-initial': 'int',
            '*cpu-throttle-increment': 'int',
  'data': { '*compress-level': 'uint8',
            '*compress-threads': 'uint8',
            '*decompress-threads': 'uint8',
            '*cpu-throttle-initial': 'uint8',
            '*cpu-throttle-increment': 'uint8',
            '*tls-creds': 'str',
            '*tls-hostname': 'str',
            '*max-bandwidth': 'int',
            '*downtime-limit': 'int',
            '*x-checkpoint-delay': 'int',
            '*max-bandwidth': 'size',
            '*downtime-limit': 'uint64',
            '*x-checkpoint-delay': 'uint32',
            '*block-incremental': 'bool' ,
            '*x-multifd-channels': 'int',
            '*x-multifd-page-count': 'int',
            '*x-multifd-channels': 'uint8',
            '*x-multifd-page-count': 'uint32',
            '*xbzrle-cache-size': 'size' } }

##