Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/snapshot.h
Show All 38 Lines | |||||
#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 BHYVE_RUN_DIR "/var/run/bhyve/" | ||||
#define MAX_SNAPSHOT_FILENAME PATH_MAX | #define MAX_SNAPSHOT_FILENAME PATH_MAX | ||||
#define MAX_HOSTNAME_LEN 255 | |||||
jrtc27: Why not use MAXHOSTNAMELEN? Which is 256 not 255... | |||||
#define DEFAULT_MIGRATION_PORT 24983 | |||||
struct vmctx; | struct vmctx; | ||||
#define SNAPSHOT_BUFFER_SIZE (20 * MB) | |||||
jrtc27Unsubmitted Not Done Inline ActionsMB is defined inside C files, don't use it here jrtc27: MB is defined inside C files, don't use it here | |||||
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; | ||||
}; | }; | ||||
struct __attribute__((packed)) migrate_req { | |||||
char host[MAX_HOSTNAME_LEN]; | |||||
unsigned int port; | |||||
}; | |||||
/* Filename that will be used for save/restore */ | /* Filename that will be used for save/restore */ | ||||
struct checkpoint_op { | struct checkpoint_op { | ||||
char snapshot_filename[MAX_SNAPSHOT_FILENAME]; | char snapshot_filename[MAX_SNAPSHOT_FILENAME]; | ||||
struct migrate_req migrate_req; | |||||
}; | }; | ||||
/* Messages that a bhyve process understands. */ | /* Messages that a bhyve process understands. */ | ||||
enum ipc_opcode { | enum ipc_opcode { | ||||
START_CHECKPOINT, | START_CHECKPOINT, | ||||
START_SUSPEND, | START_SUSPEND, | ||||
START_MIGRATE, | |||||
START_MIGRATE_LIVE, | |||||
}; | }; | ||||
/* | /* | ||||
* The type of message and associated data to | * The type of message and associated data to | ||||
* send to a bhyve process. | * send to a bhyve process. | ||||
*/ | */ | ||||
struct ipc_message { | struct ipc_message { | ||||
enum ipc_opcode code; | enum ipc_opcode code; | ||||
union { | union { | ||||
/* | /* | ||||
* message specific structures | * message specific structures | ||||
*/ | */ | ||||
struct checkpoint_op op; | struct checkpoint_op op; | ||||
} data; | } data; | ||||
}; | }; | ||||
struct checkpoint_thread_info { | struct checkpoint_thread_info { | ||||
struct vmctx *ctx; | struct vmctx *ctx; | ||||
int socket_fd; | int socket_fd; | ||||
struct sockaddr_un *addr; | |||||
}; | }; | ||||
const char **get_pci_devs(int *); | |||||
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 */ | ||||
vm_resume_dev_cb resume_cb; /* callback for device resume */ | vm_resume_dev_cb resume_cb; /* callback for device resume */ | ||||
}; | }; | ||||
struct vm_snapshot_kern_info { | struct vm_snapshot_kern_info { | ||||
const char *struct_name; /* kernel structure name*/ | const char *struct_name; /* kernel structure name*/ | ||||
enum snapshot_req req; /* request type */ | enum snapshot_req req; /* request type */ | ||||
}; | }; | ||||
const struct vm_snapshot_dev_info *get_snapshot_devs(int *ndevs); | |||||
const struct vm_snapshot_kern_info *get_snapshot_kern_structs(int *ndevs); | |||||
void destroy_restore_state(struct restore_state *rstate); | void destroy_restore_state(struct restore_state *rstate); | ||||
const char *lookup_vmname(struct restore_state *rstate); | const char *lookup_vmname(struct restore_state *rstate); | ||||
int lookup_memflags(struct restore_state *rstate); | int lookup_memflags(struct restore_state *rstate); | ||||
size_t lookup_memsize(struct restore_state *rstate); | size_t lookup_memsize(struct restore_state *rstate); | ||||
int lookup_guest_ncpus(struct restore_state *rstate); | int lookup_guest_ncpus(struct restore_state *rstate); | ||||
void checkpoint_cpu_add(int vcpu); | void checkpoint_cpu_add(int vcpu); | ||||
void checkpoint_cpu_resume(int vcpu); | void checkpoint_cpu_resume(int vcpu); | ||||
void checkpoint_cpu_suspend(int vcpu); | void checkpoint_cpu_suspend(int vcpu); | ||||
void vm_vcpu_pause(struct vmctx *ctx); | |||||
void vm_vcpu_resume(struct vmctx *ctx); | |||||
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 get_checkpoint_msg(int conn_fd, struct vmctx *ctx); | ||||
void *checkpoint_thread(void *param); | void *checkpoint_thread(void *param); | ||||
int init_checkpoint_thread(struct vmctx *ctx); | 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 |
Why not use MAXHOSTNAMELEN? Which is 256 not 255...