1 /* 2 * QEMU migration miscellaneus exported functions 3 * 4 * Copyright IBM, Corp. 2008 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2. See 10 * the COPYING file in the top-level directory. 11 * 12 */ 13 14 #ifndef MIGRATION_MISC_H 15 #define MIGRATION_MISC_H 16 17 #include "qemu/notify.h" 18 #include "qapi/qapi-types-migration.h" 19 #include "qapi/qapi-types-net.h" 20 #include "migration/client-options.h" 21 22 /* migration/ram.c */ 23 24 typedef enum PrecopyNotifyReason { 25 PRECOPY_NOTIFY_SETUP = 0, 26 PRECOPY_NOTIFY_BEFORE_BITMAP_SYNC = 1, 27 PRECOPY_NOTIFY_AFTER_BITMAP_SYNC = 2, 28 PRECOPY_NOTIFY_COMPLETE = 3, 29 PRECOPY_NOTIFY_CLEANUP = 4, 30 PRECOPY_NOTIFY_MAX = 5, 31 } PrecopyNotifyReason; 32 33 typedef struct PrecopyNotifyData { 34 enum PrecopyNotifyReason reason; 35 } PrecopyNotifyData; 36 37 void precopy_infrastructure_init(void); 38 void precopy_add_notifier(NotifierWithReturn *n); 39 void precopy_remove_notifier(NotifierWithReturn *n); 40 int precopy_notify(PrecopyNotifyReason reason, Error **errp); 41 42 void ram_mig_init(void); 43 void qemu_guest_free_page_hint(void *addr, size_t len); 44 bool migrate_ram_is_ignored(RAMBlock *block); 45 46 /* migration/block.c */ 47 48 #ifdef CONFIG_LIVE_BLOCK_MIGRATION 49 void blk_mig_init(void); 50 #else 51 static inline void blk_mig_init(void) {} 52 #endif 53 54 AnnounceParameters *migrate_announce_params(void); 55 /* migration/savevm.c */ 56 57 void dump_vmstate_json_to_file(FILE *out_fp); 58 59 /* migration/migration.c */ 60 void migration_object_init(void); 61 void migration_shutdown(void); 62 bool migration_is_idle(void); 63 bool migration_is_active(void); 64 bool migration_is_device(void); 65 bool migration_thread_is_self(void); 66 bool migration_is_setup_or_active(void); 67 bool migrate_mode_is_cpr(MigrationState *); 68 69 typedef enum MigrationEventType { 70 MIG_EVENT_PRECOPY_SETUP, 71 MIG_EVENT_PRECOPY_DONE, 72 MIG_EVENT_PRECOPY_FAILED, 73 MIG_EVENT_MAX 74 } MigrationEventType; 75 76 typedef struct MigrationEvent { 77 MigrationEventType type; 78 } MigrationEvent; 79 80 /* 81 * A MigrationNotifyFunc may return an error code and an Error object, 82 * but only when @e->type is MIG_EVENT_PRECOPY_SETUP. The code is an int 83 * to allow for different failure modes and recovery actions. 84 */ 85 typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify, 86 MigrationEvent *e, Error **errp); 87 88 /* 89 * Register the notifier @notify to be called when a migration event occurs 90 * for MIG_MODE_NORMAL, as specified by the MigrationEvent passed to @func. 91 * Notifiers may receive events in any of the following orders: 92 * - MIG_EVENT_PRECOPY_SETUP -> MIG_EVENT_PRECOPY_DONE 93 * - MIG_EVENT_PRECOPY_SETUP -> MIG_EVENT_PRECOPY_FAILED 94 * - MIG_EVENT_PRECOPY_FAILED 95 */ 96 void migration_add_notifier(NotifierWithReturn *notify, 97 MigrationNotifyFunc func); 98 99 /* 100 * Same as migration_add_notifier, but applies to be specified @mode. 101 */ 102 void migration_add_notifier_mode(NotifierWithReturn *notify, 103 MigrationNotifyFunc func, MigMode mode); 104 105 void migration_remove_notifier(NotifierWithReturn *notify); 106 int migration_call_notifiers(MigrationState *s, MigrationEventType type, 107 Error **errp); 108 bool migration_in_setup(MigrationState *); 109 bool migration_has_finished(MigrationState *); 110 bool migration_has_failed(MigrationState *); 111 bool migration_is_running(void); 112 /* ...and after the device transmission */ 113 /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ 114 bool migration_in_incoming_postcopy(void); 115 /* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */ 116 bool migration_incoming_postcopy_advised(void); 117 /* True if background snapshot is active */ 118 bool migration_in_bg_snapshot(void); 119 120 /* migration/block-dirty-bitmap.c */ 121 void dirty_bitmap_mig_init(void); 122 123 #endif 124