aboutsummaryrefslogtreecommitdiff
path: root/migration
diff options
context:
space:
mode:
Diffstat (limited to 'migration')
-rw-r--r--migration/migration.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/migration/migration.c b/migration/migration.c
index ae087df..2f5f270 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -627,6 +627,17 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
}
}
+static void populate_disk_info(MigrationInfo *info)
+{
+ if (blk_mig_active()) {
+ info->has_disk = true;
+ info->disk = g_malloc0(sizeof(*info->disk));
+ info->disk->transferred = blk_mig_bytes_transferred();
+ info->disk->remaining = blk_mig_bytes_remaining();
+ info->disk->total = blk_mig_bytes_total();
+ }
+}
+
MigrationInfo *qmp_query_migrate(Error **errp)
{
MigrationInfo *info = g_malloc0(sizeof(*info));
@@ -652,15 +663,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->setup_time = s->setup_time;
populate_ram_info(info, s);
-
- if (blk_mig_active()) {
- info->has_disk = true;
- info->disk = g_malloc0(sizeof(*info->disk));
- info->disk->transferred = blk_mig_bytes_transferred();
- info->disk->remaining = blk_mig_bytes_remaining();
- info->disk->total = blk_mig_bytes_total();
- }
-
+ populate_disk_info(info);
break;
case MIGRATION_STATUS_POSTCOPY_ACTIVE:
/* Mostly the same as active; TODO add some postcopy stats */
@@ -674,15 +677,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->setup_time = s->setup_time;
populate_ram_info(info, s);
-
- if (blk_mig_active()) {
- info->has_disk = true;
- info->disk = g_malloc0(sizeof(*info->disk));
- info->disk->transferred = blk_mig_bytes_transferred();
- info->disk->remaining = blk_mig_bytes_remaining();
- info->disk->total = blk_mig_bytes_total();
- }
-
+ populate_disk_info(info);
break;
case MIGRATION_STATUS_COLO:
info->has_status = true;