From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> This is an example use of the rolling statistics to watch the 'expected downtime' in a bit more detail than the current summary figure.
Example outputs from a simple run: HMP: expected downtime stats: Min/Max: 222, 1634 Mean: 983.8 (Weighted: 1005.1253) Count: 141 Values: 1248@39356292, 981@39356395, 774@39356497, 876@39356599, 1040@39356702 QMP: "expected-downtime-stats": { "min": 222, "count": 378, "mean": 1100.2, "max": 1942, "weighted-mean": 1115.710848, "values": [ { "tag": 39380740, "value": 1118 }, { "tag": 39380842, "value": 953 }, { "tag": 39380945, "value": 1017 }, { "tag": 39381048, "value": 1336 }, { "tag": 39381150, "value": 1077 } ] } Signed-off-by: Dr. David Alan Gilbert <dgilb...@redhat.com> --- hmp.c | 5 ++++- include/migration/migration.h | 1 + migration/migration.c | 15 +++++++++++++++ qapi-schema.json | 6 +++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index 20241d8..6bd19b2 100644 --- a/hmp.c +++ b/hmp.c @@ -138,7 +138,6 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict) qapi_free_MouseInfoList(mice_list); } -__attribute__ (( unused )) /* Until later in patch series */ static void monitor_printf_RollingStats(Monitor *mon, const char *title, RollingStats *r) { @@ -186,6 +185,10 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n", info->expected_downtime); } + if (info->has_expected_downtime_stats) { + monitor_printf_RollingStats(mon, "expected downtime stats", + info->expected_downtime_stats); + } if (info->has_downtime) { monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n", info->downtime); diff --git a/include/migration/migration.h b/include/migration/migration.h index 703b7d7..b37ec0c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -63,6 +63,7 @@ struct MigrationState int64_t xbzrle_cache_size; int64_t setup_time; int64_t dirty_sync_count; + RStats *expected_downtime_stats; }; void process_incoming_migration(QEMUFile *f); diff --git a/migration/migration.c b/migration/migration.c index b3adbc6..4041823 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -24,6 +24,7 @@ #include "migration/block.h" #include "qemu/thread.h" #include "qmp-commands.h" +#include "qemu/rolling-stats.h" #include "trace.h" enum { @@ -201,6 +202,9 @@ MigrationInfo *qmp_query_migrate(Error **errp) - s->total_time; info->has_expected_downtime = true; info->expected_downtime = s->expected_downtime; + info->expected_downtime_stats = + rstats_as_RollingStats(s->expected_downtime_stats); + info->has_expected_downtime_stats = true; info->has_setup_time = true; info->setup_time = s->setup_time; @@ -238,6 +242,9 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->downtime = s->downtime; info->has_setup_time = true; info->setup_time = s->setup_time; + info->expected_downtime_stats = + rstats_as_RollingStats(s->expected_downtime_stats); + info->has_expected_downtime_stats = true; info->has_ram = true; info->ram = g_malloc0(sizeof(*info->ram)); @@ -389,12 +396,18 @@ static MigrationState *migrate_init(const MigrationParams *params) memcpy(enabled_capabilities, s->enabled_capabilities, sizeof(enabled_capabilities)); + /* Resets the current state */ memset(s, 0, sizeof(*s)); s->params = *params; memcpy(s->enabled_capabilities, enabled_capabilities, sizeof(enabled_capabilities)); s->xbzrle_cache_size = xbzrle_cache_size; + if (!s->expected_downtime_stats) { + s->expected_downtime_stats = rstats_init(5, 0.2); + } else { + rstats_reset(s->expected_downtime_stats); + } s->bandwidth_limit = bandwidth_limit; s->state = MIG_STATE_SETUP; trace_migrate_set_state(MIG_STATE_SETUP); @@ -658,6 +671,8 @@ static void *migration_thread(void *opaque) 10000 is a small enough number for our purposes */ if (s->dirty_bytes_rate && transferred_bytes > 10000) { s->expected_downtime = s->dirty_bytes_rate / bandwidth; + rstats_add_value(s->expected_downtime_stats, + s->expected_downtime, current_time); } qemu_file_reset_rate_limit(s->file); diff --git a/qapi-schema.json b/qapi-schema.json index 9f5cdce..c43f0e7 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -480,6 +480,9 @@ # may be expensive, but do not actually occur during the iterative # migration rounds themselves. (since 1.6) # +# @expected-downtime-stats: #optional more detailed statistics from the +# downtime estimation. +# # Since: 0.14.0 ## { 'type': 'MigrationInfo', @@ -489,7 +492,8 @@ '*total-time': 'int', '*expected-downtime': 'int', '*downtime': 'int', - '*setup-time': 'int'} } + '*setup-time': 'int', + '*expected-downtime-stats': 'RollingStats' } } ## # @query-migrate -- 2.1.0