KVM: Difference between revisions

From UMIACS
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:
*In a terminal run:
*In a terminal run:
:<pre>virt-manager -c qemu:///session</pre>
:<pre>virt-manager -c qemu:///session</pre>
:This will bring up a graphical interface which can be used to manage various aspects of your virtual manchines.
:This will bring up a graphical interface which can be used to manage various aspects of your virtual manchines.  The network that is available is called usermode networking which provides a NAT connection to the outside world.  See bellow about forwarding ports using qemu-kvm.


== Creating a virtual machine ==
== Creating a virtual machine ==
=== Initializing the machine ===
===Initializing the machine===
In virt-manager, highlight 'localhost' and then click the 'New' button.  This will bring up a new window that will guide you through configuring your virtual machine.  For the most part, you should stick with the default options.
In virt-manager, highlight 'localhost' and then click the 'New' button.  This will bring up a new window that will guide you through configuring your virtual machine.  For the most part, you should stick with the default options.
===Forwarding Ports===
This functionality is only available by editing the XML file for your domain directly.  First create your VM with virt-manager and then shut it down.  Run in a shell <code>virsh -c qemu:///session</code> which will drop you into the virsh shell.  You can list your VMs both running and off by typing <code>list --all</code>.  Find the name of the VM and type <code>edit NAME</code> where NAME is the name of the VM.
You need to replace the <code><domain></code> tag in the first line to:
<pre>
  <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
</pre>
Then you need to insert the following lines directly above the last line which should have the <code></domain></code> tag.  In this case the port 2222 will be forwarded to the port 22.  You may specify multiple ports here but each needs its own <code>-redir</code> line and the port specifications.
<pre>
  <qemu:commandline>
      <qemu:arg value='-redir'/>
      <qemu:arg value='tcp:2222::22'/>
    </qemu:commandline>
</pre>

Revision as of 17:27, 6 May 2014

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. KVM also requires a modified QEMU although work is underway to get the required changes upstream.

Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc.

The kernel component of KVM is included in mainline Linux, as of 2.6.20.

    • The system image for the virtual machine should be on local disk space. Putting a running virtual machine on networked file space will result in poor performance for both the virtual machine, as well as other users of the filespace.**


Getting Started

In order to start using KVM on your machine UMIACS Staff will first need to install the requisite packages, and set a baseline configuration. Please submit your request to staff@umiacs.umd.edu along with a brief explanation of your goals for running a local virtual machine.

Once staff has installed the required packages you can then use the program 'virt-manager' to initialize and manager your virtual machines.

  • In a terminal run:
virt-manager -c qemu:///session
This will bring up a graphical interface which can be used to manage various aspects of your virtual manchines. The network that is available is called usermode networking which provides a NAT connection to the outside world. See bellow about forwarding ports using qemu-kvm.

Creating a virtual machine

Initializing the machine

In virt-manager, highlight 'localhost' and then click the 'New' button. This will bring up a new window that will guide you through configuring your virtual machine. For the most part, you should stick with the default options.

Forwarding Ports

This functionality is only available by editing the XML file for your domain directly. First create your VM with virt-manager and then shut it down. Run in a shell virsh -c qemu:///session which will drop you into the virsh shell. You can list your VMs both running and off by typing list --all. Find the name of the VM and type edit NAME where NAME is the name of the VM.

You need to replace the <domain> tag in the first line to:

   <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>

Then you need to insert the following lines directly above the last line which should have the </domain> tag. In this case the port 2222 will be forwarded to the port 22. You may specify multiple ports here but each needs its own -redir line and the port specifications.

   <qemu:commandline>
      <qemu:arg value='-redir'/>
      <qemu:arg value='tcp:2222::22'/>
    </qemu:commandline>