@@ -58,6 +58,9 @@ typedef struct SaveVMHandlers {
/* This runs after restoring CPU related state */
void (*post_load_state)(void *opaque);
+
+ /* This runs before stopping VCPU */
+ void (*save_before_stop)(QEMUFile *f, void *opaque);
LoadStateHandler *load_state;
} SaveVMHandlers;
@@ -84,6 +84,7 @@ void qemu_announce_self(void);
bool qemu_savevm_state_blocked(Error **errp);
void qemu_savevm_state_begin(QEMUFile *f,
const MigrationParams *params);
+void qemu_savevm_save_before_stop(QEMUFile *f);
void qemu_savevm_state_header(QEMUFile *f);
int qemu_savevm_state_iterate(QEMUFile *f);
void qemu_savevm_state_complete(QEMUFile *f);
@@ -759,7 +759,6 @@ int64_t migrate_xbzrle_cache_size(void)
}
/* migration thread support */
-
static void *migration_thread(void *opaque)
{
MigrationState *s = opaque;
@@ -788,6 +787,8 @@ static void *migration_thread(void *opaque)
} else {
int ret;
+ qemu_savevm_save_before_stop(s->file);
+
qemu_mutex_lock_iothread();
start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
@@ -715,6 +715,19 @@ void qemu_savevm_post_load(void)
}
}
+void qemu_savevm_save_before_stop(QEMUFile *f)
+{
+ SaveStateEntry *se;
+
+ QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
+ if (!se->ops || !se->ops->save_before_stop) {
+ continue;
+ }
+
+ se->ops->save_before_stop(f, se->opaque);
+ }
+}
+
void qemu_savevm_state_header(QEMUFile *f)
{
This patch is to add a callback which is called just before stopping VCPU. It's for VF migration to trigger mailbox irq as later as possible to decrease service downtime. Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> --- include/migration/vmstate.h | 3 +++ include/sysemu/sysemu.h | 1 + migration/migration.c | 3 ++- migration/savevm.c | 13 +++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-)