From: Trieu Huynh <vikingtc4@gmail.com>
To: qemu-devel@nongnu.org
Cc: Trieu Huynh <vikingtc4@gmail.com>, Peter Xu <peterx@redhat.com>,
Fabiano Rosas <farosas@suse.de>
Subject: [PATCH 1/2] migration: track timing and received pages in MigrationIncomingState
Date: Sun, 5 Apr 2026 22:26:07 +0700 [thread overview]
Message-ID: <20260405152612.93027-2-viking4@gmail.com> (raw)
In-Reply-To: <20260405152612.93027-1-viking4@gmail.com>
From: Trieu Huynh <vikingtc4@gmail.com>
Add start_time, total_time, received_normal_pages,
received_zero_pages, and received_xbzrle_pages to
MigrationIncomingState.
start_time is recorded when the incoming state transitions to ACTIVE;
total_time is recorded when it transitions to COMPLETED. The page
counters are incremented in ram_load_precopy() as each page type is
received from the source.
These fields will be used by a subsequent patch to populate
fill_destination_migration_info() for the migration COMPLETED case.
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
migration/migration.c | 2 ++
migration/migration.h | 17 +++++++++++++++++
migration/ram.c | 3 +++
3 files changed, 22 insertions(+)
diff --git a/migration/migration.c b/migration/migration.c
index 5c9aaa6e58..17c9a8b344 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -726,6 +726,7 @@ static void process_incoming_migration_bh(void *opaque)
*/
migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
MIGRATION_STATUS_COMPLETED);
+ mis->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - mis->start_time;
migration_incoming_state_destroy();
}
@@ -758,6 +759,7 @@ process_incoming_migration_co(void *opaque)
migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_ACTIVE);
+ mis->start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
mis->loadvm_co = qemu_coroutine_self();
ret = qemu_loadvm_state(mis->from_src_file, &local_err);
mis->loadvm_co = NULL;
diff --git a/migration/migration.h b/migration/migration.h
index b6888daced..cd51ae452c 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -176,6 +176,23 @@ struct MigrationIncomingState {
/* PostCopyFD's for external userfaultfds & handlers of shared memory */
GArray *postcopy_remote_fds;
+ /*
+ * Timestamps for reporting migration duration via query-migrate on the
+ * destination. start_time is recorded when the state moves to ACTIVE;
+ * total_time is recorded when it moves to COMPLETED.
+ */
+ int64_t start_time;
+ int64_t total_time;
+
+ /*
+ * Page counters for reporting RAM statistics via query-migrate on the
+ * destination. Incremented in ram_load_precopy() as each page type
+ * is received.
+ */
+ uint64_t received_normal_pages;
+ uint64_t received_zero_pages;
+ uint64_t received_xbzrle_pages;
+
MigrationStatus state;
/*
diff --git a/migration/ram.c b/migration/ram.c
index 979751f61b..6646e5daad 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -4417,10 +4417,12 @@ static int ram_load_precopy(QEMUFile *f)
break;
}
ram_handle_zero(host, TARGET_PAGE_SIZE);
+ mis->received_zero_pages++;
break;
case RAM_SAVE_FLAG_PAGE:
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
+ mis->received_normal_pages++;
break;
case RAM_SAVE_FLAG_XBZRLE:
@@ -4430,6 +4432,7 @@ static int ram_load_precopy(QEMUFile *f)
ret = -EINVAL;
break;
}
+ mis->received_xbzrle_pages++;
break;
case RAM_SAVE_FLAG_MULTIFD_FLUSH:
multifd_recv_sync_main();
--
2.43.0
next prev parent reply other threads:[~2026-04-05 15:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 15:26 [PATCH 0/2] migration: include timing and RAM stats on destination when query-migrate Trieu Huynh
2026-04-05 15:26 ` Trieu Huynh [this message]
2026-04-07 12:02 ` [PATCH 1/2] migration: track timing and received pages in MigrationIncomingState Claudio Fontana
2026-04-07 12:11 ` Claudio Fontana
2026-04-07 18:28 ` Trieu Huynh
2026-04-05 15:26 ` [PATCH 2/2] migration: expose RAM stats and timing on destination via query-migrate Trieu Huynh
2026-04-08 16:14 ` Claudio Fontana
2026-04-08 19:38 ` Trieu Huynh
2026-04-06 14:02 ` [PATCH 0/2] migration: include timing and RAM stats on destination when query-migrate Fabiano Rosas
2026-04-08 20:04 ` Peter Xu
2026-04-09 10:08 ` Claudio Fontana
2026-04-09 13:08 ` Fabian Grünbichler
2026-04-09 13:17 ` Claudio Fontana
2026-04-09 13:29 ` Fabian Grünbichler
2026-04-13 21:07 ` Peter Xu
2026-04-16 16:53 ` Trieu Huynh
2026-04-16 18:50 ` Peter Xu
2026-04-17 10:01 ` Trieu Huynh
2026-04-22 22:46 ` Fabiano Rosas
2026-04-23 13:22 ` Peter Xu
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=20260405152612.93027-2-viking4@gmail.com \
--to=vikingtc4@gmail.com \
--cc=farosas@suse.de \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.