Why is the wrong time displayed on my virtual machine?

Here is the scenario:

You have a bunch of server virtual machines that are merrily running somewhere in your environment.  Normally you do not interact with them, but once in a while you need to login to one of them and do something.  When this happens – you open up Hyper-V Manager and connect to the virtual machine.  The virtual machine connection opens and you see:

image

Only, the time and day displayed is completely wrong!  But, as soon as you click on the virtual machine (or press a key) the time and date *pop* to the right time.  What is happening here?

The answer is a little bit odd.  What is actually happening is that Windows (inside the virtual machine) is turning off its monitor to “save power”.  The result is that you get a stale display on the virtual machine until you provide keyboard or mouse input.

This is actually a new behavior as of Hyper-V in Windows Server 2012 / Windows 8.  It is an unintended side effect of other work that we did on our video driver.  The short version of which is: we updated our virtual machine video driver significantly in Windows Server 2012 / Windows 8 in order to improve its efficiency, and accidentally enabled power management of the virtual video device in the process.

When we first realized that this was happening – we had a lengthy discussion about what to do.  Options suggested were:

  1. Hack the virtual video driver to explicitly not support power management.  This would have been a pretty gross thing to do (from a code perspective) so we ruled that option out quickly.
  2. Display a black screen when the guest OS slept the monitor (which is what physical computers do).  With this option we were afraid that users would think that the guest OS had crashed (or something similar).
  3. Grey out the last screen from the guest OS.  Unfortunately this is what we already do when you pause a virtual machine, so we were worried that there would be confusion about this.
  4. Put up a fluorescent pink box with the words “Virtual monitor in sleep mode!” written across it (this idea probably received far more discussion than it deserved).
  5. Just leave the last image displayed up.

To be honest, we were not super happy with any of these ideas – and ended up going with the last option.  If this behavior bothers you, you can actually control it.  Just edit the power management plan inside the virtual machine and tell Windows to not turn the display off:

image

I can guarantee that this will not waste any power :-)

Cheers,
Ben