Shutting down VM gracefully

Discussions related to using VirtualBox on Windows hosts.

Shutting down VM gracefully

Postby TMD » 26. Feb 2016, 18:16

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
TMD
 
Posts: 2
Joined: 26. Feb 2016, 18:11

Re: Shutting down VM gracefully

Postby scottgus1 » 26. Feb 2016, 22:32

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.
Last edited by scottgus1 on 29. Feb 2016, 15:32, edited 1 time in total.
Human government is like that crazy uncle who hides a quarter in his fist behind his back, then asks you to guess which fist the quarter is in...
No matter which side you choose, Left or Right, both Sides are empty.
scottgus1
Volunteer
 
Posts: 4502
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Win7

Re: Shutting down VM gracefully

Postby TMD » 29. Feb 2016, 14:04

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?
TMD
 
Posts: 2
Joined: 26. Feb 2016, 18:11

Re: Shutting down VM gracefully

Postby scottgus1 » 29. Feb 2016, 14:05

My experience is as I posted. I've never heard of the VM_QUERYSESSION thing, try it and post back what happened.
Human government is like that crazy uncle who hides a quarter in his fist behind his back, then asks you to guess which fist the quarter is in...
No matter which side you choose, Left or Right, both Sides are empty.
scottgus1
Volunteer
 
Posts: 4502
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Win7

Re: Shutting down VM gracefully

Postby davor » 12. Aug 2019, 12:49

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.


Seriously? In 2019.

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?
davor
 
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

Postby mpack » 12. Aug 2019, 13:46

TMD wrote:Hi, I was under the impression that the Windows host will post a WM_QUERYENDSESSION

That worked in Win98. Not so much in Win10. This is not single core days when the shutdown function will wait forever.

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.
mpack
Site Moderator
 
Posts: 29846
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP


Return to VirtualBox on Windows Hosts

Who is online

Users browsing this forum: No registered users and 39 guests