Difference between revisions of "Compiling Xen"

From Xen
(Split off stuff from Fedora13Xen4 Tutorial)
 
Line 1: Line 1:
 
This document currently assumes you are using Fedora/RHEL/CentOS to do the compilation. For other distributions (ie. Ubuntu/Debian), you'll need to use the respective package management software to get the packages.
 
This document currently assumes you are using Fedora/RHEL/CentOS to do the compilation. For other distributions (ie. Ubuntu/Debian), you'll need to use the respective package management software to get the packages.
  +
== Compiling Xen from source - Getting ready ==
== Installing packages required for compiling Xen from sources ==
 
  +
First of all, you have to get the Xen source. You have two options for this, which we’ll deal with in a bit.
For more information about installing Xen 4.0 from sources please see [[Xen4.0]] wiki page.
 
   
  +
Whichever you choose, to actually build from source, you’ll need to download the compilers and such. To do so, run
Install required development tools and libraries:
 
   
<pre><nowiki>
+
<pre>
# yum groupinstall "Development Libraries"
+
# yum groupinstall "Development Libraries" "Development Tools"
  +
# yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial glibc-devel.i686
# yum groupinstall "Development Tools"
 
</nowiki></pre>
+
</pre>
   
  +
It’ll take some time, since there’s ~200MB to download, not including the time to extract, install & configure everything. But, once yum’s got everything installed, you can compile Xen from the source code.
At the time of writing these downloads were around 100 MB and 105 MB in size.
 
 
Then install some additional packages required for building Xen from sources and running it:
 
 
<pre><nowiki>
 
# yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial
 
</nowiki></pre>
 
 
At the time of writing these downloads were around 98 MB in size.
 
 
You also need to install 32bit version of glibc-devel, it's required as well:
 
 
<pre><nowiki>
 
# yum install glibc-devel.i686</nowiki></pre>
 
 
Now all the required packages are installed and you can move forward.
 
   
 
== Building Xen rpm binaries from src.rpm source package ==
 
== Building Xen rpm binaries from src.rpm source package ==
Line 39: Line 24:
   
 
Then rebuild the source package to generate binary rpms:
 
Then rebuild the source package to generate binary rpms:
 
   
 
<pre><nowiki>
 
<pre><nowiki>
# cd /root/rpmbuild/SPECS
+
# cd rpmbuild/SPECS
 
# rpmbuild -bb xen.spec
 
# rpmbuild -bb xen.spec
 
</nowiki></pre>
 
</nowiki></pre>
   
 
After a while when the build process finishes you should see output like:
 
After a while when the build process finishes you should see output like:
 
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 75: Line 58:
 
8:xen-debuginfo ########################################### [100%]
 
8:xen-debuginfo ########################################### [100%]
 
</nowiki></pre>
 
</nowiki></pre>
  +
== Compiling Xen from the source repo ==
  +
  +
The second option is getting the latest and greatest source straight from the [http://xenbits.xen.org/hg/ Xen code repos]. The [[Xen 4.0|Xen4.0]] wiki page has more info on building from source.
  +
  +
Select the appropriate repository from the list of Xen repositories. In practice, you’ll probably want the latest stable branch, though you can choose the development branch or any of the historical branches. At this moment, the latest stable branch is 4.1, so that’ll be used.
  +
  +
Xen uses Mercurial for source control. So the command to pull the latest revision is simply
  +
  +
<pre>hg clone http://xenbits.xen.org/<repo name></pre>
  +
  +
For the 4.1 stable branch, the command is
  +
  +
<pre>hg clone http://xenbits.xen.org/xen-4.1-testing.hg</pre>
  +
  +
And wait for the download to finish. It’ll create a folder named after the repository name, so change to the directory
  +
  +
<pre>cd xen-4.1-testing.hg</pre>
  +
  +
Then, to compile Xen, run
  +
  +
<pre>make xen && make tools && make stubdom</pre>
  +
  +
And watch your screen fill with status messages. Do note that this step requires Internet access to pull the latest source code from repositories like xen-tools. If you don’t have Internet access, this will fail.
  +
  +
Finally, do
  +
  +
<pre>make install xen && make install tools PYTHON_PREFIX_ARG= && make install stubdom</pre>
  +
  +
to actually install Xen.
  +
  +
== Checking that Xen's actually installed ==
  +
The quick-and-dirty way to check is to look in /boot for xen.gz, and check that the folder /etc/xen exists. If both are present, chances are Xen is installed correctly, though you should still check by booting into Xen and running <pre>xl info</pre>.
  +
  +
If it prints something like
  +
<pre>
  +
system : Linux
  +
host : Fedora
  +
xen_release : 4.0.2
  +
xen_compile_by : root@localdomain
  +
xen_compiler : gcc version 3.3.5
  +
</pre> then Xen has been installed successfully and is working. You can now go ahead and start/create domUs.
 
[[Category:Developers]]
 
[[Category:Developers]]

Revision as of 06:14, 8 November 2011

This document currently assumes you are using Fedora/RHEL/CentOS to do the compilation. For other distributions (ie. Ubuntu/Debian), you'll need to use the respective package management software to get the packages.

Compiling Xen from source - Getting ready

First of all, you have to get the Xen source. You have two options for this, which we’ll deal with in a bit.

Whichever you choose, to actually build from source, you’ll need to download the compilers and such. To do so, run

# yum groupinstall "Development Libraries" "Development Tools"
# yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial glibc-devel.i686

It’ll take some time, since there’s ~200MB to download, not including the time to extract, install & configure everything. But, once yum’s got everything installed, you can compile Xen from the source code.

Building Xen rpm binaries from src.rpm source package

You can get the xen src.rpm source package from Fedora koji.

For the purposes of this tutorial, we're using Fedora's Xen 4.0.1-6 rpm, which contains some backported bugfixes from Xen 4.0.2.

Download and install the src.rpm source package:

# wget http://pasik.reaktio.net/fedora/xen-4.0.1-6.fc14.src.rpm
# rpm -i xen-4.0.1-6.fc14.src.rpm

Then rebuild the source package to generate binary rpms:

# cd rpmbuild/SPECS
# rpmbuild -bb xen.spec

After a while when the build process finishes you should see output like:

Wrote: /root/rpmbuild/RPMS/x86_64/xen-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-libs-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-runtime-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-hypervisor-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-doc-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-devel-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-licenses-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-debuginfo-4.0.1-6.fc13.x86_64.rpm

Install the newly built rpms: (Note: This assumes you have already satisfied the dependencies for installing Xen)

# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh *4.0.1-6*.rpm
Preparing...                ########################################### [100%]
   1:xen-licenses           ########################################### [ 13%]
   2:xen-libs               ########################################### [ 25%]
   3:xen-hypervisor         ########################################### [ 38%]
   4:xen-runtime            ########################################### [ 50%]
   5:xen                    ########################################### [ 63%]
   6:xen-devel              ########################################### [ 75%]
   7:xen-doc                ########################################### [ 88%]
   8:xen-debuginfo          ########################################### [100%]

Compiling Xen from the source repo

The second option is getting the latest and greatest source straight from the Xen code repos. The Xen4.0 wiki page has more info on building from source.

Select the appropriate repository from the list of Xen repositories. In practice, you’ll probably want the latest stable branch, though you can choose the development branch or any of the historical branches. At this moment, the latest stable branch is 4.1, so that’ll be used.

Xen uses Mercurial for source control. So the command to pull the latest revision is simply

hg clone http://xenbits.xen.org/<repo name>

For the 4.1 stable branch, the command is

hg clone http://xenbits.xen.org/xen-4.1-testing.hg

And wait for the download to finish. It’ll create a folder named after the repository name, so change to the directory

cd xen-4.1-testing.hg

Then, to compile Xen, run

make xen && make tools && make stubdom

And watch your screen fill with status messages. Do note that this step requires Internet access to pull the latest source code from repositories like xen-tools. If you don’t have Internet access, this will fail.

Finally, do

make install xen && make install tools PYTHON_PREFIX_ARG= && make install stubdom

to actually install Xen.

Checking that Xen's actually installed

The quick-and-dirty way to check is to look in /boot for xen.gz, and check that the folder /etc/xen exists. If both are present, chances are Xen is installed correctly, though you should still check by booting into Xen and running

xl info

.

If it prints something like

system                 : Linux
host                   : Fedora
xen_release            : 4.0.2
xen_compile_by         : root@localdomain
xen_compiler           : gcc version 3.3.5 

then Xen has been installed successfully and is working. You can now go ahead and start/create domUs.