Index: usr.sbin/bhyve/bhyverun.c =================================================================== --- usr.sbin/bhyve/bhyverun.c +++ usr.sbin/bhyve/bhyverun.c @@ -1540,6 +1540,9 @@ if (restore_file != NULL) destroy_restore_state(&rstate); + /* initialize mutex/cond variables */ + init_snapshot(); + /* * checkpointing thread for communication with bhyvectl */ Index: usr.sbin/bhyve/snapshot.h =================================================================== --- usr.sbin/bhyve/snapshot.h +++ usr.sbin/bhyve/snapshot.h @@ -127,6 +127,7 @@ int get_checkpoint_msg(int conn_fd, struct vmctx *ctx); void *checkpoint_thread(void *param); int init_checkpoint_thread(struct vmctx *ctx); +void init_snapshot(void); int load_restore_file(const char *filename, struct restore_state *rstate); Index: usr.sbin/bhyve/snapshot.c =================================================================== --- usr.sbin/bhyve/snapshot.c +++ usr.sbin/bhyve/snapshot.c @@ -1493,6 +1493,23 @@ return (NULL); } +void +init_snapshot(void) +{ + int err; + + err = pthread_mutex_init(&vcpu_lock, NULL); + if (err != 0) + errc(1, err, "checkpoint mutex init"); + err = pthread_cond_init(&vcpus_idle, NULL); + if (err != 0) + errc(1, err, "checkpoint cv init (vcpu_idle)"); + err = pthread_cond_init(&vcpus_can_run, NULL); + if (err != 0) + errc(1, err, "checkpoint cv init (vcpus_can_run)"); + +} + /* * Create the listening socket for IPC with bhyvectl */ @@ -1508,15 +1525,6 @@ memset(&addr, 0, sizeof(addr)); - err = pthread_mutex_init(&vcpu_lock, NULL); - if (err != 0) - errc(1, err, "checkpoint mutex init"); - err = pthread_cond_init(&vcpus_idle, NULL); - if (err == 0) - err = pthread_cond_init(&vcpus_can_run, NULL); - if (err != 0) - errc(1, err, "checkpoint cv init"); - socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0); if (socket_fd < 0) { EPRINTLN("Socket creation failed: %s", strerror(errno));