Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
#include "amd64/inout.h" | #include "amd64/inout.h" | ||||
#endif | #endif | ||||
#include "debug.h" | #include "debug.h" | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
#include "amd64/e820.h" | #include "amd64/e820.h" | ||||
#include "amd64/fwctl.h" | #include "amd64/fwctl.h" | ||||
#endif | #endif | ||||
#ifdef BHYVE_GDB | |||||
#include "gdb.h" | #include "gdb.h" | ||||
#endif | |||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
#include "amd64/ioapic.h" | #include "amd64/ioapic.h" | ||||
#include "amd64/kernemu_dev.h" | #include "amd64/kernemu_dev.h" | ||||
#endif | #endif | ||||
#include "mem.h" | #include "mem.h" | ||||
#include "mevent.h" | #include "mevent.h" | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
#include "amd64/mptbl.h" | #include "amd64/mptbl.h" | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
usage(int code) | usage(int code) | ||||
{ | { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Usage: %s [-AaCDeHhPSuWwxY]\n" | "Usage: %s [-AaCDeHhPSuWwxY]\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 port] [-k config_file] [-l lpc] [-m mem] [-o var=value]\n" | " %*s [-G port] [-k config_file] [-l lpc] [-m mem] [-o var=value]\n" | ||||
jhb: Do you want to make '-G' here conditional on `BHYVE_GDB`? (Not sure how messy the usage()… | |||||
" %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n" | " %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n" | ||||
" -A: create ACPI tables\n" | " -A: create ACPI tables\n" | ||||
" -a: local apic is in xAPIC mode (deprecated)\n" | " -a: local apic is in xAPIC mode (deprecated)\n" | ||||
" -C: include guest memory in core file\n" | " -C: include guest memory in core file\n" | ||||
" -c: number of CPUs and/or topology specification\n" | " -c: number of CPUs and/or topology specification\n" | ||||
" -D: destroy on power-off\n" | " -D: destroy on power-off\n" | ||||
" -e: exit on unhandled I/O access\n" | " -e: exit on unhandled I/O access\n" | ||||
" -G: start a debug server\n" | " -G: start a debug server\n" | ||||
▲ Show 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | if (vcpumap[vi->vcpuid] != NULL) { | ||||
error = pthread_setaffinity_np(pthread_self(), | error = pthread_setaffinity_np(pthread_self(), | ||||
sizeof(cpuset_t), vcpumap[vi->vcpuid]); | sizeof(cpuset_t), vcpumap[vi->vcpuid]); | ||||
assert(error == 0); | assert(error == 0); | ||||
} | } | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
checkpoint_cpu_add(vi->vcpuid); | checkpoint_cpu_add(vi->vcpuid); | ||||
#endif | #endif | ||||
#ifdef BHYVE_GDB | |||||
gdb_cpu_add(vi->vcpu); | gdb_cpu_add(vi->vcpu); | ||||
#endif | |||||
vm_loop(vi->ctx, vi->vcpu); | vm_loop(vi->ctx, vi->vcpu); | ||||
/* not reached */ | /* not reached */ | ||||
exit(1); | exit(1); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | for (lineno = 1; getline(&line, &linecap, fp) > 0; lineno++) { | ||||
if (!parse_config_option(line)) | if (!parse_config_option(line)) | ||||
errx(4, "%s line %u: invalid config option '%s'", path, | errx(4, "%s line %u: invalid config option '%s'", path, | ||||
lineno, line); | lineno, line); | ||||
} | } | ||||
free(line); | free(line); | ||||
fclose(fp); | fclose(fp); | ||||
} | } | ||||
#ifdef BHYVE_GDB | |||||
static void | static void | ||||
parse_gdb_options(const char *opt) | parse_gdb_options(const char *opt) | ||||
{ | { | ||||
const char *sport; | const char *sport; | ||||
char *colon; | char *colon; | ||||
if (opt[0] == 'w') { | if (opt[0] == 'w') { | ||||
set_config_bool("gdb.wait", true); | set_config_bool("gdb.wait", true); | ||||
opt++; | opt++; | ||||
} | } | ||||
colon = strrchr(opt, ':'); | colon = strrchr(opt, ':'); | ||||
if (colon == NULL) { | if (colon == NULL) { | ||||
sport = opt; | sport = opt; | ||||
} else { | } else { | ||||
*colon = '\0'; | *colon = '\0'; | ||||
colon++; | colon++; | ||||
sport = colon; | sport = colon; | ||||
set_config_value("gdb.address", opt); | set_config_value("gdb.address", opt); | ||||
} | } | ||||
set_config_value("gdb.port", sport); | set_config_value("gdb.port", sport); | ||||
} | } | ||||
#endif | |||||
static void | static void | ||||
set_defaults(void) | set_defaults(void) | ||||
{ | { | ||||
set_config_bool("acpi_tables", true); | set_config_bool("acpi_tables", true); | ||||
set_config_bool("acpi_tables_in_memory", true); | set_config_bool("acpi_tables_in_memory", true); | ||||
set_config_value("memory.size", "256M"); | set_config_value("memory.size", "256M"); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | while ((c = getopt(argc, argv, optstr)) != -1) { | ||||
case 'C': | case 'C': | ||||
set_config_bool("memory.guest_in_core", true); | set_config_bool("memory.guest_in_core", true); | ||||
break; | break; | ||||
case 'f': | case 'f': | ||||
if (qemu_fwcfg_parse_cmdline_arg(optarg) != 0) { | if (qemu_fwcfg_parse_cmdline_arg(optarg) != 0) { | ||||
errx(EX_USAGE, "invalid fwcfg item '%s'", optarg); | errx(EX_USAGE, "invalid fwcfg item '%s'", optarg); | ||||
} | } | ||||
break; | break; | ||||
#ifdef BHYVE_GDB | |||||
case 'G': | case 'G': | ||||
parse_gdb_options(optarg); | parse_gdb_options(optarg); | ||||
break; | break; | ||||
#endif | |||||
case 'k': | case 'k': | ||||
parse_simple_config_file(optarg); | parse_simple_config_file(optarg); | ||||
break; | break; | ||||
case 'K': | case 'K': | ||||
set_config_value("keyboard.layout", optarg); | set_config_value("keyboard.layout", optarg); | ||||
break; | break; | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
case 'l': | case 'l': | ||||
▲ Show 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | #endif | ||||
/* | /* | ||||
* Initialize after PCI, to allow a bootrom file to reserve the high | * Initialize after PCI, to allow a bootrom file to reserve the high | ||||
* region. | * region. | ||||
*/ | */ | ||||
if (get_config_bool("acpi_tables")) | if (get_config_bool("acpi_tables")) | ||||
vmgenc_init(ctx); | vmgenc_init(ctx); | ||||
#ifdef BHYVE_GDB | |||||
init_gdb(ctx); | init_gdb(ctx); | ||||
#endif | |||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
if (lpc_bootrom()) { | if (lpc_bootrom()) { | ||||
if (vm_set_capability(bsp, VM_CAP_UNRESTRICTED_GUEST, 1)) { | if (vm_set_capability(bsp, VM_CAP_UNRESTRICTED_GUEST, 1)) { | ||||
fprintf(stderr, "ROM boot failed: unrestricted guest " | fprintf(stderr, "ROM boot failed: unrestricted guest " | ||||
"capability not available\n"); | "capability not available\n"); | ||||
exit(4); | exit(4); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |
Do you want to make '-G' here conditional on BHYVE_GDB? (Not sure how messy the usage() function ends up at the end of all this)