Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||||||
#include <libgen.h> | #include <libgen.h> | ||||||||
#include <unistd.h> | #include <unistd.h> | ||||||||
#include <assert.h> | #include <assert.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 <uuid.h> | |||||||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||||||
#include <ucl.h> | #include <ucl.h> | ||||||||
#include <unistd.h> | #include <unistd.h> | ||||||||
#include <libxo/xo.h> | #include <libxo/xo.h> | ||||||||
#endif | #endif | ||||||||
#include <machine/vmm.h> | #include <machine/vmm.h> | ||||||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||||||
typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu); | typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu); | ||||||||
extern int vmexit_task_switch(struct vmctx *, struct vm_exit *, int *vcpu); | extern int vmexit_task_switch(struct vmctx *, struct vm_exit *, int *vcpu); | ||||||||
const char *vmname; | const char *vmname; | ||||||||
int guest_ncpus; | int guest_ncpus; | ||||||||
uint16_t cores, maxcpus, sockets, threads; | uint16_t cores, maxcpus, sockets, threads; | ||||||||
char *guest_uuid_str; | uuid_t guest_uuid; | ||||||||
int raw_stdio = 0; | int raw_stdio = 0; | ||||||||
static int gdb_port = 0; | static int gdb_port = 0; | ||||||||
static int guest_vmexit_on_hlt, guest_vmexit_on_pause; | static int guest_vmexit_on_hlt, guest_vmexit_on_pause; | ||||||||
static int virtio_msix = 1; | static int virtio_msix = 1; | ||||||||
static int x2apic_mode = 0; /* default is xAPIC */ | static int x2apic_mode = 0; /* default is xAPIC */ | ||||||||
static int destroy_on_poweroff = 0; | static int destroy_on_poweroff = 0; | ||||||||
▲ Show 20 Lines • Show All 901 Lines • ▼ Show 20 Lines | #endif | ||||||||
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; | ||||||||
uuid_create_nil(guest_uuid, NULL); | |||||||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||||||
optstr = "aehuwxACDHIPSWYp:G:c:s:m:l:U:r:"; | optstr = "aehuwxACDHIPSWYp:G:c:s:m:l:U:r:"; | ||||||||
#else | #else | ||||||||
optstr = "aehuwxACDHIPSWYp:G:c:s:m:l:U:"; | optstr = "aehuwxACDHIPSWYp:G:c:s:m:l: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': | ||||||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | case 'P': | ||||||||
break; | break; | ||||||||
case 'e': | case 'e': | ||||||||
strictio = 1; | strictio = 1; | ||||||||
break; | break; | ||||||||
case 'u': | case 'u': | ||||||||
rtc_localtime = 0; | rtc_localtime = 0; | ||||||||
break; | break; | ||||||||
case 'U': | case 'U': | ||||||||
guest_uuid_str = optarg; | uuid_from_string(optarg, &guest_uuid, &error); | ||||||||
if (error != uuid_s_ok) { | |||||||||
errx(EX_USAGE, "invalid UUID '%s'", optarg); | |||||||||
} | |||||||||
break; | break; | ||||||||
case 'w': | case 'w': | ||||||||
strictmsr = 0; | strictmsr = 0; | ||||||||
break; | break; | ||||||||
case 'W': | case 'W': | ||||||||
virtio_msix = 0; | virtio_msix = 0; | ||||||||
break; | break; | ||||||||
case 'x': | case 'x': | ||||||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | if (mptgen) { | ||||||||
error = mptable_build(ctx, guest_ncpus); | error = mptable_build(ctx, guest_ncpus); | ||||||||
if (error) { | if (error) { | ||||||||
perror("error to build the guest tables"); | perror("error to build the guest tables"); | ||||||||
exit(4); | exit(4); | ||||||||
} | } | ||||||||
} | } | ||||||||
error = smbios_build(ctx); | error = smbios_build(ctx); | ||||||||
assert(error == 0); | assert(error == 0); | ||||||||
jhbUnsubmitted Not Done Inline Actions
jhb: | |||||||||
Not Done Inline Actions
jhb: | |||||||||
if (acpi) { | if (acpi) { | ||||||||
Done Inline ActionsPer style(9) when there is only 1 statement in a block you do not enclose it in { }, so this could become just: if (error) exit(4); rgrimes: Per style(9) when there is only 1 statement in a block you do not enclose it in { }, so this… | |||||||||
Not Done Inline ActionsFor the record, style(9) was amended several years ago to allow braces around single-line statements: Space after keywords (if, while, for, return, switch). Two styles of braces (‘{’ and ‘}’) are allowed for single line statements. Either they are used for all single statements, or they are used only where needed for clarity. Usage within a function should be consistent. Forever loops are done with for's, not while's. See https://reviews.freebsd.org/V3 / https://cgit.freebsd.org/src/commit/?id=abb14e5deda3 rpokala: For the record, style(9) was amended several years ago to allow braces around single-line… | |||||||||
error = acpi_build(ctx, guest_ncpus); | error = acpi_build(ctx, guest_ncpus); | ||||||||
assert(error == 0); | assert(error == 0); | ||||||||
Done Inline ActionsHmm, I wonder if we should also exit(4) here as well? and in all the other assert(error == 0) locations? me_jamesrm.com: Hmm, I wonder if we should also exit(4) here as well? and in all the other assert(error == 0)… | |||||||||
Done Inline ActionsSave that for another review :) grehan: Save that for another review :) | |||||||||
} | } | ||||||||
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. | ||||||||
*/ | */ | ||||||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |