KVM Driver Configuration Guide for ONE 1.0

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.

Requirements

Remote Hosts

  • CPU with VT extensions
  • libvirt >= 0.4.0
  • kvm kernel modules (kvm.ko, kvm-{intel,amd}.ko). Available from kernel 2.6.20 onwards.
  • qemu virtual machine image

To gather and install the available software on a Ubuntu system:

 # sudo apt-get install kvm libvirt-bin ubuntu-vm-builder

KVM Configuration

Steps in the remote host to get this driver running:

  • The remote hosts must have the libvirt daemon running.
  • The user with access to these remotes hosts on behalf of ONE (typically <oneadmin>) has to pertain to the <libvirtd> group in order to use the deaemon.

Driver files

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.

OpenNebula Configuration

ONE Core Configuration

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 name of the driver needs to be provided at the time of adding a new host to ONE.
  • executable point to the path of the driver executable file.
  • The default points to the configuration file for the driver (see below).
  • type identifies this driver as a KVM driver.

Driver Configuration

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).
  • The $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.

KVM Specific Template Attributes (mandatory)

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]

KVM Specific Template Attributes (non-mandatory)

  • PAE: Physical address extension mode allows 32-bit guests to address more than 4 GB of memory:
  • ACPI: useful for power management, for example, with KVM guests it is required for graceful shutdown to work.

Format and valid values:

  FEATURES=[
      pae={yes,no},   
      acpi={yes,no} ]
  • RAW : This attribute offers the end user the possibility of passing by attributes not known by ONE to KVM. Basically, everything placed here will be written literally into the KVM deployment file (use libvirt xml format and semantics).

RAW = [ type=“kvm”, data=“<console type='stdio'><target port='1'></console>” ]

Testing

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"]