This is an easy way to sleep and wake Windows VM's from sleep:


craigr

Recommended Posts

I know many people scoff at sleeping a VM, but I really want to put my Windows 10 VM's to sleep because they are constantly doing things in the background and utilizing a lot of CPU.  It costs me about 50 watts to not sleep the VM and to me that is just a waste.  The trouble has been how to wake them up easily without using another device.

 

All you have to do to make the mouse and keyboard wake Windows from sleep is use evdev to pass them through instead of the Windows template.  The easiest way to learn how to do this is to watch and mostly follow Spaceinvader's new tutorial on evdev:

 

 

I'm sure he will fix it, but please note that Spaceinvader doesn't quite have the syntax correct in the qemu.conf.  The correct syntax is in my post just below his in the linked thread.  Once you get it right, your mouse and keyboard will be able to wake your Windows VM from sleep 🤩  Also, don't forget to turn "Link State Power Management" back on in the Advanced settings of the Windows 10 Power Options, otherwise your computer may just hard shutdown instead of sleep.

 

I am finally happy!

 

Best regards,

craigr

Edited by craigr
  • Like 2
Link to comment
18 minutes ago, jonathanm said:

Quick question. What happens when the array is cleanly powered off, like for instance if your UPS commands a powerdown, if the VM is asleep?

No idea.  I just did this today.

 

I will have to test this though.  I've got my UPS set to shutdown unRAID if I lose power for 10 seconds (it's not a big UPS and I have 22 drives).  I don't know if unRAID would give Windows the default 60 seconds to shutdown gracefully or not.  My guess is that it would try and shutdown windows gracefully, but I think that could be a problem because I don't want my UPS to have to work for an extra 60 seconds shutting down Windows.  I also doubt Windows could wake from sleep and then shutdown in less than 60 seconds... than again, unRAID may not even know to wake a sleeping VM to shut it down gracefully 😬

 

I'd actually rather unRAID just yank Windows with a hard shutdown. 

 

The next time I have to power down the server I will pull the power on the UPS with Windows asleep and see what happens under controlled conditions.  I'll report back with results.  I know I am going to be doing some hardware changes next Tuesday or Wednesday so I'll find out then or before.

 

Kind regards,

craigr

Link to comment
  • 3 months later...
On 12/17/2020 at 5:09 AM, methanoid said:

Nice info OP.   Not running unRAID right now (various reasons) but if you sleep your unRAID server, what happens to VMs that may be running or sleeping when you Resume your unRAID server? I know, not 100% related but it is related sorta.... 

I don’t ever sleep the server, only the Windows 10 VM running on it.

 

craigr

Link to comment
  • 1 month later...

I can answer this as I use a Windows 10 and BigSur VM :

 

I can put to sleep the Windows Vm and put to sleep  Unraid with no problem : I wake Unraid, then the W10 wm, and all work fine. Everytime. All bueno.

 

For my Bigsur VM (and for Catalina before it), it's another story and it's the ONLY thing that I can't solve on my Unraid system (well beside network troubles under BigSur..). Meaning the same operation as with the W10 VM works... sometimes. And I can't figure out why as the problem is not happening everytime. But that would be the subject of another thread 🤫

Edited by bjornatic
Link to comment
1 minute ago, bjornatic said:

I can answer this as I use a Windows 10 and BigSur VM :

 

I can put to sleep the Windows Vm and put to sleep  Unraid with no problem : I wake Unraid, then the W10 wm, and all work fine. Everytime. All bueno.

 

For my Bigsur VM (and for Catalina before it), it's another story and it's the ONLY thing that I can't solve on my Unraid system (well beside network troubles under BigSur..). Meaning the same operation as with the W10 VM works... sometimes. And I can't figure out why as the problem is not happening everytime. But that would be the subject of another thread 🤫

 

So Sleeping unRAID does NOT sleep the VM first ?   Seems to me that would be cleanest way to do it....

Link to comment

I do not now. I think it would be possible by adding the correct command in the sleep plugin (as sleep is not officially supported by Unraid).

 

And it may be a clean way, but not the logical way in my opinion. The VM has to decide by itself (or by manual command) to be put to sleep. And THEN, the Unraid server, "seeing" that everyone is sleeping, puts himself to sleep. And that's how I have it working.

 

The problem I have is on wake up ^^ (for MacOS only, though).

 

EDIT : and by "sleep" I mean hibernate... just to be clear. And It this state I can even restart the server and the W10 VM will resume OK.

 

EDIT again :  I looked around and noticed the option "Enable Virtual BMC :" in the VM manager. And I think that could enable what you suggested.

Edited by bjornatic
Link to comment
  • 8 months later...
  • 1 year later...
On 10/10/2021 at 1:37 AM, Linguafoeda said:

How do you enable a Windows VM to go to sleep if it's not being used? I don't want my Windows VM hammering my CPU / HDDs if not being used and i forgot to manually shut down the VM. Is there a way to do this?

All you need do is sleep it like a regular Windows install.  Just go into Windows power settings and set the number of minutes until sleep.

Link to comment
  • 11 months later...
On 1/3/2023 at 3:20 PM, craigr said:

All you need do is sleep it like a regular Windows install.  Just go into Windows power settings and set the number of minutes until sleep.

 

I don't have any of these options - just "sign out/shutdown/restart" in the ctrl+X menu. There is no option in settings either - just an option to "turn off display". I'm running Windows 11 Pro 23H2.

 

I also am unable to hibernate the VM itself - it gives error "Domain 'Windows' could not be suspended. internal unable to execute QEMU agent command 'guest-suspend-disk': Guest agent command failed, error was 'suspend-to-disk not supported by OS'."

Edited by Linguafoeda
Link to comment
4 hours ago, Linguafoeda said:

 

I don't have any of these options - just "sign out/shutdown/restart" in the ctrl+X menu. There is no option in settings either - just an option to "turn off display". I'm running Windows 11 Pro 23H2.

 

I also am unable to hibernate the VM itself - it gives error "Domain 'Windows' could not be suspended. internal unable to execute QEMU agent command 'guest-suspend-disk': Guest agent command failed, error was 'suspend-to-disk not supported by OS'."

Have you installed the guest agent in the VM? It is on the Virtio CD.

Link to comment
5 hours ago, Linguafoeda said:

@SimonF i installed the virtio-win-guest-tools but am still missing sleep option. I just opened up the ISO from the shared cache drive which mounted it locally within windows and installed all the driver options available (0.1.240). I restarted and also tried once more to install and hit the "repair" option for good measure.

Not sure if you need it but I have seen posts stating having hyper-v enabled may cause this issue. Try with hyper-v set to No

 

image.png

Link to comment
2 hours ago, SimonF said:

Not sure if you need it but I have seen posts stating having hyper-v enabled may cause this issue. Try with hyper-v set to No

 

image.png

 

Wouldn't this hurt vm performance which is what I'm trying to optimize (faster VM, less CPU usage, ability to save power/free up CPU & RAM by sleeping VM if idling for more than 30-60mins etc)

 

Or am I confusing what hyper-V does and how to interacts with the changes I did to my VM XML from m00nman's optimization guide

Link to comment
  • 2 months later...
On 12/7/2023 at 4:22 AM, Linguafoeda said:

 

Wouldn't this hurt vm performance which is what I'm trying to optimize (faster VM, less CPU usage, ability to save power/free up CPU & RAM by sleeping VM if idling for more than 30-60mins etc)

 

Or am I confusing what hyper-V does and how to interacts with the changes I did to my VM XML from m00nman's optimization guide

 

bump - curious on if disabling hyper-v altering performance. i had finally tuned my windows VM for high performance (especially switching to microsoft RDP for access, installing intel-gvt for virtualized iGPU acceleration and following m00nman's perf thread. I did make a bunch of his XML edits which reference hyper-V so i don't want to then toggle the hyper-v in the non-XML edit of the VM which may cause issues with what i setup via @m00nman

Edited by Linguafoeda
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.