When the host is being shut down an automatic Save State of a headless VM is triggered. Is it possible to change it to automatic shutdown instead?

General VB Question

I couldn't find any solution. The only hint was to set "VBoxManage setextradata VM-name GUI/DefaultCloseAction Shutdown", but that apparently doesn't affect headless VMs.

When I run QEMU VM on Linux and the host is shutting down it waits for all the VMs to shut down. I would like to achieve the same behavior with VirtualBox.


VirtualBox Version: Version 6.1.30 r148432 (Qt5.6.2)

Host OS: Win10 Pro 21H2

Guest OS: Debian GNU/Linux 11 (bullseye)

Host Extensions Installed: Yes

Guest Additions Installed: No

Hardware virtualization enabled: Yes

Posted Jun 15, 2022, 6:16 AM UTC

27
azra1l•

The problem with a script solution is that windows will likely terminate the script process and the VM process if that's still active for some reason, before the script can finish.

I am struggling to find a solution for ages. There is an app that's supposed to do exactly this, can't remember the name but should be easy to find via Google. Yet it doesn't work at all for me.

Edit: VBoxHeadlessTray was it I think.

But, maybe VBoxVmService is a much better solution. It will run your virtual machine as a service that can be started/stopped with windows start/shutdown, that way windows should automatically handle everything for you and wait for the VM to gracefully shutdown. The downside was that i needed admin rights to access VM control, which kind of killed it for me. Will have to take another look at this.

3
Certain_CombinationOP•

Thanks for the tip. VBoxVmService looks interesting.

1
officer_terrell•

Not a perfect solution but just until you get a better answer

You could make a shell script to use instead of shutdown that tells VirtualBox to close the vm, then shuts down your PC? I don't think that would wait for it to fully shut down though so maybe add a sleep command

Edit: thought you were on Linux. Same thing applies though, just make a batch script instead

2
Certain_CombinationOP•

Thank you for your reply. There appears to be a way how to run a script on Windows shutdown.

If VirtualBox wouldn't offer any more direct solution, this could solve it.

Until now, I was shutting it down manually, but sometimes I forgot about it and VM session was saved instead of shutting down.

2
[deleted]•

[deleted]

1
AlzHeimer1963•

I have not tried this myself...

I would assume, that VB will reuse the latest option used when closing the guest window by itself. So close manualy this window, select "send the shutdown signal", click OK.

Next time you close the window this same option should be the default. And so this might be the default, when abutting down the host.

1
Certain_CombinationOP•

I'm running a headless VM so there is no window. That's also the reason why I've been forgetting to shut it down before the host shutdown.

1
zfsbest•

Try putting a yellow sticky note on the monitor as a reminder ;-)

1