Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 922 Lines • ▼ Show 20 Lines | #ifdef BHYVE_SNAPSHOT | ||||
checkpoint_cpu_resume(*pvcpu); | checkpoint_cpu_resume(*pvcpu); | ||||
#endif | #endif | ||||
return (VMEXIT_CONTINUE); | return (VMEXIT_CONTINUE); | ||||
} | } | ||||
static int | static int | ||||
vmexit_breakpoint(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) | vmexit_breakpoint(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) | ||||
{ | { | ||||
gdb_cpu_breakpoint(*pvcpu, vmexit); | gdb_cpu_breakpoint(*pvcpu, vmexit); | ||||
return (VMEXIT_CONTINUE); | return (VMEXIT_CONTINUE); | ||||
} | } | ||||
static vmexit_handler_t handler[VM_EXITCODE_MAX] = { | static vmexit_handler_t handler[VM_EXITCODE_MAX] = { | ||||
[VM_EXITCODE_INOUT] = vmexit_inout, | [VM_EXITCODE_INOUT] = vmexit_inout, | ||||
[VM_EXITCODE_INOUT_STR] = vmexit_inout, | [VM_EXITCODE_INOUT_STR] = vmexit_inout, | ||||
[VM_EXITCODE_VMX] = vmexit_vmx, | [VM_EXITCODE_VMX] = vmexit_vmx, | ||||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | case 'a': | ||||
break; | break; | ||||
case 'A': | case 'A': | ||||
set_config_bool("acpi_tables", true); | set_config_bool("acpi_tables", true); | ||||
break; | break; | ||||
case 'D': | case 'D': | ||||
set_config_bool("destroy_on_poweroff", true); | set_config_bool("destroy_on_poweroff", true); | ||||
break; | break; | ||||
case 'p': | case 'p': | ||||
if (pincpu_parse(optarg) != 0) { | if (pincpu_parse(optarg) != 0) { | ||||
errx(EX_USAGE, "invalid vcpu pinning " | errx(EX_USAGE, "invalid vcpu pinning " | ||||
"configuration '%s'", optarg); | "configuration '%s'", optarg); | ||||
} | } | ||||
break; | break; | ||||
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': | ||||
set_config_bool("memory.guest_in_core", true); | set_config_bool("memory.guest_in_core", true); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | case 'h': | ||||
usage(0); | usage(0); | ||||
default: | default: | ||||
usage(1); | usage(1); | ||||
} | } | ||||
} | } | ||||
argc -= optind; | argc -= optind; | ||||
argv += optind; | argv += optind; | ||||
if (argc > 1) | #ifdef BHYVE_SNAPSHOT | ||||
if (argc > 1 || (argc == 0 && restore_file == NULL)) | |||||
usage(1); | usage(1); | ||||
#ifdef BHYVE_SNAPSHOT | |||||
if (restore_file != NULL) { | if (restore_file != NULL) { | ||||
error = load_restore_file(restore_file, &rstate); | error = load_restore_file(restore_file, &rstate); | ||||
if (error) { | if (error) { | ||||
fprintf(stderr, "Failed to read checkpoint info from " | fprintf(stderr, "Failed to read checkpoint info from " | ||||
"file: '%s'.\n", restore_file); | "file: '%s'.\n", restore_file); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
vmname = lookup_vmname(&rstate); | vmname = lookup_vmname(&rstate); | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | if (restore_file != NULL) { | ||||
fprintf(stdout, "Restoring vm mem...\r\n"); | fprintf(stdout, "Restoring vm mem...\r\n"); | ||||
if (restore_vm_mem(ctx, &rstate) != 0) { | if (restore_vm_mem(ctx, &rstate) != 0) { | ||||
fprintf(stderr, "Failed to restore VM memory.\n"); | fprintf(stderr, "Failed to restore VM memory.\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
fprintf(stdout, "Restoring pci devs...\r\n"); | fprintf(stdout, "Restoring pci devs...\r\n"); | ||||
if (vm_restore_user_devs(ctx, &rstate) != 0) { | if (walk_and_restore_user_devs(ctx, &rstate) != 0) { | ||||
fprintf(stderr, "Failed to restore PCI device state.\n"); | fprintf(stderr, "Failed to restore PCI device state.\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
fprintf(stdout, "Restoring kernel structs...\r\n"); | fprintf(stdout, "Restoring kernel structs...\r\n"); | ||||
if (vm_restore_kern_structs(ctx, &rstate) != 0) { | if (vm_restore_kern_structs(ctx, &rstate) != 0) { | ||||
fprintf(stderr, "Failed to restore kernel structs.\n"); | fprintf(stderr, "Failed to restore kernel structs.\n"); | ||||
exit(1); | exit(1); | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | for (vcpu = 0; vcpu < guest_ncpus; vcpu++) { | ||||
if (vcpu == BSP) | if (vcpu == BSP) | ||||
continue; | continue; | ||||
fprintf(stdout, "spinning up vcpu no %d...\r\n", vcpu); | fprintf(stdout, "spinning up vcpu no %d...\r\n", vcpu); | ||||
spinup_vcpu(ctx, vcpu); | spinup_vcpu(ctx, vcpu); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* Head off to the main event dispatch loop | * Head off to the main event dispatch loop | ||||
*/ | */ | ||||
mevent_dispatch(); | mevent_dispatch(); | ||||
exit(4); | exit(4); | ||||
} | } |