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 992 Lines • ▼ Show 20 Lines | spinup_vcpu(struct vmctx *ctx, int vcpu) | ||||||||
fbsdrun_set_capabilities(ctx, vcpu); | fbsdrun_set_capabilities(ctx, vcpu); | ||||||||
error = vm_set_capability(ctx, vcpu, VM_CAP_UNRESTRICTED_GUEST, 1); | error = vm_set_capability(ctx, vcpu, VM_CAP_UNRESTRICTED_GUEST, 1); | ||||||||
assert(error == 0); | assert(error == 0); | ||||||||
fbsdrun_addcpu(ctx, BSP, vcpu, rip); | fbsdrun_addcpu(ctx, BSP, vcpu, rip); | ||||||||
} | } | ||||||||
bool | |||||||||
is_valid_uuid(const char* uuid_str) | |||||||||
{ | |||||||||
uuid_t uuid; | |||||||||
uint32_t uuid_status; | |||||||||
uuid_from_string(uuid_str, &uuid, &uuid_status); | |||||||||
return uuid_status == uuid_s_ok; | |||||||||
} | |||||||||
int | int | ||||||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||||||
{ | { | ||||||||
int c, error, err; | int c, error, err; | ||||||||
int max_vcpus, mptgen, memflags; | int max_vcpus, mptgen, memflags; | ||||||||
int rtc_localtime; | int rtc_localtime; | ||||||||
bool gdb_stop; | bool gdb_stop; | ||||||||
struct vmctx *ctx; | struct vmctx *ctx; | ||||||||
▲ Show 20 Lines • Show All 103 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': | ||||||||
if (is_valid_uuid(optarg) == false) { | |||||||||
errx(EX_USAGE, "invalid UUID '%s'", optarg); | |||||||||
} | |||||||||
guest_uuid_str = optarg; | guest_uuid_str = 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 |