Remote KVM VMs, bridged Networking, and RH Virtual Machine Manager

2009-07-10 by Administrator, tagged as linux, software

Remember the good ole times when there was only one single virtualization solution to chose from? Well, today there is VMWare ESX, Microsoft Hyper-V, Citrix XenServer, Sun xVm/VirtualBox, and lot’s of others with different approaches. And the craziest part is their giving it all away for free (or parts of it). It’s almost impossible to check all of them out.
I decided to follow the Red Hat way and check out KVM because to me it seems as the only really free solution (maybe Xen) that takes the hypervisor approach and allows virtualization w/o the need to make changes to the guest OS.

One thing first: Using KVM still requires a lot of commandline tasks, especially when used in a client/server scenario. Not everything can be configured inside the available GUIs. But hey, there is SSH and you may connect to the remote machine this way anytime. Still, the client GUI is used to do the standard tasks: create, start, stop, monitor virtual machines, networks, and storage locations.
In fact, this article is about the commandline part

So here is my setup:

I use SSH as a protocol between the Virtual Machine Manager and the remote host mainly because it’s the easiest way to get a quick solution running.

Besides the current limitations of the Virtual Machine Manager (crashes every once in a while) and libvirt (currently not able to pass -std-vga or -vga option to KVM although a patch is available) one main problem I had was to configure bridged networking so that guests could use the host interface w/o NAT. The workaround I use is as follows:

  1. Create a VM with a supported network type inside Virtual Machine Manager
  2. Connect to the host via SSH and navigate to /etc/libvirt/qemu/machinename.xml
  3. Look for the <interface> section. I change it to look as this:
    <interface type='bridge'>
    <source bridge='br0'>
    </interface>
    

This requires you to have a bridge interface up and running on the host. Mine is called “br0″ as you can see. Setting up bridge interfaces differs in the distributions. A good place to start is libvirt’s Wiki: Netowrking, the Qemu Wiki, and the KVM FAQ about guest networking

Last thing is to restart libvirtd (Debian system)

/etc/init.d/libivirt-bin reload

Ah right, there is this directory /etc/libvirt/qemu/networks. I tried to create a network here that then would probably be usable inside Virtual Machine Manager but I couldn’t get this to work w/o too much code manipulation. Problem is that the interface type in the machine.xml file would be “network” and not “bridge“. Furthermore, a manipulated network.xml file does not show up inside VM Manager. Whenever you manipulate inside libvirt’s XML files you may end up with your devices, VMs, networks not showing up inside VMM anymore.

And if you’re having problems getting a host only network to run I suggest you check out the mcast option. Instead of an interface like the one above you use this:

<interface tpye='mcast'>
  <source address='230.0.0.1' port='12345'/>
</interface>

If you need separated “host-only” networks simply change the multicast IP or the port. But you probably only made a mistake with the IP address anyway (Darn! But it might be heplful one day).

So here is a list of tasks I currently still do on the commandline:

  • Create bridge interfaces (obviously)
  • Create differential / immutable disks
  • Copy/clone VM settings
  • hmmm…. I’ll think of some more