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 29f2a8f0a6SJuan Quintela /* This runs outside the iothread lock in the migration case, and 30f2a8f0a6SJuan Quintela * within the lock in the savevm case. The callback had better only 31f2a8f0a6SJuan Quintela * use data that is local to the migration thread or protected 32f2a8f0a6SJuan Quintela * by other locks. 33f2a8f0a6SJuan Quintela */ 34f2a8f0a6SJuan Quintela int (*save_live_iterate)(QEMUFile *f, void *opaque); 35f2a8f0a6SJuan Quintela 36f2a8f0a6SJuan Quintela /* This runs outside the iothread lock! */ 379907e842SJuan Quintela int (*save_setup)(QEMUFile *f, void *opaque); 38f2a8f0a6SJuan Quintela void (*save_live_pending)(QEMUFile *f, void *opaque, 39f2a8f0a6SJuan Quintela uint64_t threshold_size, 40*47995026SVladimir Sementsov-Ogievskiy uint64_t *res_precopy_only, 41*47995026SVladimir Sementsov-Ogievskiy uint64_t *res_compatible, 42*47995026SVladimir Sementsov-Ogievskiy uint64_t *res_postcopy_only); 43*47995026SVladimir Sementsov-Ogievskiy /* Note for save_live_pending: 44*47995026SVladimir Sementsov-Ogievskiy * - res_precopy_only is for data which must be migrated in precopy phase 45*47995026SVladimir Sementsov-Ogievskiy * or in stopped state, in other words - before target vm start 46*47995026SVladimir Sementsov-Ogievskiy * - res_compatible is for data which may be migrated in any phase 47*47995026SVladimir Sementsov-Ogievskiy * - res_postcopy_only is for data which must be migrated in postcopy phase 48*47995026SVladimir Sementsov-Ogievskiy * or in stopped state, in other words - after source vm stop 49*47995026SVladimir Sementsov-Ogievskiy * 50*47995026SVladimir Sementsov-Ogievskiy * Sum of res_postcopy_only, res_compatible and res_postcopy_only is the 51*47995026SVladimir Sementsov-Ogievskiy * whole amount of pending data. 52*47995026SVladimir Sementsov-Ogievskiy */ 53*47995026SVladimir Sementsov-Ogievskiy 54*47995026SVladimir Sementsov-Ogievskiy 55f2a8f0a6SJuan Quintela LoadStateHandler *load_state; 56acb5ea86SJuan Quintela int (*load_setup)(QEMUFile *f, void *opaque); 57acb5ea86SJuan Quintela int (*load_cleanup)(void *opaque); 58f2a8f0a6SJuan Quintela } SaveVMHandlers; 59f2a8f0a6SJuan Quintela 60f2a8f0a6SJuan Quintela int register_savevm_live(DeviceState *dev, 61f2a8f0a6SJuan Quintela const char *idstr, 62f2a8f0a6SJuan Quintela int instance_id, 63f2a8f0a6SJuan Quintela int version_id, 64f2a8f0a6SJuan Quintela SaveVMHandlers *ops, 65f2a8f0a6SJuan Quintela void *opaque); 66f2a8f0a6SJuan Quintela 67f2a8f0a6SJuan Quintela void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); 68f2a8f0a6SJuan Quintela 69f2a8f0a6SJuan Quintela #endif 70