From owner-freebsd-virtualization@freebsd.org Wed Apr 13 12:37:26 2016 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 463B8B0E337 for ; Wed, 13 Apr 2016 12:37:26 +0000 (UTC) (envelope-from nvass@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F17D1246 for ; Wed, 13 Apr 2016 12:37:25 +0000 (UTC) (envelope-from nvass@gmx.com) Received: from moby.local ([91.140.61.167]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MXmpv-1bJl751GY3-00WqDj; Wed, 13 Apr 2016 14:37:16 +0200 Subject: Re: Understanding Bhyve shutdown To: Roman Bogorodskiy , freebsd-virtualization@FreeBSD.org References: <20160413105520.GB84953@dev.san.ru> From: Nikos Vassiliadis Message-ID: <570E3D59.5090609@gmx.com> Date: Wed, 13 Apr 2016 15:36:41 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160413105520.GB84953@dev.san.ru> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:0xLEs3NlbcVAkYhMF4Q0osMF7Rl3s+85kPzaTK10wJvsBjBc5+F wm1DNEeNzB4RGwyxT/1yUZWIO9HFuRRC5qBrbPW7tkk7QQXjgPXkHcOLDOEugjb9eLw/9kz 1EE6fIZuF7v85qsUm/Gn8oVXgYd3KwB20fcL2rpZIw9mWsf/ybhi0p+4Dxi4gfYZqc8F8u8 xJUtp7AuiDkkDN6R885Yw== X-UI-Out-Filterresults: notjunk:1;V01:K0:KL0W+QPajMs=:6jvAXD656NSaZClRnVBCBM LdfXd9sZdCvyVIWZBj/J/8T4zmJN4NGLHml3okdAhie4yrcDuEk44gQpu8GmJynmv1K2qP+HB PP1FrujQB+Ud4Vcl/NE5FTQuXDI5/BFvJihRKYTuSafkcc3B0lkCrbe+H/uVrsYqe/FQCdrqE ub16SVMH473QFJ04ZaOnjTyvc6YSPJSw4ik4Wzvi9no4UwXYWPh6y9NH5AYH4gBWR53kcwfQE 1JzhPn26JP4yVG0BttrHRer1H2qrh9KBhHd13+Vg7Kp+QFTPAdjsfByHd4ISWCpJ+M+QTTRT3 YqgpzdFwPHiY4SsjfNCSQEJghKksAzaweFXIo3d3RfOvcWSt3ilfseJ7kJdF08UWItmcUhLk0 A18rIgRgBG7osDnESfgjvzk+rMb1KSjLSgBGVlxoevEIL/AXwR7dHUWXY6TtNoMjMnOOD73U2 /fM2uu8pFw8Dv02TmBJRIo340oPeY8ZN1NV/NEA/r3bOCZPTXkNMmvM+wC/Zn1dKXRPShOjqE uVHn7xfC2g7F6ID+PjVBrnrfifR85fVPppUDjOHg18GRo0lA7SJepk6jV+XYhThUt6JEQTDhk FBqNNhNjZrp8zGP9KCkvY9rOrEp+ncv/lta47wSmlVrDbBatctY7Rzzdm3Jmv/qJKFB8SUVU7 otfpA8QMUpWX9nzUQTOKDhQ9DDW5nZZ3pv3F+wF6M0ZzKcpJCsTvu5oqRg4mK5UOQHPz9mwPF 9nTOeboo/Qm58bj0KvUIqrXUKeE5Cw/3hej7t9NfRl3PW0O+HZm71r1BohDdqYPaVX9IMe8nH S6xkRez X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.21 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, 13 Apr 2016 12:37:26 -0000 Hi Roman, On 04/13/16 13:55, Roman Bogorodskiy wrote: > Q1: Is there a way to know if a guest reacted to power button but > waiting for the bhyve process to terminate? I just signal repeatedly $bhyve_pid until it's gone. For what it's worth, I use this /etc/rc.shutdown.local: PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin # shutdown VMs for sig in TERM KILL; do for f in 1 2 3 4 5 6 7 8 9 10; do cmds=`killall -${sig} -q -s bhyve | sed 's/$/;/'` test -z "$cmds" && exit sh -c "$cmds" sleep 1 done done When a VM is hang, it won't respond to TERM, so you might want to use something like, 'for sig in TERM HUP KILL'. It works ok in my experience and I do have some VMs running Java which take a while to shutdown. Our VMs usually shut down within one or two seconds, the Java ones need more but still within ten seconds everything is gone. Experiment a bit and give it enough time to shutdown gracefully and if it's still alive SIGHUP $bhyve_pid. HTH, Nikos