diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -552,7 +552,7 @@ } static void -fbsdrun_addcpu(struct vmctx *ctx, int newcpu, bool suspend) +fbsdrun_addcpu(struct vmctx *ctx, int newcpu) { int error; @@ -562,8 +562,7 @@ CPU_SET_ATOMIC(newcpu, &cpumask); - if (suspend) - vm_suspend_cpu(ctx, newcpu); + vm_suspend_cpu(ctx, newcpu); mt_vmm_info[newcpu].mt_ctx = ctx; mt_vmm_info[newcpu].mt_vcpu = newcpu; @@ -1138,7 +1137,7 @@ } static void -spinup_vcpu(struct vmctx *ctx, int vcpu, bool suspend) +spinup_vcpu(struct vmctx *ctx, int vcpu) { int error; @@ -1154,7 +1153,7 @@ assert(error == 0); } - fbsdrun_addcpu(ctx, vcpu, suspend); + fbsdrun_addcpu(ctx, vcpu); } static bool @@ -1488,6 +1487,16 @@ assert(error == 0); } + /* Allocate per-VCPU resources. */ + mt_vmm_info = calloc(guest_ncpus, sizeof(*mt_vmm_info)); + + /* + * Add all vCPUs. + */ + for (int vcpu = 0; vcpu < guest_ncpus; vcpu++) { + spinup_vcpu(ctx, vcpu); + } + #ifdef BHYVE_SNAPSHOT if (restore_file != NULL) { fprintf(stdout, "Pausing pci devs...\r\n"); @@ -1564,9 +1573,6 @@ #endif #ifdef BHYVE_SNAPSHOT - if (restore_file != NULL) - destroy_restore_state(&rstate); - /* initialize mutex/cond variables */ init_snapshot(); @@ -1576,24 +1582,18 @@ if (init_checkpoint_thread(ctx) < 0) printf("Failed to start checkpoint thread!\r\n"); - if (restore_file != NULL) + if (restore_file != NULL) { + destroy_restore_state(&rstate); vm_restore_time(ctx); -#endif - - /* Allocate per-VCPU resources. */ - mt_vmm_info = calloc(guest_ncpus, sizeof(*mt_vmm_info)); - /* - * Add all vCPUs. - */ - for (int vcpu = 0; vcpu < guest_ncpus; vcpu++) { - bool suspend = (vcpu != BSP); -#ifdef BHYVE_SNAPSHOT - if (restore_file != NULL) - suspend = false; -#endif - spinup_vcpu(ctx, vcpu, suspend); + for (int i = 0; i < guest_ncpus; i++) { + if (i == BSP) + continue; + vm_resume_cpu(ctx, i); + } } +#endif + vm_resume_cpu(ctx, BSP); /* * Head off to the main event dispatch loop