Bug 242684 - sysutils/vm-bhyve: service vm stop
Summary: sysutils/vm-bhyve: service vm stop
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Dmitry Marakasov
Depends on:
Reported: 2019-12-17 11:55 UTC by Bernhard Berger
Modified: 2021-03-17 00:20 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (churchers)


Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Berger 2019-12-17 11:55:18 UTC
I found a problem with VM-BHYVE.

VM-BHYVE provides a service vm which starts /stop the VM's on system startup and on system stop. 

The problem is with shutdown of the host system. The script in /usr/local/etc/rc.d/vm uses "vm stopall" to terminate the VM's. 
vm stopall sends the VM's the signal to shut down the system. if "vm stopall" is done, the script "/usr/local/etc/rc.d/vm" is done, too, so that the shutdown process of the host is continued and this is the problem, because "vm stopall" does not wait until the VM's are really finished and the shutdown processes of the host are continued, the VM's which are not finished with the schutdown will be aborted. This leads to broken file systems in the VM's -> fatal

they can easily verify that. Start a VM in a shell a: vm -f start test and now stop the VM: vm stop test in another shell b and you will see that the command in shell b is finished faster and the VM in shell a is still in the shutdown process.  

My suggestion:
In the script:
in the function core::stopall() or core::stop()

to add a check function that waits with the continuation until the VM's are actually finished. so the task: bhyve <vm-name> has disappeared.

This way you can make sure that when the host system is stopped, all VM's are really stopped.
Comment 1 Mateusz Piotrowski freebsd_committer 2019-12-17 13:24:12 UTC
(In reply to Bernhard Berger from comment #0)
Thanks for the report!

I guess this could be discussed upstream so that a fix for this problem could be included in the next release of vm-bhyve: https://github.com/churchers/vm-bhyve

Comment 2 Bernhard Berger 2020-01-05 08:17:41 UTC
This information might be helpful to know!
I found out that when using "reboot" the function "stop" in the service vm is not executed because reboot obviously does not execute the script /etc/rc.shutdown (see ticket 243094)
Comment 3 Dmitry Marakasov freebsd_committer 2021-03-17 00:20:17 UTC
So this is not related to vm-bhyve rc script.