Sunday 18 May 2014

Getting rid of the input lag in Hyper-V VMs

Hyper-V is supposedly "native" on Windows. Unfortunately, using the default Hyper-V client to connect to a VM may result in laggish keyboard and mouse input.

While this lag doesn't seem to affect Windows Server and more recent Windows OSes, it is particularly annoying on older and non-windoes OSes like Windows XP and Linux. I mean, the whole point of using Hyper-V is because better performance is expected from a "native" solution. A workaround is to connect to your VM using remote desktop. There are two requirements to this: a working (internal) network connection, and support for Remote Desktop Protocol (RDP) on the guest OS.

Setting up a connection: While using an virtual internal switch (virtual switch manager in the Hyper-V manager) may be sufficient, sometimes it is desirable to share the host OS internet with the guest OS as well. The default solution would then be to use an virtual external switch. Unfortunately this doesn't work (some explanation?) when using a wireless adapter and connecting to a public network on the host. To work around this, use an virtual internal switch instead, and share the wireless adapter (adapter settings -> sharing -> allow other network users to connect through this computer's internet connection, and set the home network to the internal switch).

RDP support: Windows OSes come with remote desktop support, although it may be disabled by default. To enable it, open the computer properties page and modify remote settings on the left pane. Firewall rules may need to be modified to allow remote connections. On Linux distros, the xrdp package is available in most repositories. Here is an excellent guide to use and install the package on Ubuntu, summarized below:

sudo apt-get install xrdp
sudo apt-get install xfce4
sudo echo xfce4-session > ~./xsession
sudo vi /etc/xrdp/xrdp.ini and replace the line port=-1 with port=ask-1
sudo service xrdp restart


The command hostname -I can be used to get the IP address of the guest Linux OS.

Modify the display resolution: If setting up networking and remote desktop is too much of a hassle, another way is to simply reduce the display resolution of the guest OS. This may or may not improve the native Hyper-V client experience. Changing the resolution for Linux requires changing the configuration in the grub config file (/etc/default/grub, SET GRUB_CMDLINE_DEFAULT="...blabla... video=hyperv_fb:800x600"). I believe there are some Linux drivers out there that improve the rendering, but I haven't tried those yet.

2 comments: