Managing Virtual Machines in the Cloud with the Open-Source libvirt API
- Preparing Your System for Virtualization
- Installing KVM
- libvirt: A Virtualization API
- Other VM Workflows
- Command-Line Access to libvirt with virsh / Running the Code
In this article, I'll be looking at one important area of virtualization: operating system-level virtualization. This variant allows for a complete operating system to be created inside a virtual machine (VM). The management of such VMs is an important problem that has not yet been solved in the general case. I'll be looking at the open-source libvirt API to explore some of the management facilities available in this interesting software technology.
If ever there were two popular buzzwords, it just has to be virtualization and the cloud! Many companies, large and small, are now declaring themselves to be cloud organizations, and yet I believe the current general understanding of these twin technologies remains a little fuzzy.
In fact, I believe virtualization and the cloud are almost synonymous. Indeed, it's probably not too controversial to say that the cloud probably could not exist without virtualization technology. So, if we accept that the cloud foundation is essentially made up of virtualized machine infrastructure, then deploying cloud services to end users becomes what is essentially a management system technology challenge.
As cloud users consume cloud resources (such as, email, data storage, and computing facilities), the big challenge for providers is twofold:
- To deploy worthwhile end user services
- To manage the underlying facilities and the services
We all use the services, but the management is not so widely understood. So, what type of management is typically required? Well, it's the usual suspects:
- Fault handling
- Quotas and metering
Some organizations will successfully meet the above management system challenge, and it is these organizations that will most likely thrive in the cloud era.
A closer look at these management areas suggests that cloud providers are not unlike telecoms providers. In the evolution of telecoms providers, there is normally a startup phase where the provider races to deploy billable services. The network then grows as the number of users grows.
Eventually, the network starts to show signs of strain, and it is usually at this point that the provider begins to struggle with the management of the network. If adequate management systems have been deployed, then the provider can look forward to growth. If on the other hand, the management systems have been neglected, then the provider will experience a great deal of pain.
I think it will be the same story for cloud providershistory repeats itself! What is interesting about the cloud industry is that (unlike the telecoms providers) many of the new cloud providers have little or no experience of managing large commercial networks with many (often demanding) customers.
On top of the management issues, the virtualization market itself is fairly fragmented with a variety of open and closed source offeringsfor example:
So, the big challenge for emerging cloud providers is managing the infrastructure and the services, and deploying survivable services and trying to make money.
Anyway, that's enough marketing talk. Let's now get stuck into the technology!
Preparing Your System for Virtualization
In this article, I'm assuming use of a Linux platform for virtualization. Specifically, I'm using Ubuntu 10.10. But this is not mandatory, because the libvirt tool works on a variety of platforms. On Linux, it's a good idea to check if your platform supports virtualization with the command:
egrep -c '(vmx|svm)' /proc/cpuinfo
If this command returns a value of 1 or more, then your CPU supports virtualization. Next, you should check that your BIOS supports virtualization using this command:
On my Dell Latitude E5400, when I run this command, I see the following output:
INFO: Your CPU supports KVM extensions INFO: KVM is disabled by your BIOS HINT: Enter your BIOS setup and enable Virtualization Technology (VT), and then hard poweroff/poweron your system KVM acceleration can NOT be used
So, I need to reboot and enable VT in my BIOS. However, even without QEMU/KVM extensions support, you can still run QEMU/KVM virtual machines, but they will run much slower.