Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Aug 2014 11:15:50 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Craig Rodrigues <rodrigc@freebsd.org>
Cc:        "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org>
Subject:   Re: libvirt and rebooting of a bhyve VM
Message-ID:  <201408201115.50392.jhb@freebsd.org>
In-Reply-To: <CAG=rPVfi0fwUyHF_dkzKX9ejo4Na4wLSuufaqBoo0U7p7ypCZA@mail.gmail.com>
References:  <CAG=rPVcGFSnMcMdrNtWjUtHUc0RLXps-t9WwzokNtyHQwWDfFQ@mail.gmail.com> <201408191332.48730.jhb@freebsd.org> <CAG=rPVfi0fwUyHF_dkzKX9ejo4Na4wLSuufaqBoo0U7p7ypCZA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, August 19, 2014 2:33:19 pm Craig Rodrigues wrote:
> On Tue, Aug 19, 2014 at 10:32 AM, John Baldwin <jhb@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408201115.50392.jhb>