1f2a8f0a6SJuan Quintela /* 2f2a8f0a6SJuan Quintela * QEMU migration vmstate registration 3f2a8f0a6SJuan Quintela * 4f2a8f0a6SJuan Quintela * Copyright IBM, Corp. 2008 5f2a8f0a6SJuan Quintela * 6f2a8f0a6SJuan Quintela * Authors: 7f2a8f0a6SJuan Quintela * Anthony Liguori <aliguori@us.ibm.com> 8f2a8f0a6SJuan Quintela * 9f2a8f0a6SJuan Quintela * This work is licensed under the terms of the GNU GPL, version 2. See 10f2a8f0a6SJuan Quintela * the COPYING file in the top-level directory. 11f2a8f0a6SJuan Quintela * 12f2a8f0a6SJuan Quintela */ 13f2a8f0a6SJuan Quintela 14f2a8f0a6SJuan Quintela #ifndef MIGRATION_REGISTER_H 15f2a8f0a6SJuan Quintela #define MIGRATION_REGISTER_H 16f2a8f0a6SJuan Quintela 17f2a8f0a6SJuan Quintela typedef struct SaveVMHandlers { 18f2a8f0a6SJuan Quintela /* This runs inside the iothread lock. */ 19f2a8f0a6SJuan Quintela SaveStateHandler *save_state; 20f2a8f0a6SJuan Quintela 2170f794fcSJuan Quintela void (*save_cleanup)(void *opaque); 22f2a8f0a6SJuan Quintela int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); 23f2a8f0a6SJuan Quintela int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); 24f2a8f0a6SJuan Quintela 25f2a8f0a6SJuan Quintela /* This runs both outside and inside the iothread lock. */ 26f2a8f0a6SJuan Quintela bool (*is_active)(void *opaque); 27c6467627SVladimir Sementsov-Ogievskiy bool (*has_postcopy)(void *opaque); 28f2a8f0a6SJuan Quintela 29c865d848SVladimir Sementsov-Ogievskiy /* is_active_iterate 30c865d848SVladimir Sementsov-Ogievskiy * If it is not NULL then qemu_savevm_state_iterate will skip iteration if 31c865d848SVladimir Sementsov-Ogievskiy * it returns false. For example, it is needed for only-postcopy-states, 32c865d848SVladimir Sementsov-Ogievskiy * which needs to be handled by qemu_savevm_state_setup and 33c865d848SVladimir Sementsov-Ogievskiy * qemu_savevm_state_pending, but do not need iterations until not in 34c865d848SVladimir Sementsov-Ogievskiy * postcopy stage. 35c865d848SVladimir Sementsov-Ogievskiy */ 36c865d848SVladimir Sementsov-Ogievskiy bool (*is_active_iterate)(void *opaque); 37c865d848SVladimir Sementsov-Ogievskiy 38f2a8f0a6SJuan Quintela /* This runs outside the iothread lock in the migration case, and 39f2a8f0a6SJuan Quintela * within the lock in the savevm case. The callback had better only 40f2a8f0a6SJuan Quintela * use data that is local to the migration thread or protected 41f2a8f0a6SJuan Quintela * by other locks. 42f2a8f0a6SJuan Quintela */ 43f2a8f0a6SJuan Quintela int (*save_live_iterate)(QEMUFile *f, void *opaque); 44f2a8f0a6SJuan Quintela 45f2a8f0a6SJuan Quintela /* This runs outside the iothread lock! */ 469907e842SJuan Quintela int (*save_setup)(QEMUFile *f, void *opaque); 47f2a8f0a6SJuan Quintela void (*save_live_pending)(QEMUFile *f, void *opaque, 48f2a8f0a6SJuan Quintela uint64_t threshold_size, 4947995026SVladimir Sementsov-Ogievskiy uint64_t *res_precopy_only, 5047995026SVladimir Sementsov-Ogievskiy uint64_t *res_compatible, 5147995026SVladimir Sementsov-Ogievskiy uint64_t *res_postcopy_only); 5247995026SVladimir Sementsov-Ogievskiy /* Note for save_live_pending: 5347995026SVladimir Sementsov-Ogievskiy * - res_precopy_only is for data which must be migrated in precopy phase 5447995026SVladimir Sementsov-Ogievskiy * or in stopped state, in other words - before target vm start 5547995026SVladimir Sementsov-Ogievskiy * - res_compatible is for data which may be migrated in any phase 5647995026SVladimir Sementsov-Ogievskiy * - res_postcopy_only is for data which must be migrated in postcopy phase 5747995026SVladimir Sementsov-Ogievskiy * or in stopped state, in other words - after source vm stop 5847995026SVladimir Sementsov-Ogievskiy * 5947995026SVladimir Sementsov-Ogievskiy * Sum of res_postcopy_only, res_compatible and res_postcopy_only is the 6047995026SVladimir Sementsov-Ogievskiy * whole amount of pending data. 6147995026SVladimir Sementsov-Ogievskiy */ 6247995026SVladimir Sementsov-Ogievskiy 6347995026SVladimir Sementsov-Ogievskiy 64f2a8f0a6SJuan Quintela LoadStateHandler *load_state; 65acb5ea86SJuan Quintela int (*load_setup)(QEMUFile *f, void *opaque); 66acb5ea86SJuan Quintela int (*load_cleanup)(void *opaque); 67d1b8eadbSPeter Xu /* Called when postcopy migration wants to resume from failure */ 68d1b8eadbSPeter Xu int (*resume_prepare)(MigrationState *s, void *opaque); 69f2a8f0a6SJuan Quintela } SaveVMHandlers; 70f2a8f0a6SJuan Quintela 71*ce62df53SDr. David Alan Gilbert int register_savevm_live(const char *idstr, 72f2a8f0a6SJuan Quintela int instance_id, 73f2a8f0a6SJuan Quintela int version_id, 74de22ded0SMarc-André Lureau const SaveVMHandlers *ops, 75f2a8f0a6SJuan Quintela void *opaque); 76f2a8f0a6SJuan Quintela 77f2a8f0a6SJuan Quintela void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); 78f2a8f0a6SJuan Quintela 79f2a8f0a6SJuan Quintela #endif 80