Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/snapshot.h
Show All 36 Lines | |||||
#ifndef _BHYVE_SNAPSHOT_ | #ifndef _BHYVE_SNAPSHOT_ | ||||
#define _BHYVE_SNAPSHOT_ | #define _BHYVE_SNAPSHOT_ | ||||
#include <machine/vmm_snapshot.h> | #include <machine/vmm_snapshot.h> | ||||
#include <libxo/xo.h> | #include <libxo/xo.h> | ||||
#include <ucl.h> | #include <ucl.h> | ||||
#define BHYVE_RUN_DIR "/var/run/bhyve/" | |||||
#define MAX_SNAPSHOT_FILENAME PATH_MAX | |||||
struct vmctx; | struct vmctx; | ||||
struct restore_state { | struct restore_state { | ||||
int kdata_fd; | int kdata_fd; | ||||
int vmmem_fd; | int vmmem_fd; | ||||
void *kdata_map; | void *kdata_map; | ||||
size_t kdata_len; | size_t kdata_len; | ||||
size_t vmmem_len; | size_t vmmem_len; | ||||
struct ucl_parser *meta_parser; | struct ucl_parser *meta_parser; | ||||
ucl_object_t *meta_root_obj; | ucl_object_t *meta_root_obj; | ||||
}; | }; | ||||
/* Filename that will be used for save/restore */ | |||||
struct checkpoint_op { | |||||
char snapshot_filename[MAX_SNAPSHOT_FILENAME]; | |||||
}; | |||||
/* Messages that a bhyve process understands. */ | |||||
enum ipc_opcode { | |||||
START_CHECKPOINT, | |||||
START_SUSPEND, | |||||
}; | |||||
/* | |||||
* The type of message and associated data to | |||||
* send to a bhyve process. | |||||
*/ | |||||
struct ipc_message { | |||||
enum ipc_opcode code; | |||||
union { | |||||
/* | |||||
* message specific structures | |||||
*/ | |||||
struct checkpoint_op op; | |||||
} data; | |||||
}; | |||||
struct checkpoint_thread_info { | |||||
struct vmctx *ctx; | |||||
int socket_fd; | |||||
}; | |||||
typedef int (*vm_snapshot_dev_cb)(struct vm_snapshot_meta *); | typedef int (*vm_snapshot_dev_cb)(struct vm_snapshot_meta *); | ||||
typedef int (*vm_pause_dev_cb) (struct vmctx *, const char *); | typedef int (*vm_pause_dev_cb) (struct vmctx *, const char *); | ||||
typedef int (*vm_resume_dev_cb) (struct vmctx *, const char *); | typedef int (*vm_resume_dev_cb) (struct vmctx *, const char *); | ||||
struct vm_snapshot_dev_info { | struct vm_snapshot_dev_info { | ||||
const char *dev_name; /* device name */ | const char *dev_name; /* device name */ | ||||
vm_snapshot_dev_cb snapshot_cb; /* callback for device snapshot */ | vm_snapshot_dev_cb snapshot_cb; /* callback for device snapshot */ | ||||
vm_pause_dev_cb pause_cb; /* callback for device pause */ | vm_pause_dev_cb pause_cb; /* callback for device pause */ | ||||
Show All 18 Lines | |||||
int restore_vm_mem(struct vmctx *ctx, struct restore_state *rstate); | int restore_vm_mem(struct vmctx *ctx, struct restore_state *rstate); | ||||
int vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate); | int vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate); | ||||
int vm_restore_user_devs(struct vmctx *ctx, struct restore_state *rstate); | int vm_restore_user_devs(struct vmctx *ctx, struct restore_state *rstate); | ||||
int vm_pause_user_devs(struct vmctx *ctx); | int vm_pause_user_devs(struct vmctx *ctx); | ||||
int vm_resume_user_devs(struct vmctx *ctx); | int vm_resume_user_devs(struct vmctx *ctx); | ||||
int get_checkpoint_msg(int conn_fd, struct vmctx *ctx); | int vm_checkpoint(struct vmctx *ctx, char *checkpoint_file, bool stop_vm); | ||||
void *checkpoint_thread(void *param); | |||||
int init_checkpoint_thread(struct vmctx *ctx); | |||||
void init_snapshot(void); | void init_snapshot(void); | ||||
int load_restore_file(const char *filename, struct restore_state *rstate); | int load_restore_file(const char *filename, struct restore_state *rstate); | ||||
#endif | #endif |