1 2Compiling Xen from source 3 4* Overview 5* Options recognized by configure 6* Variables recognized by make 7* Systemd support 8* History of options 9* Examples 10 11Overview 12======== 13 14The xen source contains four subsystems: xen, tools, stubdom and docs. 15All but xen have to be prepared for build with a configure script in the 16toplevel directory. configure recognizes certain arguments and 17environment variables which are used to adjust various aspects of the 18following compile process. Once configure is done, make(1) has to be 19called. Also make(1) recognizes certain arguments. The following sections 20will give an overview. 21 22Xen Hypervisor 23============== 24 25Xen itself is configured via a `kconfig' system borrowed from Linux. 26See docs/misc/kconfig.txt. 27 28Note that unlike with Linux, and contrary to that document, you cannot 29look at Kconfig files, or the default or generated config files etc., 30to find available configuration options. This is because it is only 31supported (and security supported) by the Xen Project, to change a 32small subset of the options. Attempts to change other options will be 33silently overridden. The only way to find which configuration options 34are available is to run `make menuconfig' or the like. 35 36You can counter-override this behaviour by setting XEN_CONFIG_EXPERT=y 37in your environment. However, doing this is not supported and the 38resulting configurations do not receive security support. If you set 39this variable there is nothing stopping you setting dangerously 40experimental combinations of features - not even any warnings. 41 42Options recognized by configure 43=============================== 44 45The configure script in the toplevel directory will recognize these 46options. It will pass them to the configure scripts in the tools, 47stubdom, and docs directory. 48 49Individual subsystems can be selected by one of the following options. 50Please note that stubdom requires tools. 51 --disable-xen 52 --disable-tools 53 --enable-stubdom 54 --disable-docs 55 56The well known GNU configure options to specify the target directories. 57Some components of these paths will be compiled into the binaries. 58Note: prefix defaults to /usr/local, sysconfdir defaults to /etc, 59localstatedir defaults to /var. 60 --prefix=DIR 61 --libdir=DIR 62 --libexecdir=BASEDIR 63 --bindir=DIR 64 --sbindir=DIR 65 --sysconfdir=DIR 66 --sharedstatedir=DIR 67 --localstatedir=DIR 68 --includedir=DIR 69 --datarootdir=DIR 70 --datadir=DIR 71 --mandir=DIR 72 --docdir=DIR 73 74To automatically run the toolstack in dom0 during system startup some 75sysv runlevel scripts are installed. This option allows to set the path 76for a given system. Possible values are /etc/init.d, /etc/rc.d/init.d or 77/etc/rc.d. If not specified configure tries to guess the path. 78 --with-initddir=DIR 79 80The runlevel scripts load certain configuration files. They are 81typically located in a subdirectory of /etc. Possible values are this 82subdirectory are "sysconfig" or "default". If not specified configure 83tries to guess the subdir. 84 --with-sysconfig-leaf-dir=SUBDIR 85 86If the tools are configured with a non-standard --prefix the runtime 87linker will either not find the required libraries or it will load them 88from a wrong location. Compiling the tools with rpath will force the 89linker to look in the correct location. 90 --enable-rpath 91 92During build in a git checkout the buildsystem needs to download 93additional tools such as qemu. This is done with either the native git 94protocol, or via http if this option is enabled. 95 --enable-githttp 96 97Disable xenstat and xentop monitoring tools. 98 --disable-monitors 99 100Disable build of certain ocaml libraries and tools. To actually build 101them ocaml development packages must be installed. If they are missing 102configure will automatically disable this option. 103 --disable-ocamltools 104 105Disable XSM policy compilation. 106 --disable-xsmpolicy 107 108Attempt to build of an OVMF firmware binary. This requires special 109versions of development tools. Use at your own risk. 110 --enable-ovmf 111 112Use the given OVMF binary instead of compiling a private copy. 113 --with-system-ovmf=PATH 114 115Build a private copy of SeaBIOS. 116 --disable-seabios 117 118Use the given SeaBIOS binary instead of compiling a private copy. 119 --with-system-seabios=PATH 120 121Build the old qemu used by xm/xend. This is required if existing domUs 122should be migrated to this host, or if existing domU snapshots should be 123started with this version of the tools. Only if all domUs used the new 124upstream qemu during initial start it is safe to disable this option. 125The old qemu requires rombios, which can be disable along with 126qemu-traditional. 127 --enable-qemu-traditional 128 --enable-rombios 129 130The libxl toolstack uses the upstream qemu per default. A private copy 131will be built. If desired this private copy can be configured with 132additional options passed to its configure script. 133 --with-extra-qemuu-configure-args="arg1 arg2" 134 135Use the given qemu binary instead of compiling a private copy. 136 --with-system-qemu=PATH 137 138A dom0 requires a set of backend drivers. The configure script already 139supplies a list of known drivers which are automatically loaded in dom0. 140This internal list can be changed with this option. 141 --with-linux-backend-modules="kmod1 kmod2" 142 143Two variants of a xenstored exist: the original xenstored written in C 144(xenstored) or the newer and robust one written in Ocaml (oxenstored). 145The oxenstored daemon is the default but can only be used if the 146required ocaml packages are installed. In case they are missing the 147original xenstored will be used. Valid names are xenstored and 148oxenstored. 149 --with-xenstored=name 150 151The path where to store core dumps for domUs which are configured with 152coredump-destroy or coredump-restart can be specified with this option. 153 --with-xen-dumpdir=DIR 154 155Instead of starting the tools in dom0 with sysv runlevel scripts they 156can also be started by systemd. If this option is enabled xenstored will 157receive the communication socked directly from systemd. So starting it 158manually will not work anymore. The paths to systemd internals can also 159be changed in case the default paths do not fit anymore. 160NOTE: if systemd development packages are installed the systemd support 161will be the enabled per default. Using --disable-systemd will override 162this detection and the sysv runlevel scripts have to be used. 163 --enable-systemd 164 --with-systemd=DIR 165 --with-systemd-modules-load=DIR 166 167Build various stubom components, some are only example code. Its usually 168enough to specify just --enable-stubdom and leave these options alone. 169 --enable-ioemu-stubdom 170 --enable-c-stubdom 171 --enable-caml-stubdom 172 --disable-pv-grub 173 --disable-xenstore-stubdom 174 --enable-vtpm-stubdom 175 --enable-vtpmmgr-stubdom 176 --disable-extfiles 177 178Per default some parts of the tools code will print additional runtime 179debug. This option can be used to disable such code paths. 180 --disable-debug 181 182The configure script recognizes also many environment variables. Calling 183the individual configure scripts in the subdirectories with the "--help" 184option will list these environment variables. 185 186Variables recognized by make 187========================== 188 189The following variables are recognized by the build system. They have to 190be passed as make options, like 'make variable=value'. Having these 191variables in the environment, like 'env variable=value make', will not 192work for most of them. 193 194In addition to pass variables as make options it is also supported to 195create a ".config" file in the toplevel directory. The file will be 196sourced by make(1). 197 198The well known variable to specify an offset during make install, 199useful for packaging. 200DESTDIR= 201 202Per default some parts of the tools code will print additional runtime 203debug. This option can be used to disable such code paths. 204debug=y 205debug_symbols=y 206 207If --prefix= was used during configure the and ocaml was enabled the 208resulting libraries will not be installed in the specified path. Instead 209the path provided by ocamlfind(1) will be used. This variable can be 210used to override this path. Using the environment variable 211OCAMLFIND_DESTDIR= and OCAMLFIND_METADIR= will have the same effect. 212OCAMLDESTDIR= 213 214The xen subsystem will install the hypervisor into fixed locations. 215BOOT_DIR defaults to /boot, DEBUG_DIR defaults to /usr/lib/debug and 216EFI_DIR to /usr/lib64/efi. 217BOOT_DIR= 218DEBUG_DIR= 219EFI_DIR= 220 221The make target 'rpmball' will build a xen.rpm. This variable can be 222used to append a custom string to the name. In addition a string can be 223appended to the rpm Release: tag. 224PKG_SUFFIX= 225PKG_RELEASE= 226 227The hypervisor will report a certain version string. This variable can 228be used to append a custom string to the version. 229XEN_VENDORVERSION= 230 231During boot xen will report a certain user@host string, which can be 232changed with these variables. 233XEN_WHOAMI= 234XEN_DOMAIN= 235 236Some components of xen and tools will include an unpredictable timestamp 237into the binaries. To allow reproducible builds the following variables 238can be used to provide fixed timestamps in the expected format. 239XEN_BUILD_DATE=<output of date(1)> 240XEN_BUILD_TIME=hh:mm:ss 241SMBIOS_REL_DATE=mm/dd/yyyy 242VGABIOS_REL_DATE="dd Mon yyyy" 243 244This variable can be used to point to a different git binary to be used. 245GIT= 246 247During tools build external repos will be cloned into the source tree. 248During stubdom build external packages will be downloaded into the 249source tree. These variables can be used to point to a different 250locations. 251XEN_EXTFILES_URL= 252OVMF_UPSTREAM_URL= 253QEMU_UPSTREAM_URL= 254QEMU_TRADITIONAL_URL= 255SEABIOS_UPSTREAM_URL= 256MINIOS_UPSTREAM_URL= 257 258Using additional CFLAGS to build tools which will run in dom0 is 259required when building distro packages. These variables can be used to 260pass RPM_OPT_FLAGS. 261EXTRA_CFLAGS_XEN_TOOLS= 262EXTRA_CFLAGS_QEMU_TRADITIONAL= 263EXTRA_CFLAGS_QEMU_XEN= 264 265Additional CFLAGS may be supplied to the build of the hypervisor by 266using this variable. 267EXTRA_CFLAGS_XEN_CORE= 268 269This variable can be used to use DIR/include and DIR/lib during build. 270This is the same as PREPEND_LIB and PREPEND_INCLUDES. APPEND_LIB and 271APPEND_INCLUDES= will be appended to the CFLAGS/LDFLAGS variable. 272EXTRA_PREFIX=DIR 273PREPEND_LIB=DIR 274PREPEND_INCLUDES=DIR 275APPEND_LIB=DIR 276APPEND_INCLUDES=DIR 277 278While the tools build will set the path to the python binary with the 279configure script, the hypervisor build has to use this variable to use a 280different python binary. 281PYTHON= 282 283Building the python tools may fail unless certain options are passed to 284setup.py. Config.mk contains additional info how to use this variable. 285PYTHON_PREFIX_ARG= 286 287The hypervisor may be built with XSM/Flask support, which can be changed 288by running: 289make -C xen menuconfig 290and enabling XSM/Flask in the 'Common Features' menu. A security policy 291is required to use XSM/Flask; if the SELinux policy compiler is 292available, the policy from tools can be included in the hypervisor. 293This option is enabled by default if XSM is enabled and the compiler 294(checkpolicy) is found. The location of this executable can be set 295using the environment variable. 296CHECKPOLICY= 297 298Use clang instead of GCC. 299clang=y 300 301 302Systemd support 303=============== 304 305If the systemd development packages are available then the support for 306systemd will be enabled per default. It is required to manually enable 307the installed systemd service files. Systemd has dependency tracking, 308which means all dependencies will be started automatically: 309 310systemctl enable xen-qemu-dom0-disk-backend.service 311systemctl enable xen-init-dom0.service 312systemctl enable xenconsoled.service 313 314Other optional services are: 315systemctl enable xendomains.service 316systemctl enable xen-watchdog.service 317 318 319QEMU Deprivilege 320================ 321It is recommended to run QEMU as non-root. 322See docs/misc/qemu-deprivilege.txt for an explanation on what you need 323to do at installation time to run QEMU as a dedicated user. 324 325 326History of options 327================== 328 329Prior to xen-4.5 configure recognized essentially only the --prefix= and 330--libdir= option to specify target directories. Starting with xen-4.5 331all paths can be adjusted once with configure. 332 333 334Examples 335======== 336 337* To build a private copy of tools and xen: 338configure --prefix=/odd/path --sysconfdir=/odd/path/etc --enable-rpath 339make 340sudo make install BOOT_DIR=/ood/path/boot EFI_DIR=/odd/path/efi 341 342 343* Use configure and make to build a distro rpm package (it is required 344 to unset variables set by the rpm configure macro): 345%build 346export WGET=$(type -P false) 347export GIT=$(type -P false) 348export EXTRA_CFLAGS_XEN_TOOLS="$RPM_OPT_FLAGS" 349export EXTRA_CFLAGS_QEMU_TRADITIONAL="$RPM_OPT_FLAGS" 350export EXTRA_CFLAGS_QEMU_XEN="$RPM_OPT_FLAGS" 351%configure \ 352 --with-initddir=%{_initddir} 353unset CFLAGS CXXFLAGS FFLAGS LDFLAGS 354make 355%install 356make install \ 357 SYSCONFIG_DIR=/var/adm/fillup-templates \ 358 DESTDIR=$RPM_BUILD_ROOT 359 360 361* To build xen and tools using a cross compiler: 362./configure --build=x86_64-unknown-linux-gnu --host=aarch64-linux-gnu 363make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- 364make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \ 365 DESTDIR=/some/path install 366 367 368 369# vim: tw=72 et 370