Programster's Blog

Tutorials focusing on Linux, programming, and open source

Ubuntu 14.04 - Getting Started with KVM using PHP Helper Script

This post carries on from my previous article on how to install KVM on Ubuntu 14.04. To make life easier, I have created a PHP tool help you create guests on your KVM host.

Setup

Install PHP

The tool requires PHP, and you will need git in order to fetch the tool so go ahead and install them.

sudo apt-get update
sudo apt-get install php5-cli git -y

Now we are going to fetch the tool and use the Ubuntu 14.04 branch.

cd ~
git clone git@github.com:programster/KVM-Command-Generator.git
cd KVM-Command-Generator
git checkout ubuntu14.04-1.1.1

Using The Tool

Simply call the script and answer all the questions.

php main.php

After having answered all the questions, copy the command it outputs and execute it.

Watch the guest get set up in text-mode in front of your eyes.

Voila! You know have a guest instance. The username and password are both ubuntu for Ubuntu VMs, and root for Debian. You may want to change this.

The script executes a kickstart file to automatically install the operating system. It is an extremely good idea to make your own and host it on the web, such as with pastebin.

Extra Info

  • If you use the KVM script to deploy an Ubuntu guest, the default username and password are both ubuntu. Please change this after installation.
  • The KVM script will deploy guests as minimally as possible. You will need to install the acpi package in the guests for the virsh commands on the host to be able to shutdown/reboot guests.

Debugging

If you see the following message:

Error in network device parameters: Virtual network 'default' has not been started.

Then run the following command:

sudo virsh net-start default

Virtualbox

KVM and Virtualbox appear to not work simultaneously on the same host. If you are running Virtualbox whilst you try to create an instance, you may see the following:

ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy
failed to initialize KVM: Device or resource busy