Virtual services – machines, kind of – have been available since the 1960’s. At first, they were only really available on mainframes. It was a very useful feature, but the dinosaurs of computing, too, became extinct (more or less – the ones that are left are very tenacious), and with it went mass adoption of virtual computing.

Until, that is, personal computers became powerful enough to rediscover this old trick, and invent a few more.

What is a virtual machine? Well, it’s a piece of software which looks to the end user – you, or another piece of software – like a real machine. It’s not created out of nothing, it’s backed by real hardware, but it’s also not entirely a trick.

Machines like HP’s ‘UX’ unix servers offer both nPar and vPar flavours – npar is hp-speak for real partitioning. It means taking a larger machine and almost physically slicing it up. The machines that result are actually separated, electrically. vpar machines, on the other hand, are virtual partitioned. It’s a specialized type of virtualization, however, which cannot be matched by standard PC’s, as it takes special service processors and extra bells and whistles which just don’t exist on PC-compatibles.

For the rest of us, we have to use either type 1 hypervisors, or type 2… or hybrid ‘type 1.5′ hypervisors.

A hypervisor is the tiny little special program which manages the sharing of resources between virtual machines. They’re often called virtual machine monitors, or VMM’s for short.

Type 1 VMM’s are often called ‘bare metal’. A Type 1 hypervisor machine is no good for anything else than running virtual machines, as that’s all it does, and it takes over the entire physical machine to do it. The plus point, here, is that that is all it’s doing, meaning the virtual machines are faster, and have more resources to play with.

Type 2 VMM’s are called ‘hosted’. Hosted VMM’s are programs which run much the same as any other program does in a normal computer. You may have heard of them – vmware and virtualbox are two I’ve mentioned before. They let an otherwise ‘normal’ computer also run virtual machines as well as doing what it normally does. The catch is that with resources in use for other programs like word processors and browsers, there’s less for virtual machines to play with.

Type 1.5 VMM’s aren’t really a class. What they are is the marriage between operating system kernels (the little programs that run in the heart of user-servicing operating systems, making them go) and the offering of virtual services. When the VMM is tied into the kernel in this way, the virtual host can offer better access to the services needed by virtual guests. It means a normal operating system has certain extra bells and whistles added on specifically for running virtual machines. In some cases, this means that virtual guests can run almost as fast (if not faster under certain conditions) than under a bare metal hypervisor.

I’ve mostly used linux, and the two most common hypervisors on Linux are xen and kvm.

Xen is a type 1. If you’ve tried running xen on your linux box, then you should know that linux was ported to xen, and not the other way around. That’s why when you’re running Xen, weird things happen – memory disappears, certain programs will chirp about permissions, perhaps, that sort of thing.

KVM is a type 1.5. KVM stands for Kernel Virtual Machine, and is a very small driver in the linux kernel itself that presents an API for virtual machines to attach to when requesting services like disk, cpu time, memory access or network packets. The 1.5 cleverness means that instead of pretending there’s a real disk, KVM can tell the virtual machine hey, just hand me that file you want to save, I’ll handle it. or instead of pretending there’s a real network card, it can tell the virtual machine yeah, just gimme that network packet, I’ll handle it.

This saves a lot of time over going through the rigmarole of fiddling with the information that the host can already deal with, and this is where a type 1.5 can be faster even than a type 1 – though most type 1 hypervisors like xen and vmware offer the same tricks.

The catch is that the guest operating systems have to know they are running in a virtual machine, which isn’t always possible. The history of virtual machines has always been one of flexibility over speed.

For a fast VM, you either need a real box doing nothing else (which renders the whole exercise pointless), a real box with special smarts (which is expensive, unless or until ‘normal’ pc’s fully support such advanced features, which will be on the twelfth of never), or you need a special VM.

Still, with modern operating systems, modifying them so they can understand they’re a virtual machine is relatively simple; it’s just a case of the right drivers.

The power of such technology means that I ran four virtual machines, each for a different purpose, on a standard computer that most gamers wouldn’t take a second look at… and thanks to another trick, inside one of those virtual machines I ran another three…

Advertisements

2 responses »

  1. fulcronz says:

    I havn’t played both products, but I think KVM’s concept is better than Xen. Since VMs resides in a matured Linux kernel, the Linux kernel can aid in many administration tasks i.e. better control and maintenance. Also, it can save a lot of time not having to context switching from host’s user mode -> host’s kernel mode. But, that is just my opinion.

    “The catch is that the guest operating systems have to know they are running in a virtual machine, which isn’t always possible. ”
    I think the one you talked about is Paravirtualization, forcing all VMs under a hypervisor to speak through same API. For this approach, OSs require modification. On the other hand, full virtualization (or HVM in Xen) does not require any change.

    4 x 3 = 12 VMs. Cool! : )

    • dmayoss says:

      Xen by default requires paravirtualization (since Linux was ported to xen, and not the other way around), but the advantage of this is it will run without specific virtualization support in hardware. KVM on the other hand, by default, requires hardware virtualization. You can run KVM without hardware virtualization, but it’s a pig. In that case, stick to a solid type-2 like virtualbox or vmware.

      The thing is, hardware virtualization is slllllooooowwwwww, and software virtualization is eeevveennn sllllooowwwweeeerrrrrr. Paravirtualization, on the other hand, can speed everything up a huge degree (I have numbers, somewhere, it’s an order of magnitude).

      Xen and KVM both (along with practically every single other hypervisor ever on x86 machines) all do paravirtualization as well, because why the heck not – at best, it’s a case of installing drivers. In practice, all modern computer support hardware virtualization, even if not everyone is taking advantage of it.

      KVM’s got my vote for smaller (less than a hundred) virtual machines on Xen because of its simplicity. Xen, however, is allegedly better at higher loads. I don’t have numbers to check that, however, so take it with a grain of salt…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s