KVM (Kernel-based Virtual Machine) is a complete virtualization technique for Linux. It offers full virtualization, where each Virtual Machine interacts with its own virtualized hardware.
To gather and install the available software on a Ubuntu system:
# sudo apt-get install kvm libvirt-bin ubuntu-vm-builder
Steps in the remote host to get this driver running:
Relative to $ONE_LOCATION
:
bin/one_vmm_kvm
: Shell script wrapper to the driver itself. Sets the environment and other bootstrap tasks.bin/one_vmm_kvm.rb
: The actual KVM driver.etc/vmm_kvm/vmm_kvmrc
: environment setup and bootstrap instructions etc/vmm_kvm/vmm_kvm.conf
: set here default values for KVM domain definitions.
ONE needs to know if it is going to use the KVM Driver. To achieve this, two lines have to be placed within /etc/oned.conf
, one for the VM driver and other for the IM driver:
IM_MAD = [ name = "im_kvm", executable = "bin/one_im_ssh", arguments = "etc/im_kvm/im_kvm.conf", default = "etc/im_kvm/im_kvm.conf" ]
VM_MAD = [ name = "vmm_kvm", executable = "bin/one_vmm_kvm", default = "etc/vmm_kvm/vmm_kvm.conf", type = "kvm" ]
The driver uses two configuration files, by default placed in $ONE_LOCATION/etc/vmm_kvm
:
$ONE_LOCATION/etc/vmm_kvm/vmm_kvm.conf
, or wherever stated in the oned.conf
configuration file, the default attribute in the driver specification line. This file is home for default values for domain definitions (in other words, ONE Templates). $ONE_LOCATION/etc/vmm_kvm/vmm_kvmrc
file can hold instructions to be executed before the actual driver load to perform specific tasks or to pass environmental variables to the driver. The syntax used for the former is plain shell script that will be evaluated before the driver execution. For the latter, the syntax is the familiar:ENVIRONMENT_VARIABLE=VALUE
Here is an example. If the user wants to set a default value for CPU requirements for all of their KVM domain definitions, simply edit the $ONE_LOCATION/etc/vmm_kvm/vmm_kvm.conf
file and set a
CPU=0.6
into it. Now, when defining a ONE template to be sent to a KVM resource, the user has the choice of “forgetting” to set the CPU requirement, in which case it will default to 0.6.
It is generally a good idea to place defaults for the KVM-specific attributes, that is, attributes mandatory in the KVM driver that are not mandatory for other hypervisors. Non mandatory attributes for KVM but specific to them are also recommended to have a default.
Specify the boot device to consider in the OS attribute, using BOOT. Valid values for BOOT are fd
, hd
, cdrom
or network
, for example:
OS=[KERNEL=/vmlinuz,BOOT=hd]
Format and valid values:
FEATURES=[ pae={yes,no}, acpi={yes,no} ]
RAW = [ type=“kvm”, data=“<console type='stdio'><target port='1'></console>” ]
In order to test the KVM driver, the following template can be instantiated with appropriate values and sent to a KVM resource:
CPU = 0.5 MEMORY = 128 OS = [kernel="/path-to-kernel",initrd= "/path-to-initrd",boot="hd" ] DISK = [source="/path-to-image-file",target="hda",readonly="no"] NIC = [mac="xx.xx.xx.xx.xx.xx", bridg="eth0"] GRAPHICS = [type="vnc",listen="127.0.0.1",port="5900"]