xref: /openbmc/qemu/include/migration/misc.h (revision 3a6813b6)
17b1e1a22SJuan Quintela /*
27b1e1a22SJuan Quintela  * QEMU migration miscellaneus exported functions
37b1e1a22SJuan Quintela  *
47b1e1a22SJuan Quintela  * Copyright IBM, Corp. 2008
57b1e1a22SJuan Quintela  *
67b1e1a22SJuan Quintela  * Authors:
77b1e1a22SJuan Quintela  *  Anthony Liguori   <aliguori@us.ibm.com>
87b1e1a22SJuan Quintela  *
97b1e1a22SJuan Quintela  * This work is licensed under the terms of the GNU GPL, version 2.  See
107b1e1a22SJuan Quintela  * the COPYING file in the top-level directory.
117b1e1a22SJuan Quintela  *
127b1e1a22SJuan Quintela  */
137b1e1a22SJuan Quintela 
147b1e1a22SJuan Quintela #ifndef MIGRATION_MISC_H
157b1e1a22SJuan Quintela #define MIGRATION_MISC_H
167b1e1a22SJuan Quintela 
171adc1ceeSJuan Quintela #include "qemu/notify.h"
18eea1e5c9SSteve Sistare #include "qapi/qapi-types-migration.h"
19ee3d96baSDr. David Alan Gilbert #include "qapi/qapi-types-net.h"
20f3bff6c4SSteve Sistare #include "migration/client-options.h"
211adc1ceeSJuan Quintela 
227b1e1a22SJuan Quintela /* migration/ram.c */
237b1e1a22SJuan Quintela 
24bd227060SWei Wang typedef enum PrecopyNotifyReason {
25bd227060SWei Wang     PRECOPY_NOTIFY_SETUP = 0,
26bd227060SWei Wang     PRECOPY_NOTIFY_BEFORE_BITMAP_SYNC = 1,
27bd227060SWei Wang     PRECOPY_NOTIFY_AFTER_BITMAP_SYNC = 2,
28bd227060SWei Wang     PRECOPY_NOTIFY_COMPLETE = 3,
29bd227060SWei Wang     PRECOPY_NOTIFY_CLEANUP = 4,
30bd227060SWei Wang     PRECOPY_NOTIFY_MAX = 5,
31bd227060SWei Wang } PrecopyNotifyReason;
32bd227060SWei Wang 
33bd227060SWei Wang typedef struct PrecopyNotifyData {
34bd227060SWei Wang     enum PrecopyNotifyReason reason;
35bd227060SWei Wang } PrecopyNotifyData;
36bd227060SWei Wang 
37bd227060SWei Wang void precopy_infrastructure_init(void);
38bd227060SWei Wang void precopy_add_notifier(NotifierWithReturn *n);
39bd227060SWei Wang void precopy_remove_notifier(NotifierWithReturn *n);
40bd227060SWei Wang int precopy_notify(PrecopyNotifyReason reason, Error **errp);
41bd227060SWei Wang 
427b1e1a22SJuan Quintela void ram_mig_init(void);
436bcb05fcSWei Wang void qemu_guest_free_page_hint(void *addr, size_t len);
44f161c88aSDavid Hildenbrand bool migrate_ram_is_ignored(RAMBlock *block);
457b1e1a22SJuan Quintela 
462c9e6fecSJuan Quintela /* migration/block.c */
472c9e6fecSJuan Quintela 
482c9e6fecSJuan Quintela #ifdef CONFIG_LIVE_BLOCK_MIGRATION
492c9e6fecSJuan Quintela void blk_mig_init(void);
502c9e6fecSJuan Quintela #else
512c9e6fecSJuan Quintela static inline void blk_mig_init(void) {}
522c9e6fecSJuan Quintela #endif
532c9e6fecSJuan Quintela 
54ee3d96baSDr. David Alan Gilbert AnnounceParameters *migrate_announce_params(void);
55b7722747SJuan Quintela /* migration/savevm.c */
56b7722747SJuan Quintela 
57b7722747SJuan Quintela void dump_vmstate_json_to_file(FILE *out_fp);
58b7722747SJuan Quintela 
59c4b63b7cSJuan Quintela /* migration/migration.c */
60e5cb7e76SPeter Xu void migration_object_init(void);
61892ae715SDr. David Alan Gilbert void migration_shutdown(void);
62c4b63b7cSJuan Quintela bool migration_is_idle(void);
63*3a6813b6SSteve Sistare bool migration_is_active(void);
647dcb3c87SSteve Sistare bool migration_is_setup_or_active(void);
659867d4ddSSteve Sistare bool migrate_mode_is_cpr(MigrationState *);
669d9babf7SSteve Sistare 
679d9babf7SSteve Sistare typedef enum MigrationEventType {
689d9babf7SSteve Sistare     MIG_EVENT_PRECOPY_SETUP,
699d9babf7SSteve Sistare     MIG_EVENT_PRECOPY_DONE,
709d9babf7SSteve Sistare     MIG_EVENT_PRECOPY_FAILED,
719d9babf7SSteve Sistare     MIG_EVENT_MAX
729d9babf7SSteve Sistare } MigrationEventType;
739d9babf7SSteve Sistare 
749d9babf7SSteve Sistare typedef struct MigrationEvent {
759d9babf7SSteve Sistare     MigrationEventType type;
769d9babf7SSteve Sistare } MigrationEvent;
779d9babf7SSteve Sistare 
784af667f8SSteve Sistare /*
794af667f8SSteve Sistare  * A MigrationNotifyFunc may return an error code and an Error object,
804af667f8SSteve Sistare  * but only when @e->type is MIG_EVENT_PRECOPY_SETUP.  The code is an int
814af667f8SSteve Sistare  * to allow for different failure modes and recovery actions.
824af667f8SSteve Sistare  */
835663dd3fSSteve Sistare typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify,
845663dd3fSSteve Sistare                                    MigrationEvent *e, Error **errp);
855663dd3fSSteve Sistare 
869d9babf7SSteve Sistare /*
879d9babf7SSteve Sistare  * Register the notifier @notify to be called when a migration event occurs
889d9babf7SSteve Sistare  * for MIG_MODE_NORMAL, as specified by the MigrationEvent passed to @func.
899d9babf7SSteve Sistare  * Notifiers may receive events in any of the following orders:
909d9babf7SSteve Sistare  *    - MIG_EVENT_PRECOPY_SETUP -> MIG_EVENT_PRECOPY_DONE
919d9babf7SSteve Sistare  *    - MIG_EVENT_PRECOPY_SETUP -> MIG_EVENT_PRECOPY_FAILED
929d9babf7SSteve Sistare  *    - MIG_EVENT_PRECOPY_FAILED
939d9babf7SSteve Sistare  */
943e775730SSteve Sistare void migration_add_notifier(NotifierWithReturn *notify,
955663dd3fSSteve Sistare                             MigrationNotifyFunc func);
969d9babf7SSteve Sistare 
976835f5a1SSteve Sistare /*
986835f5a1SSteve Sistare  * Same as migration_add_notifier, but applies to be specified @mode.
996835f5a1SSteve Sistare  */
1006835f5a1SSteve Sistare void migration_add_notifier_mode(NotifierWithReturn *notify,
1016835f5a1SSteve Sistare                                  MigrationNotifyFunc func, MigMode mode);
1026835f5a1SSteve Sistare 
1033e775730SSteve Sistare void migration_remove_notifier(NotifierWithReturn *notify);
1044af667f8SSteve Sistare int migration_call_notifiers(MigrationState *s, MigrationEventType type,
1054af667f8SSteve Sistare                              Error **errp);
106c4b63b7cSJuan Quintela bool migration_in_setup(MigrationState *);
107c4b63b7cSJuan Quintela bool migration_has_finished(MigrationState *);
108c4b63b7cSJuan Quintela bool migration_has_failed(MigrationState *);
109c4b63b7cSJuan Quintela /* ...and after the device transmission */
11080fe315cSDavid Hildenbrand /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */
11106df2e69SDavid Hildenbrand bool migration_in_incoming_postcopy(void);
11280fe315cSDavid Hildenbrand /* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */
11380fe315cSDavid Hildenbrand bool migration_incoming_postcopy_advised(void);
1141a8e44a8SAndrey Gruzdev /* True if background snapshot is active */
1151a8e44a8SAndrey Gruzdev bool migration_in_bg_snapshot(void);
1163df663e5SPeter Xu 
117b35ebdf0SVladimir Sementsov-Ogievskiy /* migration/block-dirty-bitmap.c */
118b35ebdf0SVladimir Sementsov-Ogievskiy void dirty_bitmap_mig_init(void);
119b35ebdf0SVladimir Sementsov-Ogievskiy 
1207b1e1a22SJuan Quintela #endif
121