个人工具

“UbuntuHelp:KVM”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示同一用户的7个中间版本)
第3行: 第3行:
 
#title The Kernel Virtual Machine
 
#title The Kernel Virtual Machine
 
== Introduction ==
 
== Introduction ==
=== Preliminary notes ===
+
Ubuntu uses [http://www.linux-kvm.org/page/Main_Page KVM] as the backend virtualisation technology and [http://libvirt.org/ libvirt] as its toolkit/API.  Libvirt frontends for managing VMs include [http://virt-manager.et.redhat.com/ virt-manager] (GUI) or virsh (CLI). Alternative management options include [http://www.convirture.com/ convirt] (GUI) or [http://www.convirture.com/wiki/index.php?title=Convirt2_Installation convirt2] (WWW).
* '''This is still work in progress! Feel free to jump in and extend this documentation! '''
+
== Documentation ==
 +
* [[UbuntuHelp:KVM/Installation|Installation]] - Installation and removal of KVM
 +
* [[UbuntuHelp:KVM/Networking|Networking]] - Network configuration; includes bridging
 +
* [[UbuntuHelp:KVM/CreateGuests|Guest Creation]] - Creation of different kinds of guests
 +
* [[UbuntuHelp:KVM/Managing|Guest Management]] - Management of guests; command line or graphically
 +
* [[UbuntuHelp:KVM/Directly|KVM Directly]] - Using KVM directly (without libvirt)
 +
* [[UbuntuHelp:KVM/FAQ|FAQ]] - Frequently asked questions, troubleshooting tips and other recommendations
 +
== Notes ==
 
* '''The previous version of this page (which was documenting KVM for Feisty) has been moved to [[UbuntuHelp:KVMFeisty|KVMFeisty]]'''
 
* '''The previous version of this page (which was documenting KVM for Feisty) has been moved to [[UbuntuHelp:KVMFeisty|KVMFeisty]]'''
=== Basic info ===
+
* '''Also checkout the official docs, http://doc.ubuntu.com/ubuntu/serverguide/C/virtualization.html'''
Ubuntu uses [http://kvm.qumranet.com/ kvm] as the backend virtualisation technology. To manage VMs we use [http://libvirt.org/ libvirt] as the basic toolbox and [http://virt-manager.et.redhat.com/ virt-manager] as the graphical frontend for managing your vm's.
+
* The use case targeted when KVM was moved into main is '''"server virtualization"'''.  This means that even though KVM can be used to serve other purposes, it has been designed to be run on Ubuntu Server Edition to host non-graphical server operating systems. If you are looking for software to serve graphically-based virtual machines, [[UbuntuHelp:VirtualBox|VirtualBox]], Parallels Workstation (or Parallels Desktop for Mac), or [[UbuntuHelp:VMware|VMware]] Player/Server are more suitable alternatives.
== How to get started ==
+
=== How to check if your CPU supports hardware virtualisation ===
+
To run KVM, you need a processor that supports virtualisation; Intel and AMD both have developed extensions for their processors, respectively INTEL-VT and AMD-V. To see if your processor supports one of these, you can run the following command:
+
<pre><nowiki>
+
egrep '(vmx|svm)' /proc/cpuinfo
+
</nowiki></pre>
+
If nothing is printed, it means that your CPU doesn't support hardware virtualisation. Otherwise, it does - but you still need to make sure that virtualisation is enabled in the BIOS.
+
=== Installation of KVM ===
+
For the following setup, we will assume that you are deploying KVM on a server, and therefore do not have any X server on the machine.
+
You need to install a few packages first:
+
<pre><nowiki>
+
$ sudo apt-get install kvm libvirt-bin ubuntu-vm-builder
+
</nowiki></pre>
+
* libvirt-bin provides libvirtd which you need to administer qemu and kvm instances using libvirt
+
* kvm is the backend
+
* ubuntu-vm-builder powerful command line tool for building virtual machines
+
Then, add yourself to the ''libvirtd'' and ''kvm'' groups:
+
<pre><nowiki>
+
$ sudo adduser `id -un` libvirtd
+
$ sudo adduser `id -un` kvm
+
</nowiki></pre>
+
This will give you access to the system-wide libvirtd instance. This is preferable for you because it gives you access to the advanced networking options rather than simply the "userspace networking" option as you may know it from QEmu.
+
Note: You need to log out and log back in for the new group membership to take effect.
+
Note: The `id -un` command will return the current username, for example if your username is ''joe'' you will be effectively be running ''sudo adduser joe libvirtd''.
+
You can test if your install has been successful with the following command:
+
<pre><nowiki>
+
$ virsh -c qemu:///system list
+
Id Name                State
+
----------------------------------
+
 
+
$
+
</nowiki></pre>
+
If on the other hand you get something like this:
+
<pre><nowiki>
+
$ virsh -c qemu:///system list
+
libvir: Remote error : Permission denied
+
error: failed to connect to the hypervisor
+
$
+
</nowiki></pre>
+
Something is wrong and you probably want to fix this before you move on. The critical point here is whether or not you have write access to ''/var/run/libvirt/libvirt-sock''.
+
== Network Bridging ==
+
There are a few different ways to allow a virtual machine access to the external network. The default virtual network configuration is usermode networking, which uses the SLIRP protocol and traffic is NATed through the host interface to the outside network.
+
To enable external hosts to directly access services on virtual machines a bridge needs to be configured. This allows the virtual interfaces to connect to the outside network through the physical interface, making them appear as normal hosts to the rest of the network.
+
'''Warning:''' Network bridging will not work when the physcial network device (eg eth1, ath0) used for bridging is a wireless device (eg ipw3945), as most wireless device drivers do not support bridging!
+
=== Creating a network bridge on the host ===
+
To setup a bridge interface edit /etc/network/interfaces and either comment or replace the existing config with (replace with the values for your network):
+
<pre><nowiki>
+
auto lo
+
iface lo inet loopback
+
 
+
auto br0
+
iface br0 inet static
+
        address 192.168.0.10
+
        network 192.168.0.0
+
        netmask 255.255.255.0
+
        broadcast 192.168.0.255
+
        gateway 192.168.0.1
+
        bridge_ports eth0
+
        bridge_fd 9
+
        bridge_hello 2
+
        bridge_maxage 12
+
        bridge_stp off
+
 
+
iface eth0 inet static
+
address 172.16.5.0
+
netmask 255.255.255.0
+
</nowiki></pre>
+
or to use DHCP
+
<pre><nowiki>
+
auto lo
+
iface lo inet loopback
+
 
+
auto br0
+
iface br0 inet dhcp
+
        bridge_ports eth0
+
        bridge_fd 9
+
        bridge_hello 2
+
        bridge_maxage 12
+
        bridge_stp off
+
 
+
iface eth0 inet static
+
address 172.16.5.0
+
netmask 255.255.255.0
+
</nowiki></pre>
+
This will create a virtual interface br0. Don't worry about the static eth0 line. It gets overwritten by the bridge but the statement is necessary or you get an eth0 error.
+
Now restart networking :
+
<pre><nowiki>
+
sudo /etc/init.d/networking restart
+
</nowiki></pre>
+
=== Configuring ubuntu-vm-builder to create bridged guests by default ===
+
Virtual machines are defined in XML files; ubuntu-vm-builder, the tool we will use to create VMs, bases them on the template file /usr/share/ubuntu-vm-builder/templates/libvirt.tmpl.
+
Open that file, and change:
+
<pre><nowiki>
+
    <interface type='network'>
+
      <mac address='%MAC%'/>
+
      <source network='default'/>
+
    </interface>
+
</nowiki></pre>
+
To:
+
<pre><nowiki>
+
    <interface type='bridge'>
+
      <mac address='%MAC%'/>
+
      <source bridge='br0'/>
+
    </interface>
+
</nowiki></pre>
+
=== Converting an existing guest ===
+
If you have already created VMs before, you can make them use bridged networking if you change the XML definition (in /etc/libvirt/qemu/) for the network interface, adjusting the mac address as desired from:
+
<pre><nowiki>
+
    <interface type='network'>
+
      <mac address='00:11:22:33:44:55'/>
+
      <source network='default'/>
+
    </interface>
+
</nowiki></pre>
+
to:
+
<pre><nowiki>
+
    <interface type='bridge'>
+
      <mac address='00:11:22:33:44:55'/>
+
      <source bridge='br0'/>
+
    </interface>
+
</nowiki></pre>
+
You do not need to restart libvirtd to reload the changes; the easiest way is to log into virsh (a command line tool to manage VMs), stop the VM, reread its configuration file, and restart the VM:
+
<pre><nowiki>
+
yhamon@paris:/etc/libvirt/qemu$ ls
+
mirror.xml  networks  vm2.xml
+
yhamon@paris:/etc/libvirt/qemu$ sudo virsh
+
Connecting to uri: qemu:///system
+
Welcome to virsh, the virtualization interactive terminal.
+
 
+
Type:  'help' for help with commands
+
      'quit' to quit
+
 
+
virsh # list
+
Id Name                State
+
----------------------------------
+
10 vm2                  running
+
15 mirror              running
+
 
+
virsh # shutdown mirror
+
Domain mirror is being shutdown
+
 
+
virsh # define mirror.xml
+
Domain mirror defined from mirror.xml
+
 
+
virsh # start mirror
+
Domain mirror started
+
 
+
</nowiki></pre>
+
The VM "mirror" is now using bridged networking.
+
== Creating virtual machines ==
+
Now that KVM is installed, let s see how we install our first VM. There is a tool to manage VMs on a remote host: virt-manager. Sadly, VM creation on a remote host is not supported yet - therefore you will have to create the VM in command line.
+
There are two different tools to do this; virt-install, a python script developed by redhat, and ubuntu-vm-builder, developed by Canonical.
+
=== Ubuntu-vm-builder: the fast & powerful way to create Ubuntu JEOS VMs ===
+
[http://doc.ubuntu.com/ubuntu/serverguide/C/ubuntu-vm-builder.html Ubuntu-vm-builder] is probably the best tool to use if you want to create VMs running Ubuntu JEOS 8.04, as the install is entirely scripted (very fast).
+
This tool is packaged, and in universe:
+
<pre><nowiki>
+
sudo apt-get install ubuntu-vm-builder
+
</nowiki></pre>
+
==== Basic use ====
+
Here is a very basic example of how to use it:
+
<pre><nowiki>
+
sudo ubuntu-vm-builder kvm hardy
+
</nowiki></pre>
+
This will create an Ubuntu Hardy, with all options set to default.
+
==== More complex example ====
+
Now here is a somewhat more complex example:
+
<pre><nowiki>
+
ubuntu-vm-builder kvm hardy \
+
                  --domain newvm \
+
                  --dest newvm \
+
                  --arch i386 \
+
                  --hostname hostnameformyvm \
+
                  --mem 256 \
+
                  --user john \
+
                  --pass doe \
+
                  --ip 192.168.0.12 \
+
                  --mask 255.255.255.0 \
+
                  --net 192.168.0.0 \
+
                  --bcast 192.168.0.255 \
+
                  --gw 192.168.0.1 \
+
                  --dns 192.168.0.1 \
+
                  --mirror http://archive.localubuntumirror.net/ubuntu \
+
                  --components main,universe \
+
                  --addpkg vim \
+
                  --libvirt qemu:///system ;
+
</nowiki></pre>
+
This will create a new Ubuntu Hardy VM called "newvm", the hostname will be set to "hostnameformyvm", the network will be configured with a static IP address and a gateway at address 192.168.0.1. The --mirror will tell the script to download the packages from a local Ubuntu mirror instead of the default server (this may speed up by a lot the time necessary to create the VM). The components argument will enable main and universe by default on the VM, --addpkg vim will install vim, and finally the last argument will automatically add the newly created VM to KVM.
+
Note: The manual isn't specific about the --exec option, used to execute a script file during the vm build process. If you specify the --exec option then you must provide the full path to the script you are executing. Not doing so will cause the installer to tell you that it can't find the script file.
+
==== Install on a raw block device ====
+
Ubuntu-vm-builder doesn't allow you to create the VM on a raw block device yet (like a standalone partition, or a iSCSI share). You can use ubuntu-vm-builder to create the qcow2 image and then move the VM to the block device with qemu-img though; if /dev/sdb is the disk device on which you want to move the virtual machine:
+
<pre><nowiki>
+
sudo qemu-img convert root.qcow2 -O raw /dev/sdb
+
</nowiki></pre>
+
Edit the XML definition file for the VM in /etc/libvirt/qemu/, and set the source file to be:
+
<pre><nowiki>
+
<source file='/dev/sdb'/>
+
</nowiki></pre>
+
Redefine the VM and start it; it is now running from /dev/sdb.
+
Ubuntu-vm-builder is a very powerful tool - to get a more detailed list of its capabilities, use ubuntu-vm-builder --help.
+
=== Create VMs running other operating systems: virt-install ===
+
Virt-install is radically different in the way it works. Instead of creating automagically a new VM, it will allow you to boot on an iso, and therefore to install almost any operating system.  For a list of supported operating system, consult [http://kvm.qumranet.com/kvmwiki/Guest_Support_Status kvm's official webpage].
+
Copy the ISO of the system you want to install to your working directory:
+
<pre><nowiki>
+
yhamon@paris:~$ ls *.iso
+
ubuntu-8.04-server-i386.iso  windowsxpsp2.iso
+
</nowiki></pre>
+
Then, run virt-install:
+
<pre><nowiki>
+
sudo virt-install -n xpsp2 -r 512 -f devserver.img -s 5 -c windowsxpsp2.iso --accelerate --vnc --noautoconsole
+
</nowiki></pre>
+
This will boot a new VM from the ISO. Connect to the new VM using virt-viewer:
+
<pre><nowiki>
+
virt-viewer -c qemu+ssh://10.10.10.10/system xpsp2
+
</nowiki></pre>
+
You should now have a graphical interface to install your VM!
+
== Manage your virtual machines ==
+
=== From the shell ===
+
You can manage your VMs from the shell using [http://linux.die.net/man/1/virsh virsh]. You can get a list of the available commands if you type "help". Type "help command" to get additional infos for a particular command.
+
==== List your VMs ====
+
Virsh allows you to list the virtual machines available on the current host:
+
<pre><nowiki>
+
yhamon@paris:/etc/libvirt/qemu$ sudo virsh
+
Connecting to uri: qemu:///system
+
Welcome to virsh, the virtualization interactive terminal.
+
 
+
Type:  'help' for help with commands
+
      'quit' to quit
+
 
+
virsh # help list
+
  NAME
+
    list - list domains
+
 
+
  SYNOPSIS
+
    list [--inactive | --all]
+
 
+
  DESCRIPTION
+
    Returns list of domains.
+
 
+
  OPTIONS
+
    --inactive      list inactive domains
+
    --all            list inactive & active domains
+
 
+
virsh # list
+
  Id Name                State
+
----------------------------------
+
15 mirror              running
+
16 vm2                  running
+
 
+
virsh # list --all
+
Id Name                State
+
----------------------------------
+
15 mirror              running
+
16 vm2                  running
+
  - test5                shut off
+
</nowiki></pre>
+
==== Define, undefine, start, shutdown, destroy VMs ====
+
The VMs you see with list --all are VMs that have been "defined" from an XML file. Every VM is configured via a XML file in /etc/libvirt/qemu. If you want to remove a VM from the list of VMs, you need to undefine it:
+
<pre><nowiki>
+
virsh # undefine test5  # WARNING: undefine will delete your XML file!
+
Domain test5 has been undefined
+
 
+
virsh # list --all
+
Id Name                State
+
----------------------------------
+
15 mirror              running
+
16 vm2                  running
+
</nowiki></pre>
+
To be able to undefine a virtual machine, it needs to be shutdown first:
+
<pre><nowiki>
+
virsh # shutdown mirror
+
Domain mirror is being shutdown
+
</nowiki></pre>
+
This command asks for a nice shutdown (like running shutdown in command line) - but you can also use "destroy", the more brutal way of shutting down a VM, equivalent of taking the power cable off:
+
<pre><nowiki>
+
virsh # destroy mirror
+
Domain mirror destroyed
+
</nowiki></pre>
+
If you have made a change to the XML configuration file, you need to tell KVM to reload it before restarting the VM:
+
<pre><nowiki>
+
virsh # define /etc/libvirt/qemu/mirror.xml
+
Domain mirror defined from /etc/libvirt/qemu/mirror.xml
+
</nowiki></pre>
+
Then, to restart the VM:
+
<pre><nowiki>
+
virsh # start mirror
+
Domain mirror started
+
</nowiki></pre>
+
==== Suspend and resume a Virtual Machine ====
+
Virsh allows you to easily suspend and resume a virtual machine.
+
<pre><nowiki>
+
virsh # suspend mirror
+
Domain mirror suspended
+
 
+
virsh # resume mirror
+
Domain mirror resumed
+
</nowiki></pre>
+
=== Using a graphical interface ===
+
There is also an easier way to manage your virtual machines. The tool virt-manager allows you to use a graphical interface to interact with KVM. Install virt-manager on your desktop:
+
<pre><nowiki>
+
sudo apt-get install virt-manager virt-viewer
+
</nowiki></pre>
+
And use it to connect to your server:
+
<pre><nowiki>
+
$ virt-manager -c qemu+ssh://10.10.10.10/system
+
</nowiki></pre>
+
10.10.10.10 being the IP address of your host running KVM.
+
https://help.ubuntu.com/community/KVM?action=AttachFile&do=get&target=virt-manager.png
+
== How-to edit the attributes of a Virtual Machine (add CPUs, RAM) ==
+
KVM allows you to create SMP guests: If you have several processors/cores on the KVM host, each VM can use one or more than one of these. To add CPUs to one VM, you need to edit the '/etc/libvirt/qemu/yourvm.xml' file:
+
<pre><nowiki>
+
<domain type='kvm'>
+
  <name>mirror</name>
+
  <uuid>ec13fb81-7960-ec5a-fa99-d8928f75d3ea</uuid>
+
  <memory>524288</memory>
+
  <currentMemory>524288</currentMemory>
+
  <vcpu>1</vcpu>
+
  <os>
+
    <type>hvm</type>
+
    <boot dev='hd'/>
+
  </os>
+
  <clock offset='utc'/>
+
  <on_poweroff>destroy</on_poweroff>
+
  <on_reboot>restart</on_reboot>
+
  <on_crash>destroy</on_crash>
+
  <devices>
+
    <emulator>/usr/bin/kvm</emulator>
+
    <disk type='file' device='disk'>
+
      <source file='/home/yhamon/mirror.img'/>
+
      <target dev='hda' bus='ide'/>
+
    </disk>
+
    <interface type='bridge'>
+
      <mac address='00:16:3e:4d:94:c0'/>
+
      <source bridge='br0'/>
+
    </interface>
+
    <input type='mouse' bus='ps2'/>
+
    <graphics type='vnc' port='-1' listen='127.0.0.1'/>
+
  </devices>
+
</domain>
+
</nowiki></pre>
+
This file is the equivalent of *.vmx files in vmware, and is pretty easy to understand. To assign 2 CPUs to your VM, just change '<vcpu>1</vcpu>' by '<vcpu>2</vcpu>'. You will need to shutdown your vm, redefine it, and restart it, to have the changes active (see previous chapter for how to do this).
+
== Troubleshooting/FAQ ==
+
=== How to boot Dapper, Edgy, Feisty or Gutsy ISO ===
+
* Q: I'm on Intel hardware, and I'm trying to boot Dapper, Edgy, Feisty, or Gutsy, but kvm fails immediately.
+
* A: Yes, this is rather unfortunate. The issue is a limitation in Intel's virtualisation extensions that don't interact very well with gfxboot. The evil, hacky workaround is to modify the ISO to disable gfxboot. The following has worked for me, but it might kill your cat or make your coffee go cold or make other unpleasantries happen to you. You've been warned!
+
<pre><nowiki>
+
$ sed -e 's/GFXBOOT bootlogo/#FXBOOT bootlogo/g' < ubuntu-7.10-server-amd64.iso > ubuntu-7.10-server-amd64-nogfxboot.iso
+
</nowiki></pre>
+
/!\ Don't change the above command! The length of the string mustn't change or you will have knackered the filesystem on the CD.
+
A slightly safer way is to download gfxboot-disable from [http://hg.codemonkey.ws/gfxboot-disable] and then run:
+
<pre><nowiki>
+
$ gfxboot-disable ubuntu-7.10-server-amd64.iso
+
</nowiki></pre>
+
=== How to convert [[UbuntuHelp:VMware|VMware]] machines to virt-manager ===
+
kvm has the ability to use [[UbuntuHelp:VMware|VMware]]'s vmdk disk files directly, as long as the disk is wholly contained in the vmdk (ie [[UbuntuHelp:VMware|VMware]] allows splitting a disk into smaller, usually 2GB, vmdk files. kvm can't use these). Point kvm at the vmdk with the appropriate options (see <code><nowiki> man kvm-qemu </nowiki></code>), and it should work.
+
To use the [[UbuntuHelp:VMware|VMware]] machine from within virt-manager, the .vmx file must be converted to libvirt's .xml. vmware2libvirt was created to help with this, and it can be used like so:
+
<pre><nowiki>
+
$ vmware2libvirt -f ./file.vmx > file.xml
+
$ virsh -c qemu:///system define file.xml
+
</nowiki></pre>
+
The first command converts the [[UbuntuHelp:VMware|VMware]] 'file.vmx' file to the libvirt compatible 'file.xml'. See <code><nowiki> man vmware2libvirt </nowiki></code> for details. '''Note:''' until vmware2libvirt is shipped with the libvirt packages, you can download it from [http://people.ubuntu.com/~soren/vmware2libvirt/]. The second command imports file.xml into libvirt. The imported .xml files are stored in /etc/libvirt/qemu.
+
'''IMPORTANT:''' keep in mind that while the .vmx file is converted to .xml, the disks are used as is. Please make backups, especially if you want to use the virtual machine in [[UbuntuHelp:VMware|VMware]] later.
+
==== Caveats ====
+
While vmware2libvirt works well on simple virtual machines, there are limitations because .vmx files don't always contain enough information, and also because vmware2libvirt tries not to make too many assumptions about what it finds. A couple of things to look out for:
+
<ol><li>While vmware2libvirt attempts to detect a 64-bit guest, be sure that your 64-bit guest has in its .xml file: <pre><nowiki>
+
<os>
+
<type arch='x86_64' machine='pc'>hvm</type>
+
...
+
</os>
+
</nowiki></pre>
+
</li><li>vmware2libvirt only detects and uses the first ethernet interface found. Additional interfaces can be added from within virt-manager.
+
</li><li>Currently the first scsi disk is used if found, otherwise the first ide disk. Additional disks can be added from within virt-manager.
+
</li><li>The converted virtual machine is hard-coded to use 1 cpu.  This can be changed with:<pre><nowiki>
+
<vcpu>2</vcpu>
+
</nowiki></pre>
+
</li><li>vmware2libvirt does not (and cannot) convert anything that was VMware-specific within the guest. See 'Guest Notes' below for more details.</li></ol>
+
 
+
==== Guest notes ====
+
<ol><li>Be sure to remove vmware-tools if you have it installed (otherwise it will overwrite xorg.conf on reboot)
+
</li><li>Guests should not use ntp to synchronize the clock, so be sure to remove/disable ntpd
+
</li><li>Linux guests with Xorg should be using the 'cirrus' video driver.  To use, adjust /etc/X11/xorg.conf to have: <pre><nowiki>
+
Section "Device"
+
        Identifier      "Configured Video Device"
+
        Driver          "cirrus"
+
EndSection
+
</nowiki></pre> then be sure that your Screen section uses 'Configured Video Device' for its Device.
+
</li><li>Linux guests with Xorg should be using the 'vmmouse' driver (not available on Ubuntu Dapper).  To use, perform within the guest: <pre><nowiki>
+
aptitude install xserver-xorg-input-vmmouse
+
</nowiki></pre> then adjust /etc/X11/xorg.conf to have (the Identifier line should not change, and you should have only an Identifier line and Driver line for the mouse): <pre><nowiki>
+
Section "InputDevice"
+
        Identifier      "Configured Mouse"
+
        Driver          "vmmouse"
+
EndSection
+
</nowiki></pre>
+
</li><li>Linux guests with Xorg need to adjust the resolution for Xorg in /etc/X11/xorg.conf.  Look for the Screen section, and make sure each of the 'Modes' lines has a reasonable resolution for your system (due to [https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/193456 bug #193456] the resolution in the guest's resolution needs to be smaller than the host). Eg: <pre><nowiki>
+
Section "Screen"
+
        ...
+
        SubSection "Display"
+
                Depth          16
+
                Modes          "800x600" "640x480"
+
        EndSubSection
+
        SubSection "Display"
+
                Depth          24
+
                Modes          "800x600" "640x480"
+
        EndSubSection
+
EndSection
+
</nowiki></pre>
+
</li><li>Windows (other than Vista) virtual machines should substitute in the .xml file: <pre><nowiki>
+
<features>
+
  <acpi/>
+
</features>
+
</nowiki></pre> with: <pre><nowiki>
+
<features/>
+
</nowiki></pre>
+
</li><li>Windows Vista virtual machines should add these to the /etc/libvirt/qemu/my-vista.xml file: <pre><nowiki>
+
<domain type='kvm'>
+
...
+
  <features>
+
    <acpi/>
+
  </features>
+
</domain>
+
</nowiki></pre>
+
</li><li>Debian Sarge (oldstable) may write /boot/grub/menu.lst incorrectly, resulting in the following on boot: <pre><nowiki>
+
pivot_root: no such file or directory
+
/sbin/init: 432: cannot open dev/console: no such file
+
Kernel panic: Attempted to kill init!
+
</nowiki></pre> The fix is at the grub menu, press 'e' and adjust <code><nowiki>root=/dev/hdb1</nowiki></code> to be <code><nowiki>root=/dev/hda1</nowiki></code>. After a successful boot, you will need to update /boot/grub/menu.lst to have: <pre><nowiki>
+
# kopt=root=/dev/hda1 ro
+
</nowiki></pre> and run: <pre><nowiki>
+
# update-grub
+
</nowiki></pre></li></ol>
+
 
+
 
----
 
----
 
[[category:CategoryVirtualization]]
 
[[category:CategoryVirtualization]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 23:05的最新版本

  1. title The Kernel Virtual Machine

Introduction

Ubuntu uses KVM as the backend virtualisation technology and libvirt as its toolkit/API. Libvirt frontends for managing VMs include virt-manager (GUI) or virsh (CLI). Alternative management options include convirt (GUI) or convirt2 (WWW).

Documentation

  • Installation - Installation and removal of KVM
  • Networking - Network configuration; includes bridging
  • Guest Creation - Creation of different kinds of guests
  • Guest Management - Management of guests; command line or graphically
  • KVM Directly - Using KVM directly (without libvirt)
  • FAQ - Frequently asked questions, troubleshooting tips and other recommendations

Notes

  • The previous version of this page (which was documenting KVM for Feisty) has been moved to KVMFeisty
  • Also checkout the official docs, http://doc.ubuntu.com/ubuntu/serverguide/C/virtualization.html
  • The use case targeted when KVM was moved into main is "server virtualization". This means that even though KVM can be used to serve other purposes, it has been designed to be run on Ubuntu Server Edition to host non-graphical server operating systems. If you are looking for software to serve graphically-based virtual machines, VirtualBox, Parallels Workstation (or Parallels Desktop for Mac), or VMware Player/Server are more suitable alternatives.