Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyvectl/bhyvectl.c
Show First 20 Lines • Show All 880 Lines • ▼ Show 20 Lines | |||||
nvlist_destroy(nvl); | nvlist_destroy(nvl); | ||||
done: | done: | ||||
if (socket_fd > 0) | if (socket_fd > 0) | ||||
close(socket_fd); | close(socket_fd); | ||||
return (err); | return (err); | ||||
} | } | ||||
static int | |||||
open_directory(const char *file) | |||||
{ | |||||
char *path; | |||||
int fd; | |||||
if ((path = strdup(file)) == NULL) | |||||
return (-ENOMEM); | |||||
dirname(path); | |||||
fd = open(path, O_DIRECTORY); | |||||
free(path); | |||||
return (fd >= 0 ? fd : -errno); | |||||
} | |||||
static const char * | |||||
last_name(const char *path) | |||||
{ | |||||
const char *p; | |||||
p = strrchr(path, '/'); | |||||
if (p == NULL) | |||||
return (path); | |||||
return (p + 1); | |||||
} | |||||
static int | static int | ||||
snapshot_request(const char *vmname, const char *file, bool suspend) | snapshot_request(const char *vmname, const char *file, bool suspend) | ||||
{ | { | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
nvl = nvlist_create(0); | nvl = nvlist_create(0); | ||||
nvlist_add_string(nvl, "cmd", "checkpoint"); | nvlist_add_string(nvl, "cmd", "checkpoint"); | ||||
nvlist_add_string(nvl, "filename", file); | nvlist_add_string(nvl, "filename", last_name(file)); | ||||
nvlist_add_bool(nvl, "suspend", suspend); | nvlist_add_bool(nvl, "suspend", suspend); | ||||
nvlist_move_descriptor(nvl, "fddir", open_directory(file)); | |||||
return (send_message(vmname, nvl)); | return (send_message(vmname, nvl)); | ||||
} | } | ||||
#endif | #endif | ||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 666 Lines • Show Last 20 Lines |