From owner-freebsd-virtualization@FreeBSD.ORG Wed Aug 20 16:00:42 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8F93F721; Wed, 20 Aug 2014 16:00:42 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 635E93081; Wed, 20 Aug 2014 16:00:42 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 4B6F9B9CD; Wed, 20 Aug 2014 12:00:41 -0400 (EDT) From: John Baldwin To: Craig Rodrigues Subject: Re: libvirt and rebooting of a bhyve VM Date: Wed, 20 Aug 2014 11:15:50 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <201408191332.48730.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201408201115.50392.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 20 Aug 2014 12:00:41 -0400 (EDT) Cc: "freebsd-virtualization@freebsd.org" X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2014 16:00:42 -0000 On Tuesday, August 19, 2014 2:33:19 pm Craig Rodrigues wrote: > On Tue, Aug 19, 2014 at 10:32 AM, John Baldwin 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