Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show All 29 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#endif | #endif | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
markj: This should be further down, together with other userspace headers. | |||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#endif | #endif | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
#include <sys/un.h> | #include <sys/un.h> | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 1,072 Lines • ▼ Show 20 Lines | #ifndef WITHOUT_CAPSICUM | ||||
if (caph_ioctls_limit(vm_get_device_fd(ctx), cmds, ncmds) == -1) | if (caph_ioctls_limit(vm_get_device_fd(ctx), cmds, ncmds) == -1) | ||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | errx(EX_OSERR, "Unable to apply rights for sandbox"); | ||||
free((cap_ioctl_t *)cmds); | free((cap_ioctl_t *)cmds); | ||||
#endif | #endif | ||||
if (reinit) { | if (reinit) { | ||||
error = vm_reinit(ctx); | error = vm_reinit(ctx); | ||||
if (error) { | if (error) { | ||||
perror("vm_reinit"); | perror("vm_reinit"); | ||||
Not Done Inline Actionsextra debugging to be removed emaste: extra debugging to be removed | |||||
exit(4); | exit(4); | ||||
} | } | ||||
} | } | ||||
error = vm_set_topology(ctx, sockets, cores, threads, maxcpus); | error = vm_set_topology(ctx, sockets, cores, threads, maxcpus); | ||||
if (error) | if (error) | ||||
errx(EX_OSERR, "vm_set_topology"); | errx(EX_OSERR, "vm_set_topology"); | ||||
return (ctx); | return (ctx); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
char *optstr; | char *optstr; | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
char *restore_file; | char *restore_file; | ||||
struct restore_state rstate; | struct restore_state rstate; | ||||
int vcpu; | int vcpu; | ||||
restore_file = NULL; | restore_file = NULL; | ||||
#endif | #endif | ||||
char *ckp_path = NULL; | |||||
init_config(); | init_config(); | ||||
set_defaults(); | set_defaults(); | ||||
progname = basename(argv[0]); | progname = basename(argv[0]); | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
optstr = "aehuwxACDHIPSWYk:o:p:G:c:s:m:l:K:U:r:"; | optstr = "aehuwxACDHIPSWYk:o:p:G:c:s:m:l:K:U:r:t:"; | ||||
#else | #else | ||||
optstr = "aehuwxACDHIPSWYk:o:p:G:c:s:m:l:K:U:"; | optstr = "aehuwxACDHIPSWYk:o:p:G:c:s:m:l:K:U:"; | ||||
#endif | #endif | ||||
while ((c = getopt(argc, argv, optstr)) != -1) { | while ((c = getopt(argc, argv, optstr)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'a': | case 'a': | ||||
set_config_bool("x86.x2apic", false); | set_config_bool("x86.x2apic", false); | ||||
break; | break; | ||||
Show All 35 Lines | case 'l': | ||||
errx(EX_USAGE, "invalid lpc device " | errx(EX_USAGE, "invalid lpc device " | ||||
"configuration '%s'", optarg); | "configuration '%s'", optarg); | ||||
} | } | ||||
break; | break; | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
case 'r': | case 'r': | ||||
restore_file = optarg; | restore_file = optarg; | ||||
break; | break; | ||||
case 't': | |||||
Not Done Inline ActionsPlease document this in the bhyve(8) man page. markj: Please document this in the bhyve(8) man page. | |||||
ckp_path = optarg; | |||||
break; | |||||
#endif | #endif | ||||
case 's': | case 's': | ||||
if (strncmp(optarg, "help", strlen(optarg)) == 0) { | if (strncmp(optarg, "help", strlen(optarg)) == 0) { | ||||
pci_print_supported_devices(); | pci_print_supported_devices(); | ||||
exit(0); | exit(0); | ||||
} else if (pci_parse_slot(optarg) != 0) | } else if (pci_parse_slot(optarg) != 0) | ||||
exit(4); | exit(4); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | #endif | ||||
if (lpc_bootrom()) | if (lpc_bootrom()) | ||||
fwctl_init(); | fwctl_init(); | ||||
/* | /* | ||||
* Change the proc title to include the VM name. | * Change the proc title to include the VM name. | ||||
*/ | */ | ||||
setproctitle("%s", vmname); | setproctitle("%s", vmname); | ||||
#ifndef WITHOUT_CAPSICUM | |||||
caph_cache_catpages(); | |||||
if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1) | |||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | |||||
if (caph_enter() == -1) | |||||
errx(EX_OSERR, "cap_enter() failed"); | |||||
#endif | |||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
if (restore_file != NULL) | if (restore_file != NULL) | ||||
Not Done Inline Actionsstrange whitespace here emaste: strange whitespace here | |||||
destroy_restore_state(&rstate); | destroy_restore_state(&rstate); | ||||
/* initialize mutex/cond variables */ | /* initialize mutex/cond variables */ | ||||
init_snapshot(); | init_snapshot(ckp_path); | ||||
/* | /* | ||||
* checkpointing thread for communication with bhyvectl | * checkpointing thread for communication with bhyvectl | ||||
Not Done Inline ActionsThis should be called from init_snapshot(), not from the top-level bhyve code. It only initializes state for the snapshot code. markj: This should be called from init_snapshot(), not from the top-level bhyve code. It only… | |||||
*/ | */ | ||||
if (init_checkpoint_thread(ctx) < 0) | if (init_checkpoint_thread(ctx) < 0) | ||||
printf("Failed to start checkpoint thread!\r\n"); | printf("Failed to start checkpoint thread!\r\n"); | ||||
gusev.vitaliy_gmail.comUnsubmitted Not Done Inline ActionsHere should be added exit/err on fail. I guess having checkpoint thread is critical or, if not, it should rely on new introduces "-t" parameter: if "-t" is specified, checkpoint is activated. gusev.vitaliy_gmail.com: Here should be added exit/err on fail. I guess having checkpoint thread is critical or, if not… | |||||
if (restore_file != NULL) | if (restore_file != NULL) | ||||
vm_restore_time(ctx); | vm_restore_time(ctx); | ||||
#endif | |||||
#ifndef WITHOUT_CAPSICUM | |||||
caph_cache_catpages(); | |||||
if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1) | |||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | |||||
if (caph_enter() == -1) | |||||
errx(EX_OSERR, "cap_enter() failed"); | |||||
#endif | #endif | ||||
/* | /* | ||||
* Add CPU 0 | * Add CPU 0 | ||||
*/ | */ | ||||
fbsdrun_addcpu(ctx, BSP, BSP, rip); | fbsdrun_addcpu(ctx, BSP, BSP, rip); | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
Show All 22 Lines |
This should be further down, together with other userspace headers.