Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Context not available. | |||||
char *vmname; | char *vmname; | ||||
int guest_ncpus; | int guest_ncpus; | ||||
uint16_t cores, maxcpus, sockets, threads; | |||||
grehan: uint16_t -> uint16_t | |||||
char *guest_uuid_str; | char *guest_uuid_str; | ||||
static int guest_vmexit_on_hlt, guest_vmexit_on_pause; | static int guest_vmexit_on_hlt, guest_vmexit_on_pause; | ||||
Context not available. | |||||
{ | { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Usage: %s [-abehuwxACHPSWY] [-c vcpus] [-g <gdb port>] [-l <lpc>]\n" | "Usage: %s [-abehuwxACHPSWY]\n" | ||||
" %*s [-c [cpus=]numcpus[,sockets=n][,cores=n][,threads=n]]\n" | |||||
" %*s [-g <gdb port>] [-l <lpc>]\n" | |||||
" %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n" | " %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n" | ||||
" -a: local apic is in xAPIC mode (deprecated)\n" | " -a: local apic is in xAPIC mode (deprecated)\n" | ||||
" -A: create ACPI tables\n" | " -A: create ACPI tables\n" | ||||
" -c: # cpus (default 1)\n" | " -c: [cpus=]numcpus[,sockets=n][,cores=n][,threads=n]\n" | ||||
" -C: include guest memory in core file\n" | " -C: include guest memory in core file\n" | ||||
" -e: exit on unhandled I/O access\n" | " -e: exit on unhandled I/O access\n" | ||||
" -g: gdb port\n" | " -g: gdb port\n" | ||||
Context not available. | |||||
" -W: force virtio to use single-vector MSI\n" | " -W: force virtio to use single-vector MSI\n" | ||||
" -x: local apic is in x2APIC mode\n" | " -x: local apic is in x2APIC mode\n" | ||||
" -Y: disable MPtable generation\n", | " -Y: disable MPtable generation\n", | ||||
progname, (int)strlen(progname), ""); | progname, (int)strlen(progname), "", (int)strlen(progname), "", | ||||
(int)strlen(progname), ""); | |||||
exit(code); | exit(code); | ||||
} | } | ||||
static int | static int | ||||
topology_parse(const char *opt) | |||||
{ | |||||
char *cp, *str; | |||||
int i; | |||||
uint16_t tmp; | |||||
str = strdup(opt); | |||||
if ((cp = strchr(str, ',')) != NULL) { | |||||
for (i = 0; str; i++) { | |||||
if (sscanf(str, "cpus=%hu", &tmp) == 1) | |||||
guest_ncpus = tmp; | |||||
else if (sscanf(str, "sockets=%hu", &tmp) == 1) | |||||
sockets = tmp; | |||||
else if (sscanf(str, "cores=%hu", &tmp) == 1) | |||||
cores = tmp; | |||||
Done Inline Actionsmaxcpus is currently a no-op so it doesn't need to be exposed. No harm in having it in the internal api though. grehan: maxcpus is currently a no-op so it doesn't need to be exposed. No harm in having it in the… | |||||
else if (sscanf(str, "threads=%hu", &tmp) == 1) | |||||
threads = tmp; | |||||
#ifdef notyet /* Do not expose this until vmm.ko implements it */ | |||||
else if (sscanf(str, "maxcpus=%hu", &tmp) == 1) | |||||
maxcpus = tmp; | |||||
#endif | |||||
else | |||||
return (-1); | |||||
if (cp == NULL) | |||||
str = NULL; | |||||
else { | |||||
str = ++cp; | |||||
cp = strchr(str, ','); | |||||
} | |||||
} | |||||
} else { | |||||
if (sscanf(str, "cpus=%hu", &tmp) == 1) | |||||
guest_ncpus = tmp; | |||||
else if (sscanf(str, "%hu", &tmp) == 1) | |||||
guest_ncpus = tmp; | |||||
else | |||||
return (-1); | |||||
} | |||||
if (guest_ncpus != sockets * cores * threads) | |||||
return (-1); | |||||
else | |||||
return(0); | |||||
} | |||||
static int | |||||
pincpu_parse(const char *opt) | pincpu_parse(const char *opt) | ||||
{ | { | ||||
int vcpu, pcpu; | int vcpu, pcpu; | ||||
Done Inline ActionsShould check an error return here. grehan: Should check an error return here. | |||||
Context not available. | |||||
exit(1); | exit(1); | ||||
} | } | ||||
} | } | ||||
error = vm_set_topology(ctx, sockets, cores, threads, maxcpus); | |||||
if (error) { | |||||
perror("vm_set_topology"); | |||||
exit(1); | |||||
} | |||||
return (ctx); | return (ctx); | ||||
} | } | ||||
Context not available. | |||||
progname = basename(argv[0]); | progname = basename(argv[0]); | ||||
gdb_port = 0; | gdb_port = 0; | ||||
guest_ncpus = 1; | guest_ncpus = 1; | ||||
sockets = cores = threads = 1; | |||||
maxcpus = 0; | |||||
memsize = 256 * MB; | memsize = 256 * MB; | ||||
mptgen = 1; | mptgen = 1; | ||||
rtc_localtime = 1; | rtc_localtime = 1; | ||||
Context not available. | |||||
} | } | ||||
break; | break; | ||||
case 'c': | case 'c': | ||||
guest_ncpus = atoi(optarg); | if (topology_parse(optarg) !=0) { | ||||
errx(EX_USAGE, "invalid cpu topology " | |||||
"'%s'", optarg); | |||||
} | |||||
break; | break; | ||||
case 'C': | case 'C': | ||||
memflags |= VM_MEM_F_INCORE; | memflags |= VM_MEM_F_INCORE; | ||||
Context not available. |
uint16_t -> uint16_t