Kernel-based Virtual Machine: Difference between revisions

Content deleted Content added
Links
Better reference for z/Architecture and PPC, and also a reference for IA-64. Add another reference for "s390" really meaning "s390x", i.e. z/Architecture.
 
(65 intermediate revisions by 41 users not shown)
Line 1:
{{short description|Virtualization module in the Linux kernel}}
<!-- {{RedirectDistinguish|KVM switch}} -->
 
{{Infobox software
| name = KVM
| logo = Kvmbanner-logo2 1.png
| logo size = 160px
| screenshot = KvmQEMU 6.2 running variousNetBSD and OpenIndiana guestsscreenshot.png
| screenshot size = 300px
| caption = Screenshot of QEMU/KVM running [[NetBSD]], [[OpenSolaris]] and [[KubuntuOpenIndiana]] guests on an [[Arch Linux]] host.
| author = [[Qumranet]]
| developer = The [[Linux Kernel]] community
| operating_system = [[Unix-like]]
| programming_language = [[C (programming language)|C]]
| platform = [[ARM architecture|ARM]], [[IA-64PowerPC]], [[PowerPCz/Architecture]], [[IBM ESA/390|S/390IA-32]], [[x86-64]], [[x86RISC-64V]]
| genre = [[Hypervisor]]
| license = [[GNU General Public License|GNU GPL]] or [[GNU Lesser General Public License|LGPL]]
| website = {{URL|www.linux-kvm.org}}
}}
{{Distinguish|KVM switch}}
 
'''Kernel-based Virtual Machine''' ('''KVM''') is a [[free and open-source]] [[virtualization]] module in the [[Linux kernel]] that allows the [[Kernel (operating system)|kernel]] to function as a [[hypervisor]]. It was merged into the [[Linux]] kernelMainline Linux|mainline inLinux kernel]] in version 2.6.20, which was released on February 5, 2007.<ref name="2620notes">{{cite web
| url = http://kernelnewbies.org/Linux_2_6_20#head-bca4fe7ffe454321118a470387c2be543ee51754
| title = Linux kernel 2.6.20, Section 2.2. Virtualization support through KVM
| date = 2007-02-05
| accessdateaccess-date = 2014-06-16
| website = kernelnewbies.org}}</ref> KVM requires a processor with [[hardware virtualization]] extensions, such as [[Intel VT]] or [[AMD-V]].<ref>[http://www.linux-kvm.org/page/FAQ#What_do_I_need_to_use_KVM.3F KVM FAQ: What do I need to use KVM?]</ref> KVM has also been ported to other operating systems such as [[FreeBSD]]<ref>{{cite web|url=http://www.freebsd.org/news/status/report-2007-07-2007-10.html#Porting-Linux-KVM-to-FreeBSD|title=FreeBSD Quarterly Status Report: Porting Linux KVM to FreeBSD}}</ref> and [[illumos]]<ref>{{cite web|url=http://dtrace.org/blogs/bmc/2011/08/15/kvm-on-illumos/|title=KVM on illumos|date=15 August 2011 }}</ref> in the form of loadable kernel modules.
 
KVM was originally designed for [[x86]] processors but has since been [[porting|ported]] to [[z/Architecture]],<ref name="2626notes">{{cite web
KVM was originally designed for [[x86]] processors and has since been [[porting|ported]] to [[IBM ESA/390|S/390]],<ref>{{Cite web |url=http://article.gmane.org/gmane.comp.emulators.kvm.devel/2570 |title=Gmane - Mail To News And Back Again<!-- Bot generated title --> |access-date=2007-05-07 |archive-url=https://web.archive.org/web/20070929124348/http://article.gmane.org/gmane.comp.emulators.kvm.devel/2570 |archive-date=2007-09-29 |url-status=dead }}</ref> [[PowerPC]],<ref>[http://news.gmane.org/gmane.comp.emulators.kvm.devel/2595 Gmane Loom<!-- Bot generated title -->] {{webarchive|url=https://web.archive.org/web/20070929103042/http://news.gmane.org/gmane.comp.emulators.kvm.devel/2595 |date=2007-09-29 }}</ref> [[IA-64]], and [[ARM architecture|ARM]].<ref>{{Cite web |url=https://columbia.github.com/linux-kvm-arm |title=KVM/ARM Open Source Project |access-date=2017-11-01 |archive-url=https://web.archive.org/web/20130310052146/http://columbia.github.com/linux-kvm-arm/ |archive-date=2013-03-10 |url-status=dead }}</ref>
| url = https://kernelnewbies.org/Linux_2_6_26#KVM_ported_to_IA64.2C_PPC_and_S390
| title = Linux_2_6_26
| at = 1.2. KVM ported to IA64, PPC and S390
| date = 2008-07-13
| access-date = 2025-08-23
| website = kernelnewbies.org}}</ref><ref>{{cite web |url=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b0c632db637d68ad39d9f97f452ce176253f5f4e |title=KVM: s390: arch backend for the kvm kernel module |date=2008-04-27}}</ref> [[PowerPC]],<ref name="2626notes" /> [[IA-64]],<ref name="2626notes" /> and [[ARM architecture|ARM]].<ref>{{cite web |url=https://systems.cs.columbia.edu/projects/kvm-arm/ |title=KVM/ARM: An Open-Source ARM Virtualization System}}</ref><ref>{{Cite web |url=https://columbia.github.com/linux-kvm-arm |title=KVM/ARM Open Source Project |access-date=2017-11-01 |archive-url=https://web.archive.org/web/20130310052146/http://columbia.github.com/linux-kvm-arm/ |archive-date=2013-03-10 |url-status=dead }}</ref><ref>{{Cite journal|url=https://dl.acm.org/doi/10.1145/2654822.2541946 | title = KVM/ARM: The Design and Implementation of the Linux ARM Hypervisor | author1 = Christoffer Dall | author2 = Jason Nieh | journal = SIGARCH Comput. Archit. News | publisher = ACM International Conference on Architectural Support for Programming Languages and Operating Systems | date = 2014| volume = 42 | issue = 1 | pages = 333–348 | doi = 10.1145/2654822.2541946 }}</ref>
The IA-64 port was removed in 2014.<ref>{{Cite web|url=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=003f7de6258900e17f6206e8e417d76c75ca549f | title=kernel/git/torvalds/linux.git: KVM: ia64: remove}}</ref>
 
KVM providessupports [[hardware-assisted virtualization]] for a wide variety of guest operating systems including Linux, [[BSD]], [[Solaris (operating system)|Solaris]], [[Microsoft Windows|Windows]], [[Haiku (operating system)|Haiku]], [[ReactOS]], [[Plan 9 from Bell Labs|Plan 9]], [[AROS Research Operating System|AROS]], [[macOS]], and even other Linux systems.<ref>{{cite web | url = http://www.linux-kvm.org/page/Guest_Support_Status | title = KVM wiki: Guest support status | accessdateaccess-date =2007-05-27 }}</ref> and [[macOS]].<ref>{{cite web|url=http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/|title=Running Mac OS X as a QEMU/KVM Guest|accessdateaccess-date=2014-08-20}}</ref> In addition, Android 2.2, [[GNU/Hurd]]<ref>{{cite web|url=https://www.gnu.org/software/hurd/hurd/status.html |title=status |publisher=Gnu.org |access-date= |accessdate=2014-02-12}}</ref> ([[Debian]] K16), [[MINIX 3|Minix]] 3.1.2a, Solaris 10 U3 and [[Darwin (operating system)|Darwin]] 8.0.1, together with other operating systems and some newer versions of these listed, are known to work with certain limitations.<ref>{{cite web|url=http://www.linux-kvm.org/page/Guest_Support_Status |title=Guest Support Status - KVM |publisher=Linux-kvm.org |access-date= |accessdate=2014-02-12}}</ref>
 
Additionally, KVM provides [[paravirtualization]] support for Linux, [[OpenBSD]],<ref>{{cite web |url=https://man.openbsd.org/virtio.4|title=OpenBSD man page virtio(4) |accessdateaccess-date=2018-02-04}}</ref> FreeBSD,<ref>{{cite web |url=http://people.freebsd.org/~kuriyama/virtio/|title=virtio binary packages for FreeBSD|accessdateaccess-date=2012-10-29}}</ref> [[NetBSD]],<ref>{{cite web |url=http://netbsd.gw.com/cgi-bin/man-cgi?virtio++NetBSD-current |title= NetBSD man page virtio(4) |accessdateaccess-date=2013-07-15 |archive-date=2019-11-13 |archive-url=https://web.archive.org/web/20191113035952/https://netbsd.gw.com/cgi-bin/man-cgi?virtio++NetBSD-current |url-status=dead }}</ref> Plan 9<ref>{{cite web |url=https://code.google.com/p/plan9front/wiki/qemu |title=plan9front |accessdateaccess-date=2013-02-11}}</ref> and Windows guests using the VirtIO [[API]].<ref>{{cite web |url=https://lwn.net/Articles/239238/ |title=An API for virtual I/O: virtio |date=2007-07-11 |accessdateaccess-date=2014-04-16 |publisher=[[LWN.net]]}}</ref> API. This includes a paravirtual [[Ethernet card]], disk I/O controller,<ref>{{cite web |url=http://linux-iscsi.org/wiki/vHost |title=SCSI target for KVM wiki |publisher=linux-iscsi.org |date=2012-08-07 |accessdateaccess-date=2012-08-12 |archive-date=2020-06-05 |archive-url=https://web.archive.org/web/20200605120413/http://linux-iscsi.org/wiki/VHost |url-status=dead }}</ref> [[balloon devicedriver]], and a [[VGA]] graphics interface using [[SPICE (protocol)|SPICE]] or [[VMware]] drivers.
 
==History==
[[Avi Kivity]] began the development of KVM in mid-2006 at [[Qumranet]], a technology [[startup company]]<ref>[http://kerneltrap.org/node/8088 Interview: Avi Kivity] {{webarchive|url=https://web.archive.org/web/20070426033902/http://kerneltrap.org/node/8088 |date=2007-04-26 }} on [[KernelTrap]]</ref> that was acquired by [[Red Hat]] in 2008.<ref>{{cite web
| url = http://www.redhat.com/en/about/press-releases/qumranet
| title = Red Hat Advances Virtualization Leadership with Qumranet, Inc. Acquisition
| date = 4 September 2008
| accessdateaccess-date = 16 June 2015
| publisher = [[Red Hat]]}}</ref>
 
KVM surfaced in October, 2006<ref>{{Cite web|url=https://www.itworldcanada.com/article/kvm-15-equipped-with-live-migration/7901|title=KVM 15 equipped with live migration &#124; IT World Canada News|date=7 March 2007}}</ref> and was merged into the Linux kernel mainline in kernel version 2.6.20, which was released on 5 February 2007.<ref name="2620notes" />
 
KVM is maintained by Paolo Bonzini.<ref>{{cite web
Line 46 ⟶ 53:
| title = Git Success Stories and Tips from KVM Maintainer Paolo Bonzini
| date = 7 April 2015
| accessdateaccess-date = 17 June 2015
| author = Libby Clark
| publisher = [[Linux.com]]
Line 59 ⟶ 66:
| title = KVM/QEMU Storage Stack Performance Discussion
| year = 2010
| accessdateaccess-date = January 3, 2015
| author1 = Khoa Huynh
| author2 = Stefan Hajnoczi
| publisher = Linux Plumbers Conference
| website = IBM
| format = PDF}}{{dead link
| date = January 2018
| bot = InternetArchiveBot
| fix-attempted = yes}}</ref>{{rp|3}}]]
 
KVM provides device abstraction but no processor emulation. It exposes the <tt>{{mono|/dev/kvm</tt>}} interface, which a user mode host can then use to:
* Set up the guest VM's address space. The host must also supply a firmware image (usually a custom BIOS when emulating PCs) that the guest can use to bootstrap into its main OS.
* Feed the guest simulated I/O.
* Map the guest's video display back onto the system host.
 
Originally, a forked version of [[QEMU]] was provided to launch guests and deal with hardware emulation that is not handled by the kernel. That support was eventually merged into the upstream project. There are now numerous Virtual Machine Monitors (VMMs) which can utilise the KVM interface including kvmtool, crosvm and [[Firecracker_(software)|Firecracker]] and numerous specialised VMMs built with frameworks such as rust-vmm.
On Linux, [[QEMU]] versions 0.10.1 and later is one such userspace host. QEMU uses KVM when available to virtualize guests at near-native speeds, but otherwise falls back to software-only emulation.
 
Internally, KVM uses [[SeaBIOS]] as an open source implementation of a 16-bit x86 [[BIOS]].<ref>{{cite web|url=http://www.seabios.org/SeaBIOS |title=SeaBIOS |publisher=seabios.org |date=2013-12-21 |accessdateaccess-date=2014-06-16}}</ref>
 
==Features==
KVM supportshas had support for [[Hot swapping|hot plugswappable vCPUs]],<ref>{{Cite web|url=https://access.redhat.com/articles/1339413|title=Hot Plugging Virtual CPUs with Red Hat Enterprise Virtualization Manager|date=16 February 2016 }}</ref> dynamic memory management,<ref>{{Cite web|url=https://www.linux-kvm.org/page/FAQ#Is_dynamic_memory_management_for_guests_supported.3F|title=Faq - KVM}}</ref> and [[Live Migration]] since February 2007.<ref>{{Cite web|url=https://lwn.net/Articles/223754/|title = KVM-15 release &#91;LWN.net&#93;}}</ref><ref>{{Cite web|url=https://www.linux-kvm.org/page/Migration|title = Migration - KVM}}</ref> It also reduces the impact that memory write -intensive workloadworkloads impactshave inon the migration process.<ref>{{Cite web|url=https://www.berrange.com/posts/2016/05/12/analysis-of-techniques-for-ensuring-migration-completion-with-kvm/|title=Daniel P. Berrangé » Blog Archive » Analysis of techniques for ensuring migration completion with KVM}}</ref>
 
==Emulated hardware==
{{Confusing|reason=previous sections says KVM does no emulate anything by itself, but this section lists emulated hardware. Some clarification from experts is welcome.|date=February 2019}}
 
KVM itself emulates very little hardware, instead deferring to a higher level client application such as [[QEMU]], crosvm, or [[Firecracker (software)|Firecracker]] for device emulation.
{| class="wikitable"
 
|-
KVM provides the following emulated devices:
! Class !! Device
 
|-
* Virtual [[CPU]] and memory<ref>{{cite web | url=https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-create-irqchip | title=The Definitive KVM (Kernel-based Virtual Machine) API Documentation — the Linux Kernel documentation }}</ref>
| [[Video card]] || Cirrus CLGD 5446 PCI VGA card, dummy VGA card with [[Bochs]] [[VESA]] extensions,<ref name=qemu-doc>[http://wiki.qemu.org/download/qemu-doc.html wiki.qemu.org – QEMU Emulator User Documentation], read 2010-05-06</ref> or [[Virgil (software)|Virgil]] as a virtual 3D GPU<ref>{{cite web|url=http://airlied.livejournal.com/77553.html |title=Introducing Virgil - 3D virtual GPU for qemu |date=2013-07-18 |url-status=dead |archiveurl=https://web.archive.org/web/20130725063318/http://airlied.livejournal.com/77553.html |archivedate=2013-07-25 }}</ref>
* VirtIO
|-
| [[PCI (bus)|PCI]] || [[Intel 440FX|i440FX]] host [[Conventional PCI#PCI bus bridges|PCI bridge]] and [[PIIX3]] PCI to ISA bridge<ref name=qemu-doc/>
|-
| [[Input device]] || [[PS/2 connector|PS/2]] Mouse and Keyboard<ref name=qemu-doc/>
|-
| [[Sound card]] || [[Sound Blaster 16]], ENSONIQ AudioPCI [[ES1370]], [[Gravis Ultrasound GF1]], CS4231A compatible<ref name=qemu-doc/>
|-
| [[Ethernet]] [[Network card]] || AMD Am79C970A ([[Am7990]]), E1000 (Intel 82540EM, 82573L, 82544GC), [[NE2000]], and Realtek [[RTL8139]]
|-
| [[Watchdog timer]] || Intel 6300ESB or IB700
|-
| [[Random-access memory|RAM]] || between 50&nbsp;MB and 32&nbsp;TB
|-
| [[Central processing unit|CPU]] || 1 – 160&nbsp;CPUs
|}
 
==Graphical management tools==
[[File:Libvirt support.svg|thumb|300px|[[libvirt]] supports KVM]]
 
* Mist {{snd}} an open source multi-cloud management platform. Mist allows users to manage KVM alongside VMware hypervisors, public & private clouds, containers and bare metal servers from a single pane of glass. Mist comes in three flavours, on-prem Community Edition (CE) <ref>https://github.com/mistio/mist-ce</ref>, on-prem Enterprise Edition (EE) and Mist-as-a-service (HS) <ref>https://mist.io</ref>. Mist CE is licensed under the Apache v2.0 license. Mist EE and Mist HS come with commercial licenses.
* [[Kimchi (software)|Kimchi]]{{snd}} web-based virtualization management tool for KVM
* [[Virtual Machine Manager]]{{snd}} supports creating, editing, starting, and stopping KVM-based virtual machines, as well as live or cold drag-and-drop migration of VMs between hosts.
* [[Proxmox Virtual Environment]]{{snd}} an open-source virtualization management package including KVM and [[LXC]]. It has a bare-metal installer, a web-based remote management GUI, a HA cluster stack, unified storage, flexible network, and optional commercial support.
* [[OpenQRM]]{{snd}} management platform for managing heterogeneous data center infrastructures.
* [[GNOME Boxes]]{{snd}} Gnome interface for managing libvirt guests on Linux.
* [[oVirt]]{{snd}} open-source virtualization management tool for KVM built on top of [[libvirt]]
 
==Licensing==
The kernel-mode component of KVM is a part of the [[Linux kernel]], itself licensed under [[GNU General Public License#Version 2|GNU General Public License, version 2]].<ref name="Linux_Licensing">{{Cite web|url=https://www.kernel.org/doc/html/latest/process/license-rules.html#kernel-licensing|title=Linux kernel licensing rules — The Linux Kernel documentation|website=www.kernel.org|access-date=2020-01-06|archive-date=7 March 2020|archive-url=https://web.archive.org/web/20200307065451/https://www.kernel.org/doc/html/latest/process/license-rules.html#kernel-licensing|url-status=live}}</ref>
KVM's parts are licensed under various GNU licenses:<ref>Licensing info from Ubuntu 7.04 <tt>/usr/share/doc/kvm/copyright</tt></ref>
* KVM kernel module: GPL v2
* KVM user module: LGPL v2
* QEMU virtual CPU core library (libqemu.a) and QEMU PC system emulator: LGPL
* Linux user mode QEMU emulator: GPL
* BIOS files (bios.bin, vgabios.bin and vgabios-cirrus.bin): LGPL v2 or later
 
==See also==
Line 130 ⟶ 116:
* [[CloudStack]]
* [[Comparison of platform virtualization software]]
* [[libvirtHyper-V]]
* [[Kernel same-page merging]] (KSM)
* [[Lguest]]
* [[libguestfs]]
* [[libvirt]]
* [[multipass]]
* [[Open Virtualization Alliance]]
* [[OpenNebula]]
* [[OpenStack]]
* [[oVirt]]
* [[Proxmox VE]]
* [[Red Hat Virtualization]]
* [[Vx32]]
Line 149 ⟶ 132:
 
==Bibliography==
* {{cite web|accessdateaccess-date=2017-02-10|title=Ten years of KVM|url=https://lwn.net/Articles/705160/|website=lwn.net|author=Amit Shah|date=2016-11-02}}
 
==External links==
* [http://public.dhe.ibm.com/software/dw/linux390/perf/ZSW03346USEN.pdf Best practices for the Kernel-based Virtual Machine] {{Webarchive|url=https://web.archive.org/web/20191106035557/http://public.dhe.ibm.com/software/dw/linux390/perf/ZSW03346USEN.pdf |date=2019-11-06 }}, IBM, second edition, April 2012
* {{Official website|www.linux-kvm.org}}
* [http://public.dhe.ibm.com/software/dw/linux390/perf/ZSW03346USEN.pdf Best practices for the Kernel-based Virtual Machine], IBM, second edition, April 2012
* [https://web.archive.org/web/20141021055601/http://www.linux-kvm.org/wiki/images/f/f9/2012-forum-virtio-blk-performance-improvement.pdf Virtio-blk Performance Improvement], KVM Forum 2012, November 8, 2012, by Asias He
* [https://web.archive.org/web/20101128114720/http://qemu-buch.de/e/Content Wikibook QEMU & KVM]
* [https://chromium.googlesource.com/chromiumos/platform/crosvm/ crosvm - Chrome OS virtual machine monitor]
* [https://firecracker-microvm.github.io/ Firecracker VMM for KVM]
 
{{Virtualization products}}
Line 168 ⟶ 152:
[[Category:Linux kernel features]]
[[Category:Virtualization software]]
[[Category:Virtualization-related software for Linux]]
[[Category:Red Hat software]]