I've recently transferred my VM from an old Win10 laptop to a new Win11 one and encountered very annoying issue: If I close my laptop, making it go to sleep, and when wake it up after some time, my guest VM (Rocky Linux 8) resets its state to the login screen (as if after reboot). In the logs I see that the session has been killed via watchdog: systemd-logind.service: Watchdog timeout (limit 3min)!
(and several others like that).
One suspicious thing I've noticed in my VBox logs is that it doesn't seem to actually suspend when my laptop goes to sleep. At least I haven't found the corresponding message. However, there is a suspend event coinciding with the guest vm log about watchdog/crash:
<lots of similar events>
120:25:23.134650 TM: Giving up catch-up attempt at a 60 001 385 790 ns lag; new total: 168 754 705 406 043 ns
120:33:47.416772 TM: Giving up catch-up attempt at a 60 005 808 341 ns lag; new total: 168 814 711 214 384 ns
120:54:28.968325 TM: Giving up catch-up attempt at a 60 005 322 909 ns lag; new total: 168 874 716 537 293 ns
121:06:30.694374 VMMDev: vmmDevHeartbeatFlatlinedTimer: Guest seems to be unresponsive. Last heartbeat received 5 seconds ago
121:06:30.782830 VMMDev: GuestHeartBeat: Guest is alive (gone 5 212 364 421 ns)
127:35:15.487887 TM: Giving up catch-up attempt at a 23 374 472 159 396 ns lag; new total: 192 249 188 696 689 ns
127:35:15.487905 VMMDev: vmmDevHeartbeatFlatlinedTimer: Guest seems to be unresponsive. Last heartbeat received 23319 seconds ago
127:35:15.504476 TMR3UtcNow: nsNow=1 700 525 178 297 266 738 nsPrev=1 700 501 801 965 273 179 -> cNsDelta=23 376 331 993 559 (offLag=5 100 562 offVirtualSync=192 249 193 797 251 offVirtualSyncGivenUp=192 249 188 696 689, NowAgain=1 700 525 178 302 367 300)
127:35:15.505000 VMMDev: Guest Log: 00:06:17.742079 timesync vgsvcTimeSyncWorker: Radical host time change: 23 376 332 000 000ns (HostNow=1 700 525 178 297 000 000 ns HostLast=1 700 501 801 965 000 000 ns)
127:35:15.505035 VMMDev: Guest Log: 00:06:17.742589 timesync vgsvcTimeSyncWorker: Radical guest time change: 23 321 082 671 000ns (GuestNow=1 700 525 177 742 065 000 ns GuestLast=1 700 501 856 659 394 000 ns fSetTimeLastLoop=false)
127:35:15.656748 VMMDev: GuestHeartBeat: Guest is alive (gone 23 319 851 039 698 ns)
127:35:17.548800 Pausing VM execution, reason 'HostSuspend'
127:35:17.548841 Changing the VM state from 'RUNNING' to 'SUSPENDING'
127:35:17.555491 AIOMgr: Endpoint for file '***.vdi' (flags 000c0781) created successfully
127:35:17.561655 AIOMgr: Endpoint for file '***.vdi' (flags 000c0781) created successfully
127:35:17.563252 PDMR3Suspend: 14 370 022 ns run time
127:35:17.563261 Changing the VM state from 'SUSPENDING' to 'SUSPENDED'
127:35:17.563269 Console: Machine state changed to 'Paused'
I've generated a sleepstudy report in windows and it shows that at this exact point in time windows changed its state from sleep to hibernate. So it seems like VM went to sleep but not really, then woke up and died on a watchdog timer when PC was switching from sleep to hibernate (likely because it needs to briefly wake up during this) and then was properly suspended.
Manually pausing the VM before initiating sleep seems to work, but it's really annoying (I can try forcing hibernate instead of sleep, but I'd rather avoid that).
Is there a way to fix that? Is it possible to either disable watchdog in guest OS or make VBox detect sleep properly (or make windows automatically pause vm before sleep)?