1 /* 2 * QEMU migration vmstate registration 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_REGISTER_H 15 #define MIGRATION_REGISTER_H 16 17 typedef void SaveStateHandler(QEMUFile *f, void *opaque); 18 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); 19 20 typedef struct SaveVMHandlers { 21 /* This runs inside the iothread lock. */ 22 SaveStateHandler *save_state; 23 24 void (*cleanup)(void *opaque); 25 int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); 26 int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); 27 28 /* This runs both outside and inside the iothread lock. */ 29 bool (*is_active)(void *opaque); 30 31 /* This runs outside the iothread lock in the migration case, and 32 * within the lock in the savevm case. The callback had better only 33 * use data that is local to the migration thread or protected 34 * by other locks. 35 */ 36 int (*save_live_iterate)(QEMUFile *f, void *opaque); 37 38 /* This runs outside the iothread lock! */ 39 int (*save_live_setup)(QEMUFile *f, void *opaque); 40 void (*save_live_pending)(QEMUFile *f, void *opaque, 41 uint64_t threshold_size, 42 uint64_t *non_postcopiable_pending, 43 uint64_t *postcopiable_pending); 44 LoadStateHandler *load_state; 45 } SaveVMHandlers; 46 47 int register_savevm_live(DeviceState *dev, 48 const char *idstr, 49 int instance_id, 50 int version_id, 51 SaveVMHandlers *ops, 52 void *opaque); 53 54 void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); 55 56 #endif 57