Shutting down VM gracefully
Shutting down VM gracefully
Hi I have a CentOS7 VM running on a Windows server 2008 host. Is it possible to configure so that my VM shuts down gracefully when I do a shutdown or restart to the host Windows machine? Thanks
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Shutting down VM gracefully
This is very difficult to do, because of the lack of control in Windows over shutting down programs before the host OS shuts down. Left to its own devices Windows will kill your guests in mid-process. Don't trust the Group Policy shutdown script, the guest will be dead before that script runs.
You should configure your Windows host to not shut down unless a script tells it to, then make sure the script includes commands to deal with your guest before it issues the shutdown command to your host.
Use Group Policy Editor to disappear the Shutdown, Restart and Log Off options in the Start Menu. Set Windows Updates to "Notify before Download" and use the Microsoft script to actually run updates. Get a script together to handle the UPS battery backup routine, instead of just letting the UPS software handle the shutdown.
We have done all these things on our company server (Windows 7 Professional host, SBS2003 & several Win 7 guests) and have had no unexpected shutdowns.
You should configure your Windows host to not shut down unless a script tells it to, then make sure the script includes commands to deal with your guest before it issues the shutdown command to your host.
Use Group Policy Editor to disappear the Shutdown, Restart and Log Off options in the Start Menu. Set Windows Updates to "Notify before Download" and use the Microsoft script to actually run updates. Get a script together to handle the UPS battery backup routine, instead of just letting the UPS software handle the shutdown.
We have done all these things on our company server (Windows 7 Professional host, SBS2003 & several Win 7 guests) and have had no unexpected shutdowns.
Last edited by scottgus1 on 29. Feb 2016, 15:32, edited 1 time in total.
Re: Shutting down VM gracefully
Hi, I was under the impression that the Windows host will post a WM_QUERYENDSESSION message before windows logs off and/or shuts down. As such, Virtualbox will get the message, & in theory, should be able to return 0, which will stop the shutdown sequence, then trigger a shutdown of the guest OSes. When all are happily shutdown, it should be able to trigger windows to shutdown again. Are you sure that Virtualbox can't do this?
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: Shutting down VM gracefully
My experience is as I posted. I've never heard of the VM_QUERYSESSION thing, try it and post back what happened.
-
- Posts: 8
- Joined: 13. Jul 2011, 21:04
- Primary OS: MS Windows 7
- VBox Version: OSE other
- Guest OSses: Win7/XP/Fedora
Re: Shutting down VM gracefully
Seriously? In 2019.scottgus1 wrote:This is very difficult to do, because of the lack of control in Windows over shutting down programs before the host OS shuts down.
In 15 years that I use VBox, from my perspective, this is the most recurring issue which is still not fixed and constantly forcing windows users to use Hyper-V.
How hard can something be that even Notepad implements correctly?
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: Shutting down VM gracefully
That worked in Win98. Not so much in Win10. This is not single core days when the shutdown function will wait forever.TMD wrote:Hi, I was under the impression that the Windows host will post a WM_QUERYENDSESSION
If you think a fix is easy then by all means contribute a code patch.
If this is enough to force some people to use Hyper-v then that's fine too. It's not like that would cost us anything.