From owner-freebsd-virtualization@freebsd.org Tue Apr 23 05:27:12 2019 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85129158EDB1 for ; Tue, 23 Apr 2019 05:27:12 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E8F9F8FED8 for ; Tue, 23 Apr 2019 05:27:11 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id x3N5R9ap036074; Mon, 22 Apr 2019 22:27:09 -0700 (PDT) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: (from freebsd-rwg@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id x3N5R96x036073; Mon, 22 Apr 2019 22:27:09 -0700 (PDT) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201904230527.x3N5R96x036073@gndrsh.dnsmgr.net> Subject: Re: [vm-bhyve] Windows 2012 and 2016 servers guests would not stop In-Reply-To: <20190423041358.GA2992@admin.sibptus.ru> To: Victor Sudakov Date: Mon, 22 Apr 2019 22:27:09 -0700 (PDT) CC: freebsd-virtualization@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: E8F9F8FED8 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.982,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 23 Apr 2019 05:27:12 -0000 -- Start of PGP signed section. > Paul Vixie wrote: > > > > Victor Sudakov wrote on 2019-04-22 19:43: > > ... > > >> And the implementation is pretty brutal: > > >> # 'vm stopall' > > >> # stop all bhyve instances > > >> # note this will also stop instances not started by vm-bhyve > > >> # > > >> core::stopall(){ > > >> local _pids=$(pgrep -f 'bhyve:') > > >> > > >> echo "Shutting down all bhyve virtual machines" > > >> killall bhyve > > >> sleep 1 > > >> killall bhyve > > >> wait_for_pids ${_pids} > > >> } > > > > yow. > > To be sure, I was unable to find the above code (as is) in > /usr/local/lib/vm-bhyve/vm-* (the vm-bhyve port 1.3.0). It may be that > something more intelligent is happening in a more recent version, like a > sequential shutdown. However, "kill $pid; sleep 1; kill $pid" seems to > be still present. I probably pulled that from old code, pulled from: vm-bhyve-1.2.3 Management system for bhyve virtual machines > > > > > >> > > >> I wonder what the effect of the second kill is, > > >> that seems odd. > > > > > > Indeed. > > > > the first killall will cause each client OS to see a soft shutdown > > signal. the sleep 1 gives them some time to flush their buffers. the > > second killall says, time's up, just stop. > > > > i think this is worse than brutal, it's wrong. consider freebsd's own > > work flow when trying to comply with the first soft shutdown it got: > > > > https://github.com/freebsd/freebsd/blob/master/sbin/reboot/reboot.c#L220 > > > > this has bitten me more than once, because using "pageins" as a proxy > > for "my server processes are busy trying to synchronize their user mode > > state" is inaccurate. i think _any_ continuing I/O should be reason to > > wait the full 60 seconds. > > Would it be beneficial to just hack /usr/local/lib/vm-bhyve/vm-* ? One can always hack experiments, my vm-bhyve is fairly diverged from the release bits as I have done stuff to it so that it better meets my needs. Most of that is not submittable as upstream changes, some I should really sort out and try to push up. Some is due to local changes to bhyve that are not mainstream and thus are not (yet) applicable. > > and so i think the "sleep 1" above should be a "sleep 65". > > > > > What is needed in vm-bhyve is the feature that if ACPI does not stop the > > > guest for a predefined period of time, the guest is powered off. > > > > i agree with this. > > Will you please support the bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237479 More powerfull would be if we could come up with some patches against 1.3.0 that effected some of the changes we desire. And some more investigation as to just how the guests are handling this ACPI shutdown event. What might be wrong for FreeBSD might be right for windows? Does the ACPI spec saying anything about hitting the power down button twice within 1 second for example? > Victor Sudakov, VAS4-RIPE, VAS47-RIPN -- Rod Grimes rgrimes@freebsd.org