Linux Virtual Machine Stack

Linux Virtual Machine Stack

For a long time, I used VirtualBox. This was mainly in my Windows days. Though, I have seen many Linux users actually use this, for some reason. In this article I would like present a different option that is very native to Linux and is enterprise quality. You can use this setup to replace MS Hyper-V and VMWare, depending on your usage requirements.

KVM (Kernel-based Virtual Machine)

The Kernel-based Virtual Machine is in the Linux Kernel and it supplies the ability for virtual machines to have their own individual virtualized hardware. Some of the main functionality of this layer is CPU and memory communication. This is the lowest level of the virtual stack we are discussing here. This has been in the kernel ever since version 2.6.20, back in 2007. Simply make sure your Intel or AMD hardware has the virtualization feature enabled in the BIOS.

QEMU (Quick EMUlator)

The next layer up is quite power in itself. QEMU has the ability to be a full virtual machine (emulation) for an entire operating system on a lot of different architectures or even run a single program for a different architecture (still Linux). Our main interest in this stack is that it can essentially plug into KVM and run a virtual machine at near native performance (virtualization).

When using QEMU with KVM, the CPU usage is redirected to KVM. The memory is only partly handed-off and QEMU handles the higher-level things like the hard disk, peripherals and network activity. This shared responsibility of the resources leads to a very efficient virtual machine stack. This is known as hardware-assisted virtualization.

libvirt (virtualization platform toolkit)

This layer provides a consistent set of APIs on top of QEMU/KVM, along with other options like Xen, VMWare ESX and others. You can access libvirt from many languages; most likely your favorite one is in the list. This is the main layer to create, run and manage your virtual machines.

Interface

Now that we have the full stack to run and manage our virtual machines on Linux, we need an interface. There are many options, and you can create one yourself in your favorite language. However, there are two very nice options that are very functional and ready to go!

Interface CLI

Beginning with the terminal, as you may be running this on a server or just want to manage your virtual machines without a GUI. In this case, you will want to use virsh. You can do everything you need here, including a live migration. This tool deserves an entire series of articles on its own.

Interface GUI

If you are wanting a simple GUI experience that is similar to VirtualBox, then virt-manager (Virtual Machine Manager) is the program for you. I'm a huge fan of this application and I use it to setup my local VMs. However, you can use it to connect to a variety of hypervisors over ssh to manage servers with this GUI as well. You will be missing some more advanced functionality that you have with virsh, but it will get the job done for everyday needs.

Remote

As a bit of a bonus section, it is worth noting that you can use the Virtual Machine Manager to view your machines and interact with them. However, I want to present another option. One of my favorite programs is Remmina. I have all kinds of servers and connections setup where I can easily connect to what I need. This makes my life a lot easier to have all my RDP, SSH, SFTP, VNC and now SPICE connections all in one place.

Looking in the Virtual Machine Manger, open "show virtual hardware details" icon and look at the "Display Spice" item. If you have this set as Spice server type, listen on address type, with localhost only, you can see the port listed that you can use to connect. In a new Remmina connection, select the SPICE protocol and set the server to have the localhost address with the port your found earlier. It may look like this: 127.0.0.1:5900

要查看或添加评论,请登录

社区洞察

其他会员也浏览了