when windows host shuts down or logoff give user options to

Here you can provide suggestions on how to improve the product, website, etc.
Post Reply
gg99
Posts: 44
Joined: 19. Sep 2011, 08:27
Primary OS: MS Windows 8
VBox Version: PUEL
Guest OSses: vista, w7, w8.1, w8.1 embedded pro, xp(being phased out)

when windows host shuts down or logoff give user options to

Post by gg99 »

somehow allow the user option to save vm states for all or only selected vm when the host start to shutdown or log off.
Currently the Vb main interface and services shut down before prompting user to save vm. However it's too late for user to save as the service is no longer available.
http://www.virtualbox.org/

Failed to save the state of the virtual machine .

Callee RC: RPC_S_SERVER_UNAVAILABLE 0x800706BA (0x800706BA)
Failed to open a session for the virtual machine xpho2 - gTalk, visual studio 2010.

The VM session was aborted.

Result Code: E_FAIL (0x80004005)
Component: SessionMachine
Interface: ISession {12f4dcdb-12b2-4ec1-b7cd-ddd9f6c5bf4d}

I'm using VB 4.3.15r91406 on windows 8.1 pro x64 running on core 2 quad
Last edited by gg99 on 15. Jan 2014, 21:32, edited 1 time in total.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: when windows host shuts down or logoff give user options

Post by scottgus1 »

I don't think this is possible because of the way Windows shuts down. Windows doesn't always peacefully ask its running programs if they're ready to shut down yet.
I've tried using scripts in the logoff Group Policy to do save-states on running VMs and I still have windows forcefully shut down the guests before the logooff save-state script gets a chance to run.

Good ways to make sure guests don't get killed during a Windows shutdown on usual hosts, like your laptop you carry with you everywhere, etc. are:
Get into the habit of shutting down all programs before shutting down the host manually.
Remove all timed shutdowns, such as fully automatic Windows Automatic Updates - make it download & notify instead (Edit: I don't do this anymore, I use a script - see down lower).

For hosts that run mission-critical guests, like the office server:
Remove the Shutdown and Restart selections from the Start menu, so a shutdown has to be run from shutdown.exe instead, and provide scripts that check if the guests are running before running shutdown.exe.
Run guests from a service, using this setup: viewtopic.php?f=6&t=4762 No log-in required, but all guests have to be accessed via remote-in software, either Virtualbox's RDP or something in-guest, like MSRDP, LogMeIn, UltraVNC, etc. in the guest.
Last edited by scottgus1 on 20. Nov 2014, 20:53, edited 1 time in total.
gg99
Posts: 44
Joined: 19. Sep 2011, 08:27
Primary OS: MS Windows 8
VBox Version: PUEL
Guest OSses: vista, w7, w8.1, w8.1 embedded pro, xp(being phased out)

Re: when windows host shuts down or logoff give user options

Post by gg99 »

I wonder how notepad does it. it always hangs in there until click one of the options: save, don't save, cancel
or until I force shut down

Btw some .net programmer friend told me there is something in the framework they can use to subscribe to shutdown notification. I wouldn't be surprised the Microsoft native windows c++ interface could do the same
Last edited by gg99 on 16. Jan 2014, 20:40, edited 1 time in total.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: when windows host shuts down or logoff give user options

Post by scottgus1 »

There's a thought. If Virtualbox could do what Notepad does to make the system wait, that would accomplish your suggestion. Would be very useful, too.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: when windows host shuts down or logoff give user options

Post by scottgus1 »

This post: http://social.msdn.microsoft.com/Forums ... arpgeneral says that Notepad makes a modal dialog asking to save or not when a shutdown occurs while the notepad file is unsaved, thus preventing shutdown.
Perhaps this could be a clue how to make the host sit and wait when a guest is running, at least for Windows hosts? Maybe Virtualbox marks its guests "dirty" like unsaved Notepad documents do, and pops up the "Close guest" window modally, so the host thinks they're files that need to be saved and won't shut down until the modal dialog is dealt with?
No idea how to do this myself, but it would be helpful. I've killed a few guests accidentally with unexpected shutdowns.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: when windows host shuts down or logoff give user options

Post by noteirak »

The problem is not in the user interface, but in the service & kernel modules running in the background. Even if the GUI was to block, if the actual core of Virtualbox is shutdown by Windows, it doesn't matter...
There is no way to prevent Windows to shutdown a service at shutdown AFAIK.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
RBerteig
Posts: 1
Joined: 20. Nov 2014, 01:17

Re: when windows host shuts down or logoff give user options

Post by RBerteig »

I don't know enough about the overall structure of VirtualBox to guide the details of fixing this, but the constant refrain of "don't do automatic updates" runs counter to current best practices for individual PC owners. Windows out of the box is set to automatically download and install updates. This is generally a good thing. Applications running on Windows must accept the possibility of an unattended shutdown where just prompting the user is not sufficient. To do otherwise is to be a bad citizen of the Windows ecosystem.

Windows services get informed of the impending shutdown and are given a chance to clean up state. If the difficulty is that the service has already exited before the GUI heard about the shutdown, then the solution is to take appropriate action in the service.

For an unattended reboot, the safest response is for VB to Save the Machine State for every open machine. That should be fast and low risk, and generally follow the principle of Least Surprise.
Darwood
Posts: 7
Joined: 27. Apr 2011, 16:53
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows XP and Windows 7

Re: when windows host shuts down or logoff give user options

Post by Darwood »

Agreed. The Vb service should ideally save machine state when receiving a shutdown signal from Windows. In the absence of such I would recommend disabling automatic restart by Windows Updates. I can't post the URLs for how to do this here as I don't have the permissions on this forum yet. GIYF
Darwood
Posts: 7
Joined: 27. Apr 2011, 16:53
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows XP and Windows 7

Re: when windows host shuts down or logoff give user options

Post by Darwood »

scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: when windows host shuts down or logoff give user options

Post by scottgus1 »

Update to the concept of turning off windows Updates:
I have since learned how to download and install Windows Updates via VBS script and batch files which can shut down or save state the guests before running the Windows Update script. I use this setup now and my Windows Updates get installed properly and my guests are all shut down beforehand, so a host reboot does no damage.
See viewtopic.php?f=6&t=64741
gg99
Posts: 44
Joined: 19. Sep 2011, 08:27
Primary OS: MS Windows 8
VBox Version: PUEL
Guest OSses: vista, w7, w8.1, w8.1 embedded pro, xp(being phased out)

Re: when windows host shuts down or logoff give user options to

Post by gg99 »

using windows pro as host give me reboot option after auto install.
windows no long reboot automatically and usual have 1 day or more to reboot although I tend to reboot asap after saving all vm and shutdown virtualbox
Post Reply