2017-04-24 13:42:55 +02:00
|
|
|
/*
|
|
|
|
* QEMU migration vmstate registration
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2008
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MIGRATION_REGISTER_H
|
|
|
|
#define MIGRATION_REGISTER_H
|
|
|
|
|
2019-08-28 14:00:19 +02:00
|
|
|
#include "hw/vmstate-if.h"
|
|
|
|
|
2017-04-24 13:42:55 +02:00
|
|
|
typedef struct SaveVMHandlers {
|
|
|
|
/* This runs inside the iothread lock. */
|
|
|
|
SaveStateHandler *save_state;
|
|
|
|
|
2017-06-28 11:52:25 +02:00
|
|
|
void (*save_cleanup)(void *opaque);
|
2017-04-24 13:42:55 +02:00
|
|
|
int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque);
|
|
|
|
int (*save_live_complete_precopy)(QEMUFile *f, void *opaque);
|
|
|
|
|
|
|
|
/* This runs both outside and inside the iothread lock. */
|
|
|
|
bool (*is_active)(void *opaque);
|
2017-07-10 18:30:14 +02:00
|
|
|
bool (*has_postcopy)(void *opaque);
|
2017-04-24 13:42:55 +02:00
|
|
|
|
2018-03-13 20:34:01 +01:00
|
|
|
/* is_active_iterate
|
|
|
|
* If it is not NULL then qemu_savevm_state_iterate will skip iteration if
|
|
|
|
* it returns false. For example, it is needed for only-postcopy-states,
|
|
|
|
* which needs to be handled by qemu_savevm_state_setup and
|
|
|
|
* qemu_savevm_state_pending, but do not need iterations until not in
|
|
|
|
* postcopy stage.
|
|
|
|
*/
|
|
|
|
bool (*is_active_iterate)(void *opaque);
|
|
|
|
|
2017-04-24 13:42:55 +02:00
|
|
|
/* This runs outside the iothread lock in the migration case, and
|
|
|
|
* within the lock in the savevm case. The callback had better only
|
|
|
|
* use data that is local to the migration thread or protected
|
|
|
|
* by other locks.
|
|
|
|
*/
|
|
|
|
int (*save_live_iterate)(QEMUFile *f, void *opaque);
|
|
|
|
|
|
|
|
/* This runs outside the iothread lock! */
|
2017-06-28 11:52:24 +02:00
|
|
|
int (*save_setup)(QEMUFile *f, void *opaque);
|
2018-03-13 20:34:00 +01:00
|
|
|
/* Note for save_live_pending:
|
2023-02-08 14:48:02 +01:00
|
|
|
* must_precopy:
|
|
|
|
* - must be migrated in precopy or in stopped state
|
|
|
|
* - i.e. must be migrated before target start
|
2018-03-13 20:34:00 +01:00
|
|
|
*
|
2023-02-08 14:48:02 +01:00
|
|
|
* can_postcopy:
|
|
|
|
* - can migrate in postcopy or in stopped state
|
|
|
|
* - i.e. can migrate after target start
|
|
|
|
* - some can also be migrated during precopy (RAM)
|
|
|
|
* - some must be migrated after source stops (block-dirty-bitmap)
|
|
|
|
*
|
|
|
|
* Sum of can_postcopy and must_postcopy is the whole amount of
|
|
|
|
* pending data.
|
2018-03-13 20:34:00 +01:00
|
|
|
*/
|
2022-10-03 02:00:03 +02:00
|
|
|
/* This estimates the remaining data to transfer */
|
2023-02-08 14:48:02 +01:00
|
|
|
void (*state_pending_estimate)(void *opaque, uint64_t *must_precopy,
|
|
|
|
uint64_t *can_postcopy);
|
2022-10-03 02:00:03 +02:00
|
|
|
/* This calculate the exact remaining data to transfer */
|
2023-02-08 14:48:02 +01:00
|
|
|
void (*state_pending_exact)(void *opaque, uint64_t *must_precopy,
|
|
|
|
uint64_t *can_postcopy);
|
2017-04-24 13:42:55 +02:00
|
|
|
LoadStateHandler *load_state;
|
2017-06-28 11:52:26 +02:00
|
|
|
int (*load_setup)(QEMUFile *f, void *opaque);
|
|
|
|
int (*load_cleanup)(void *opaque);
|
2018-05-02 12:47:31 +02:00
|
|
|
/* Called when postcopy migration wants to resume from failure */
|
|
|
|
int (*resume_prepare)(MigrationState *s, void *opaque);
|
2023-06-21 13:11:55 +02:00
|
|
|
/* Checks if switchover ack should be used. Called only in dest */
|
|
|
|
bool (*switchover_ack_needed)(void *opaque);
|
2017-04-24 13:42:55 +02:00
|
|
|
} SaveVMHandlers;
|
|
|
|
|
2019-08-22 13:54:33 +02:00
|
|
|
int register_savevm_live(const char *idstr,
|
2019-10-16 04:29:31 +02:00
|
|
|
uint32_t instance_id,
|
2017-04-24 13:42:55 +02:00
|
|
|
int version_id,
|
2018-11-14 14:31:39 +01:00
|
|
|
const SaveVMHandlers *ops,
|
2017-04-24 13:42:55 +02:00
|
|
|
void *opaque);
|
|
|
|
|
2019-08-28 14:02:32 +02:00
|
|
|
void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque);
|
2017-04-24 13:42:55 +02:00
|
|
|
|
|
|
|
#endif
|