Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2014 11:33:19 -0700
From:      Craig Rodrigues <rodrigc@FreeBSD.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org>
Subject:   Re: libvirt and rebooting of a bhyve VM
Message-ID:  <CAG=rPVfi0fwUyHF_dkzKX9ejo4Na4wLSuufaqBoo0U7p7ypCZA@mail.gmail.com>
In-Reply-To: <201408191332.48730.jhb@freebsd.org>
References:  <CAG=rPVcGFSnMcMdrNtWjUtHUc0RLXps-t9WwzokNtyHQwWDfFQ@mail.gmail.com> <20140819154035.GA62903@kloomba> <CAG=rPVdGuuKuYsPKy%2BO5o8i_fOZ8qrxh27N%2BY2dNVysXapu13A@mail.gmail.com> <201408191332.48730.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

--
Craig



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