Code: Difference between revisions

From KVM
No edit summary
m (Remove not relevant category)
(18 intermediate revisions by 12 users not shown)
Line 1: Line 1:
=Code=
=Code=


[[Category:Architechture]]
== kernel git tree ==
== kernel git tree ==
The kvm kernel code is available through a git tree.  To create a repository using git, type


  git clone git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git
The kvm kernel code is available through a git tree (like the kernel itself).  To create a repository using git, type
 
  git clone git://git.kernel.org/pub/scm/virt/kvm/kvm.git


Alternatively, it is also accessible through the kernel.org gitweb interface:               
Alternatively, it is also accessible through the kernel.org gitweb interface:               
[http://git.kernel.org/?p=linux/kernel/git/avi/kvm.git;a=summary]
[http://git.kernel.org/?p=virt/kvm/kvm.git;a=summary]


For subsequent upgrades use the command
For subsequent upgrades use the command
                                        
                                        
  git-pull
  git pull
in the git working dir.
 
in the git working directory.
 
== kernel git workflow ==
 
See [[Kvm-Git-Workflow]]


== userspace git tree ==
== userspace git tree ==
The kvm userspace code (libkvm and qemu) is available through a git tree. To create a repository using git, type
 
As of QEMU 1.3, the KVM userspace code is in mainline QEMU.  Please use and develop with
 
git clone git://git.qemu-project.org/qemu.git
 
'''If you want to contribute code''', please see the [http://wiki.qemu.org/Contribute/StartHere guidelines] and submit patches to qemu-devel@nongnu.org.
 
The old qemu-kvm.git fork repository is still available but outdated, type
                                                                                        
                                                                                        
  git clone git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git
  git clone git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git


Alternatively, it is also accessible through the kernel.org gitweb interface:         
Alternatively, it is also accessible through the kernel.org gitweb interface:         
[http://git.kernel.org/?p=virt/kvm/kvm-userspace.git;a=summary]
[http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=summary]
 
== linux guest drivers kit ==
This kit converts a virtio-capable kernel into a package that can generate linux guest drivers for older kernels.                                                                                               
 
git clone git://git.kernel.org/pub/scm/virt/kvm/kvm-guest-drivers-linux.git


The corresponding kernel tree can found in the <code>virtio</code> branch of <code>kvm.git</code>.


== building an external module with older kernels ==
== building an external module with older kernels ==
Line 35: Line 41:


1. If you wish to use a distribution kernel (or just some random kernel you like) with kvm,
1. If you wish to use a distribution kernel (or just some random kernel you like) with kvm,
you can get both the userspace and kernel (via git)In the userspace                 
you can use the external module kitYou will need the kvm-kmod repository:
toplevel directory, type:
 
                                                                                       
git clone git://git.kiszka.org/kvm-kmod.git
cd kvm-kmod
git submodule update --init
  ./configure [--kerneldir=/path/to/kernel/dir]
  ./configure [--kerneldir=/path/to/kernel/dir]
make sync
make
=== Tip about building against Red Hat Enterprise Linux kernels ===


2. If you are using a released kvm-XX.tar.gz, skip to step 3. If you got the source from git, you need to run the following commands:
<code>kvm-userspace/kernel</code> has some compat code to allow it to compile against older kernels, and also some code specific to features that are normally not present on older kernels but are present on RHEL kernels.


cd kernel
So, when building against a RHEL kernel tree, check if the <code>RHEL_*</code> macros at <code>${kerneldir}/include/linux/version.h</code> are defined correctly, corresponding to the RHEL version where the kernel source comes from. If those macros aren't defined correctly, the compat code that allows compilation against RHEL kernels will break and you will get build errors.
make sync LINUX=/path/to/kvm/git/tree
cd ..


3. Finally, build KVM and the KVM modules:


make
== release tags ==


kvm stable releases (based off of Qemu's stable branch) are tagged with <code>kvm-qemu-0.NN.N</code> where ''N'' equates to the upstream Qemu branch versions. Note that kvm has them tagged not branched.


There are three important directories in this scenario:
kvm development releases are tagged with <code>kvm-nn</code> where ''nn'' is the release number.
{|border=1
! kvm-userspace
| Contains a <code>kernel</code> subdirectory. If you got the source from git, it needs to be populated with files from the kvm.git repository (using <code>make sync</code>).
|-
! host kernel tree
| Older kernel you want to use newer KVM modules with. Refer to it with <code>configure --kerneldir</code>.
You need to point to a '''configured''' kernel source tree corresponding to the kernel you are building modules for. The default is to look for the sources of the running kernel at <code>/lib/modules/`uname -r`/build</code>.
|-
! kvm kernel tree (from git)
| A clone of the kvm.git repository. Used as the source of the KVM modules. Refer to it with <code>LINUX=path</code> in <code>make sync</code>.
|}


=== Tip about building against Red Hat Enterprise Linux kernels ===
== Binary Packages ==


<code>kvm-userspace/kernel</code> has some compat code to allow it to compile against older kernels, and also some code specific to features that are normally not present on older kernels but are present on RHEL kernels.
=== CentOS / RHEL ===


So, when building against a RHEL kernel tree, check if the </code>RHEL_*</code> macros at <code>${kerneldir}/include/linux/version.h</code> are defined correctly, corresponding to the RHEL version where the kernel source comes from. If those macros aren't defined correctly, the compat code that allows compilation against RHEL kernels will break and you will get build errors.
Unofficial packages of latest releases can be found at:
<code>http://www.lfarkas.org/linux/packages/centos/5/</code>


=== Debian ===


== release tags ==
For Debian Lenny, please use packages from backports.debian.org - for <em>both</em> qemu-kvm and kernel (at least 2.6.32).  It is important to use more recent kernel - 2.6.26 does not work well with kvm.


kvm releases are tagged with <code>kvm-nn</code> where ''nn'' is the release number.
Note that package "kvm" has been renamed to "qemu-kvm" in Squeeze and in Lenny backports (and kvm is now transitional package that installs qemu-kvm automatically).


== Binary Packages ==
Debian Squeeze will have qemu-kvm based on 0.12, available in standard repositories.
=== CentOS / RHEL ===


Unofficial packages of latest releases can be found at
Experimental 0.13 packages are available at  
http://www.lfarkas.org/linux/packages/centos/5/
<code>http://www.corpit.ru/debian/tls/kvm/0.13/</code> , pending upload to debian -experimental.


== nightly snapshots ==
== nightly snapshots ==


Nightly snapshots, for those who are uncomfortable with git, are [http://people.qumranet.com/avi/snapshots available].  When reporting a problem with a snapshot, please quote the snapshot name (which includes the date) and the contents of the SOURCES file in the snapshot tarball.
Nightly snapshots, for those who are uncomfortable with git, are [http://people.qumranet.com/avi/snapshots available].  When reporting a problem with a snapshot, please quote the snapshot name (which includes the date) and the contents of the SOURCES file in the snapshot tarball.
[[Category:Docs]][[Category:HowTo]]

Revision as of 16:45, 16 May 2015

Code

kernel git tree

The kvm kernel code is available through a git tree (like the kernel itself). To create a repository using git, type

git clone git://git.kernel.org/pub/scm/virt/kvm/kvm.git

Alternatively, it is also accessible through the kernel.org gitweb interface: [1]

For subsequent upgrades use the command

git pull

in the git working directory.

kernel git workflow

See Kvm-Git-Workflow

userspace git tree

As of QEMU 1.3, the KVM userspace code is in mainline QEMU. Please use and develop with

git clone git://git.qemu-project.org/qemu.git

If you want to contribute code, please see the guidelines and submit patches to qemu-devel@nongnu.org.

The old qemu-kvm.git fork repository is still available but outdated, type

git clone git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git

Alternatively, it is also accessible through the kernel.org gitweb interface: [2]


building an external module with older kernels

This only works for the x86 architecture.

1. If you wish to use a distribution kernel (or just some random kernel you like) with kvm, you can use the external module kit. You will need the kvm-kmod repository:

git clone git://git.kiszka.org/kvm-kmod.git
cd kvm-kmod
git submodule update --init
./configure [--kerneldir=/path/to/kernel/dir]
make sync
make

Tip about building against Red Hat Enterprise Linux kernels

kvm-userspace/kernel has some compat code to allow it to compile against older kernels, and also some code specific to features that are normally not present on older kernels but are present on RHEL kernels.

So, when building against a RHEL kernel tree, check if the RHEL_* macros at ${kerneldir}/include/linux/version.h are defined correctly, corresponding to the RHEL version where the kernel source comes from. If those macros aren't defined correctly, the compat code that allows compilation against RHEL kernels will break and you will get build errors.


release tags

kvm stable releases (based off of Qemu's stable branch) are tagged with kvm-qemu-0.NN.N where N equates to the upstream Qemu branch versions. Note that kvm has them tagged not branched.

kvm development releases are tagged with kvm-nn where nn is the release number.

Binary Packages

CentOS / RHEL

Unofficial packages of latest releases can be found at: http://www.lfarkas.org/linux/packages/centos/5/

Debian

For Debian Lenny, please use packages from backports.debian.org - for both qemu-kvm and kernel (at least 2.6.32). It is important to use more recent kernel - 2.6.26 does not work well with kvm.

Note that package "kvm" has been renamed to "qemu-kvm" in Squeeze and in Lenny backports (and kvm is now transitional package that installs qemu-kvm automatically).

Debian Squeeze will have qemu-kvm based on 0.12, available in standard repositories.

Experimental 0.13 packages are available at http://www.corpit.ru/debian/tls/kvm/0.13/ , pending upload to debian -experimental.

nightly snapshots

Nightly snapshots, for those who are uncomfortable with git, are available. When reporting a problem with a snapshot, please quote the snapshot name (which includes the date) and the contents of the SOURCES file in the snapshot tarball.