On Tuesday, August 19, 2014 2:33:19 pm Craig Rodrigues wrote:
> On Tue, Aug 19, 2014 at 10:32 AM, John Baldwin <j...@freebsd.org> wrote:
> > The exit code is different.  An ACPI shutdown uses an exit code of 1 
whereas a
> > reboot uses an exit code of 0 IIRC.
> 
> 
> Hi,
> 
> I have a CURRENT system, and ran some tests doing a "shutdown -r" and
> "shutdown -p" verified that you are right,
> with respect to the exit codes.
> 
> Looking at src/usr.sbin/bhyve/bhyverun.c, I see that
> 
> fbsdrun_start_thread() -> vm_loop()
> 
> Inside vm_loop(), there is this line:
> 
> rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu);
> 
> That line ends up calling vmexit_suspend().
> 
> In vmexit_suspend() there is this:
> 
>         switch (how) {
>         case VM_SUSPEND_RESET:
>                 exit(0);
>         case VM_SUSPEND_POWEROFF:
>                 exit(1);
>         case VM_SUSPEND_HALT:
>                 exit(2);
>         case VM_SUSPEND_TRIPLEFAULT:
>                 exit(3);
>         default:
>                 fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
>                 exit(100);
>         }
> 
> 
> I think that:
> 
> (1)  vmrun.sh should be changed a little bit to accomodate this new logic
> (2)  the bhyve man page should document these return codes.

vmrun.sh already handles this.  It breaks out of the loop for any non-zero
exit code and only continues the loop for exit code 0.

It probably would be good to document the return codes in the man page, but
eventually they will all go away.  The long term plan is to make bhyve operate
more like other hypervisors in which case a single process invocation will
mimic a power-on to power-off cycle of a machine and you wouldn't need 
vmrun.sh at all (you would just run bhyve with appropriate args / config 
file).  In that case, the return codes will change since it won't exit for
reboots anymore.

-- 
John Baldwin
_______________________________________________
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"

Reply via email to