Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <pthread_np.h> | #include <pthread_np.h> | ||||
#include <sysexits.h> | #include <sysexits.h> | ||||
#include <stdbool.h> | #include <stdbool.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <libxo/xo.h> | |||||
#include <machine/vmm.h> | #include <machine/vmm.h> | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
#include <machine/vmm_dev.h> | #include <machine/vmm_dev.h> | ||||
#endif | #endif | ||||
#include <vmmapi.h> | #include <vmmapi.h> | ||||
#include "bhyverun.h" | #include "bhyverun.h" | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
static cpuset_t *vcpumap[VM_MAXCPU] = { NULL }; | static cpuset_t *vcpumap[VM_MAXCPU] = { NULL }; | ||||
static void | static void | ||||
usage(int code) | usage(int code) | ||||
{ | { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Usage: %s [-abehuwxACHPSWY]\n" | "Usage: %s [-abefhuwxACHPSWY]\n" | ||||
" %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n" | " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n" | ||||
" %*s [-g <gdb port>] [-l <lpc>]\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: number of cpus and/or topology specification\n" | " -c: number of cpus and/or topology specification\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" | ||||
" -f: show supported emulator features\n" | |||||
" -g: gdb port\n" | " -g: gdb port\n" | ||||
" -h: help\n" | " -h: help\n" | ||||
" -H: vmexit from the guest on hlt\n" | " -H: vmexit from the guest on hlt\n" | ||||
" -l: LPC device configuration\n" | " -l: LPC device configuration\n" | ||||
" -m: memory size in MB\n" | " -m: memory size in MB\n" | ||||
" -p: pin 'vcpu' to 'hostcpu'\n" | " -p: pin 'vcpu' to 'hostcpu'\n" | ||||
" -P: vmexit from the guest on pause\n" | " -P: vmexit from the guest on pause\n" | ||||
" -s: <slot,driver,configinfo> PCI slot config\n" | " -s: <slot,driver,configinfo> PCI slot config\n" | ||||
" -S: guest memory cannot be swapped\n" | " -S: guest memory cannot be swapped\n" | ||||
" -u: RTC keeps UTC time\n" | " -u: RTC keeps UTC time\n" | ||||
" -U: uuid\n" | " -U: uuid\n" | ||||
" -w: ignore unimplemented MSRs\n" | " -w: ignore unimplemented MSRs\n" | ||||
" -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), "", (int)strlen(progname), "", | progname, (int)strlen(progname), "", (int)strlen(progname), "", | ||||
(int)strlen(progname), ""); | (int)strlen(progname), ""); | ||||
exit(code); | exit(code); | ||||
} | } | ||||
static void | |||||
show_emulator_features() | |||||
{ | |||||
/* top-level container */ | |||||
xo_open_container("bhyve"); | |||||
xo_emit("{L:Schema version}: {:schema_version}\n", "1.0"); | |||||
/* features collection container */ | |||||
xo_open_container("features"); | |||||
/* rtc_utc */ | |||||
xo_open_container("feature"); | |||||
xo_open_container("rtc_utc"); | |||||
xo_emit("\n{T:rtc_utc}\n"); | |||||
xo_emit("{L:Description}: {:description}\n", "RTC keeps UTC time"); | |||||
xo_open_container("cmd"); | |||||
xo_emit("{L:Command line switch}: {:switch}\n", "-u"); | |||||
xo_close_container("cmd"); | |||||
xo_close_container("rtc_utc"); | |||||
xo_close_container("feature"); | |||||
/* wire_guest_memory */ | |||||
xo_open_container("feature"); | |||||
xo_open_container("wire_guest_memory"); | |||||
xo_emit("\n{T:wire_guest_memory}\n"); | |||||
xo_emit("{L:Description}: {:description}\n", "Wire guest memory"); | |||||
xo_open_container("cmd"); | |||||
xo_emit("{L:Command line switch}: {:switch}\n", "-S"); | |||||
xo_close_container("cmd"); | |||||
xo_close_container("wire_guest_memory"); | |||||
xo_close_container("feature"); | |||||
/* devices */ | |||||
xo_open_container("feature"); | |||||
xo_open_container("devices"); | |||||
xo_emit("\n{T:devices}\n"); | |||||
xo_emit("{L:Description}: {:description}\n", "Devices support"); | |||||
xo_open_container("cmd"); | |||||
xo_emit("{L:Command line switch}: {:switch}\n", "-s"); | |||||
xo_open_list("arguments"); | |||||
/* virtio-net */ | |||||
xo_open_instance("arguments"); | |||||
xo_emit("{L:Arguments}: {:options/%s} {L:Description}: {:description/%s}\n", | |||||
"virtio-net,tapN,mac=xx:xx:xx:xx:xx:xx", | |||||
"Virtio network device"); | |||||
xo_close_instance("arguments"); | |||||
/* virtio-block */ | |||||
xo_open_instance("arguments"); | |||||
xo_emit("{L:Arguments}: {:options/%s} {L:Description}: {:description/%s}\n", | |||||
"virtio-blk,path,nocache,direct,ro,sectorsize=logical/physical", | |||||
"Virtio block device"); | |||||
xo_close_instance("arguments"); | |||||
/* fbuf */ | |||||
xo_open_instance("arguments"); | |||||
xo_emit("{L:Arguments}: '{:options/%s}' {L:Description}: {:description/%s}\n", | |||||
"fbuf,rfb,rfb=IP:port,w=width,h=heigh,vga=vgaconf,wait,password=password", | |||||
"Framebuffer device"); | |||||
xo_close_instance("arguments"); | |||||
xo_close_list("arguments"); | |||||
xo_close_container("cmd"); | |||||
xo_close_container("devices"); | |||||
xo_close_container("feature"); | |||||
xo_close_container("features"); | |||||
xo_close_container("bhyve"); | |||||
xo_finish(); | |||||
} | |||||
/* | /* | ||||
* XXX This parser is known to have the following issues: | * XXX This parser is known to have the following issues: | ||||
* 1. It accepts null key=value tokens ",,". | * 1. It accepts null key=value tokens ",,". | ||||
* 2. It accepts whitespace after = and before value. | * 2. It accepts whitespace after = and before value. | ||||
* 3. Values out of range of INT are silently wrapped. | * 3. Values out of range of INT are silently wrapped. | ||||
* 4. It doesn't check non-final values. | * 4. It doesn't check non-final values. | ||||
* 5. The apparently bogus limits of UINT16_MAX are for future expansion. | * 5. The apparently bogus limits of UINT16_MAX are for future expansion. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 735 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
guest_ncpus = 1; | guest_ncpus = 1; | ||||
sockets = cores = threads = 1; | sockets = cores = threads = 1; | ||||
maxcpus = 0; | maxcpus = 0; | ||||
memsize = 256 * MB; | memsize = 256 * MB; | ||||
mptgen = 1; | mptgen = 1; | ||||
rtc_localtime = 1; | rtc_localtime = 1; | ||||
memflags = 0; | memflags = 0; | ||||
optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:U:"; | argc = xo_parse_args(argc, argv); | ||||
if (argc < 0) | |||||
exit(1); | |||||
optstr = "abefhuwxACHIPSWYp:g:G:c:s:m:l:U:"; | |||||
while ((c = getopt(argc, argv, optstr)) != -1) { | while ((c = getopt(argc, argv, optstr)) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'a': | case 'a': | ||||
x2apic_mode = 0; | x2apic_mode = 0; | ||||
break; | break; | ||||
case 'A': | case 'A': | ||||
acpi = 1; | acpi = 1; | ||||
break; | break; | ||||
Show All 9 Lines | case 'p': | ||||
case 'c': | case 'c': | ||||
if (topology_parse(optarg) != 0) { | if (topology_parse(optarg) != 0) { | ||||
errx(EX_USAGE, "invalid cpu topology " | errx(EX_USAGE, "invalid cpu topology " | ||||
"'%s'", optarg); | "'%s'", optarg); | ||||
} | } | ||||
break; | break; | ||||
case 'C': | case 'C': | ||||
memflags |= VM_MEM_F_INCORE; | memflags |= VM_MEM_F_INCORE; | ||||
break; | |||||
case 'f': | |||||
show_emulator_features(); | |||||
exit(0); | |||||
break; | break; | ||||
case 'g': | case 'g': | ||||
dbg_port = atoi(optarg); | dbg_port = atoi(optarg); | ||||
break; | break; | ||||
case 'G': | case 'G': | ||||
if (optarg[0] == 'w') { | if (optarg[0] == 'w') { | ||||
gdb_stop = true; | gdb_stop = true; | ||||
optarg++; | optarg++; | ||||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |