Tuesday, 20 December 2016

Windows 10, Virtual Machine Manager, and KVM

I really, really like the fact that Microsoft has embraced Linux in the form of releasing Ubuntu on Windows. To me, it's probably the first Linux on the desktop solution that was as good as using Linux itself without having to worry about using virtualization for my Windows applications and games. However, it's not exactly a true Linux kernel running behind the scenes and there are other things that will not simply work.

For one, out of the box you cannot use any X11 applications without an X server installed and some extra configuration. However, it is relatively painless to get this up and running and just as easy to get Virtual Machine Manager working as well. If you already have access to the KVM tools on the VM host, you will be able to use it remotely using an SSH connection from the Windows computer.

This is what we're going to need to install:

  • OpenSSH Client
  • Virtual Machine Manager
  • Python Spice GTK module

Assuming that you have already gone ahead and updated and configured Windows 10 to use the feature, you'll want to use Xming to act as your X server. There are other X servers you can consider, including MobaXterm and XvxSrv, but I prefer Xming due to its simplicity and the fact that it sits in the tray once you launch it.

Running XLaunch after installing Xming brings up this screen. Personally, I prefer having it set to multiple windows but of course you'll want to set this to your liking. You can leave the rest as defaults and it should be fine.

With the X Server out of the way, we'll want to configure Bash on Windows to automatically connect to the X server. This can be done by editing the .bashrc file in your home directory with the following at the end:

export DISPLAY=:0

Close and reopen Bash on Windows and it is ready to go. You can test out whether or not it works by installing something like GEdit or Xterm to see if it launches.

We do however have to enable D-Bus for use as Virtual Machine Manager depends on it. We can do this real quickly by performing the following command:

sudo sed -i 's$<listen>.*</listen>$<listen>tcp:host=localhost,port=0</listen>$'\ 
/etc/dbus-1/session.conf

Once this is done we can now proceed to install VMM.

sudo apt-get install python-spice-client-gtk virt-manager openssh-client
This shouldn't take too long and once it's done all we have to do is type the following command:

virt-manager

And here we are!


It should be noted that you cannot create virtual machines on your Windows 10 computer using this method--you're better off using HyperV if you want to go down this road. However, it is at this point that we can connect to a KVM host using SSH.

You'll want to configure OpenSSH within Bash on Windows first with key-based authentication to proceed but once that is done it's relatively simple to configure the system. Under the File menu, you'll see Add Connection which will ask you for some details:


You should see your VMs populate now:



And you can even use them as a console:


Enjoy.

No comments:

Post a Comment