Date: Sun, 9 Feb 2014 16:10:12 -0800 From: Neel Natu <neelnatu@gmail.com> To: Craig Rodrigues <rodrigc@freebsd.org> Cc: "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org> Subject: Re: Detect of BHyve VM was powered off or rebooted? Message-ID: <CAFgRE9FXtd_MhmzBbs_f=SNt16wgOSOOwfXn9R7rW1ofzX2Aew@mail.gmail.com> In-Reply-To: <CAG=rPVcsGG7u_5iuPbn2htvmQBYd=bm_9SE2SuA_ZJtMLKGDoA@mail.gmail.com> References: <CAG=rPVcfYQ2nUaZYuc6teL2r%2BQZzxhuoV052zgf6=Dxh8MeNcA@mail.gmail.com> <CAGBxaX=QiO_eThN3gXoEeRJ%2BBqpuA3kCGayORGhgC7b_yNKYGA@mail.gmail.com> <CAG=rPVcsGG7u_5iuPbn2htvmQBYd=bm_9SE2SuA_ZJtMLKGDoA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Craig, On Sun, Feb 9, 2014 at 2:18 PM, Craig Rodrigues <rodrigc@freebsd.org> wrote: > On Sun, Feb 9, 2014 at 1:32 PM, Aryeh Friedman <aryeh.friedman@gmail.com>wrote: > >> >> >> >> On Sun, Feb 9, 2014 at 4:11 PM, Craig Rodrigues <rodrigc@freebsd.org>wrote: >> >>> Hi, >>> >>> I posted some rc.d scripts that I am using to boot a BHyve VM >>> and send the output to a serial console using the /dev/nmdm >>> driver: >>> >>> >>> http://lists.freebsd.org/pipermail/freebsd-virtualization/2014-January/002040.html >>> >>> It works quite well. There is some things I would like to improve, >>> and would like some advice on the best way to do it. >>> >>> (1) If the VM was destroyed with bhyvectl --destroy --vm ${VM_NAME}, >>> then I do not want to automatically restart the VM in the script. >>> User should manually: service bhyvevm start >>> >>> (2) If the VM was powered down, via shutdown -p, or halt -p, >>> then in my script I do not want to restart the VM in the script. >>> User should manually: service bhyvevm start >>> >>> (3) If the VM was rebooted via "reboot" or "shutdown -r", >>> then I *do* want the script to restart the VM. >>> >>> I think if I change my start_vm.sh script to do something like: >>> >>> >>> >>> ( >>> while [ -e /dev/vmm/${VM} ]; do >>> /usr/sbin/bhyve -c 16 -m 8G -A -H -P -g 0 -s 0:0,hostbridge -s 1:0,lpc >>> -s 2:0,virtio-net,${TAP} -s 3:0,virtio-blk,${IMG} -l com1,${CONS_A} ${VM}" >>> done >>> >>> ) & >>> >>> >>> then this might cover cases (1) and (3), but what will cover >>> case (2)? >>> >>> Thanks for any advice. >>> >> >> The options you gave (which are really the only ones available) do not >> distinguish between the reason for the termination of the instance of bhyve >> pointing to /dev/vmm/XXX (it just does a normal termination). >> > > Did you play with any of these flags to bhyvectl? > > [--get-vmcs-exit-ctls] > [--get-vmcs-exit-reason] > [--get-vmcs-exit-qualification] > [--get-vmcs-exit-interruption-info] > > If I do: > bhyvectl --get-vmcs-exit-reason --vm vm1 > > I get: > vmcs_exit_reason[0] 0x000000000000001e > > If I look at: > > http://svnweb.freebsd.org/base/head/sys/amd64/vmm/intel/vmcs.h?view=markup#l310 > > we have: > #define EXIT_REASON_INOUT 30 > > Linux has this stuff also: > http://lxr.free-electrons.com/source/arch/x86/include/asm/vmx.h?v=3.1#L250 > > so I guess these values are defined in some Intel manual. > Yes, but this an entirely different thing. The VMCS exit reason is used to inform the hypervisor what condition caused the guest to stop executing - e.g. a nested page fault. Please don't use it to infer whether the guest wanted to reboot or poweroff :-) > > >> In my playing with this for almost a month the only solution seems to be >> put a trigger on instance shutdown via whatever method to leave a "cookie" >> file behind on the host (note I have not nor plan to do this in any of my >> own work). >> > > Yes, I can see why this might need to be done. I might need to do that > myself. However, if bhyvectl can be used to provide adequate status > information as to why the VM exited, I might be able to avoid this. > > It would be nicer though if /usr/sbin/bhyve returned > the EXIT_REASON in its status code. > Agreed - see my reply to your original post. best Neel > > >> >> An other question is it wise to auto-reboot regardless of reason of the >> hypervisor termination? >> > > I think the answer is "it depends". If someone > does "reboot" or "shutdown -r", I think it is reasonable to restart the > VM. If someone does "halt -p" or "shutdown -p", I think it is reasonable > to not restart the VM. For any other error condition, I think it is > reasonable to not restart the VM. > > I think that there is no single answer for all users and all applications. > In my case, I am running BHyve VM's as "headless" which > I access via the /dev/nmdm driver. If the VM reboots normally, I want it > to restart. > > -- > Craig > _______________________________________________ > freebsd-virtualization@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization > To unsubscribe, send any mail to "freebsd-virtualization-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFgRE9FXtd_MhmzBbs_f=SNt16wgOSOOwfXn9R7rW1ofzX2Aew>