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 92Disable xenstat and xentop monitoring tools. 93 --disable-monitors 94 95Disable build of certain ocaml libraries and tools. To actually build 96them ocaml development packages must be installed. If they are missing 97configure will automatically disable this option. 98 --disable-ocamltools 99 100Disable XSM policy compilation. 101 --disable-xsmpolicy 102 103Attempt to build of an OVMF firmware binary. This requires special 104versions of development tools. Use at your own risk. 105 --enable-ovmf 106 107Use the given OVMF binary instead of compiling a private copy. 108 --with-system-ovmf=PATH 109 110Build a private copy of SeaBIOS. 111 --disable-seabios 112 113Use the given SeaBIOS binary instead of compiling a private copy. 114 --with-system-seabios=PATH 115 116Build the old qemu used by xm/xend. This is required if existing domUs 117should be migrated to this host, or if existing domU snapshots should be 118started with this version of the tools. Only if all domUs used the new 119upstream qemu during initial start it is safe to disable this option. 120The old qemu requires rombios, which can be disable along with 121qemu-traditional. 122 --enable-qemu-traditional 123 --enable-rombios 124 125The libxl toolstack uses the upstream qemu per default. A private copy 126will be built. If desired this private copy can be configured with 127additional options passed to its configure script. 128 --with-extra-qemuu-configure-args="arg1 arg2" 129 130Use the given qemu binary instead of compiling a private copy. 131 --with-system-qemu=PATH 132 133A dom0 requires a set of backend drivers. The configure script already 134supplies a list of known drivers which are automatically loaded in dom0. 135This internal list can be changed with this option. 136 --with-linux-backend-modules="kmod1 kmod2" 137 138Two variants of a xenstored exist: the original xenstored written in C 139(xenstored) or the newer and robust one written in Ocaml (oxenstored). 140The oxenstored daemon is the default but can only be used if the 141required ocaml packages are installed. In case they are missing the 142original xenstored will be used. Valid names are xenstored and 143oxenstored. 144 --with-xenstored=name 145 146The path where to store core dumps for domUs which are configured with 147coredump-destroy or coredump-restart can be specified with this option. 148 --with-xen-dumpdir=DIR 149 150Instead of starting the tools in dom0 with sysv runlevel scripts they 151can also be started by systemd. If this option is enabled xenstored will 152receive the communication socked directly from systemd. So starting it 153manually will not work anymore. The paths to systemd internals can also 154be changed in case the default paths do not fit anymore. 155NOTE: if systemd development packages are installed the systemd support 156will be the enabled per default. Using --disable-systemd will override 157this detection and the sysv runlevel scripts have to be used. 158 --enable-systemd 159 --with-systemd=DIR 160 --with-systemd-modules-load=DIR 161 162Build various stubom components, some are only example code. Its usually 163enough to specify just --enable-stubdom and leave these options alone. 164 --enable-ioemu-stubdom 165 --enable-c-stubdom 166 --disable-pv-grub 167 --disable-xenstore-stubdom 168 --enable-vtpm-stubdom 169 --enable-vtpmmgr-stubdom 170 --disable-extfiles 171 172Per default some parts of the tools code will print additional runtime 173debug. This option can be used to disable such code paths. 174 --disable-debug 175 176The configure script recognizes also many environment variables. Calling 177the individual configure scripts in the subdirectories with the "--help" 178option will list these environment variables. 179 180Variables recognized by make 181========================== 182 183The following variables are recognized by the build system. They have to 184be passed as make options, like 'make variable=value'. Having these 185variables in the environment, like 'env variable=value make', will not 186work for most of them. 187 188In addition to pass variables as make options it is also supported to 189create a ".config" file in the toplevel directory. The file will be 190sourced by make(1). 191 192The well known variable to specify an offset during make install, 193useful for packaging. 194DESTDIR= 195 196Per default some parts of the tools code will print additional runtime 197debug. This option can be used to disable such code paths. 198debug=y 199debug_symbols=y 200 201If --prefix= was used during configure the and ocaml was enabled the 202resulting libraries will not be installed in the specified path. Instead 203the path provided by ocamlfind(1) will be used. This variable can be 204used to override this path. Using the environment variable 205OCAMLFIND_DESTDIR= and OCAMLFIND_METADIR= will have the same effect. 206OCAMLDESTDIR= 207 208The xen subsystem will install the hypervisor into fixed locations. 209BOOT_DIR defaults to /boot, DEBUG_DIR defaults to /usr/lib/debug and 210EFI_DIR to /usr/lib64/efi. 211BOOT_DIR= 212DEBUG_DIR= 213EFI_DIR= 214 215The make target 'rpmball' will build a xen.rpm. This variable can be 216used to append a custom string to the name. In addition a string can be 217appended to the rpm Release: tag. 218PKG_SUFFIX= 219PKG_RELEASE= 220 221The hypervisor will report a certain version string. This variable can 222be used to append a custom string to the version. 223XEN_VENDORVERSION= 224 225During boot xen will report a certain user@host string, which can be 226changed with these variables. 227XEN_WHOAMI= 228XEN_DOMAIN= 229 230Some components of xen and tools will include an unpredictable timestamp 231into the binaries. To allow reproducible builds the following variables 232can be used to provide fixed timestamps in the expected format. 233XEN_BUILD_DATE=<output of date(1)> 234XEN_BUILD_TIME=hh:mm:ss 235SMBIOS_REL_DATE=mm/dd/yyyy 236VGABIOS_REL_DATE="dd Mon yyyy" 237 238This variable can be used to point to a different git binary to be used. 239GIT= 240 241During tools build external repos will be cloned into the source tree. 242During stubdom build external packages will be downloaded into the 243source tree. These variables can be used to point to a different 244locations. 245XEN_EXTFILES_URL= 246OVMF_UPSTREAM_URL= 247QEMU_UPSTREAM_URL= 248QEMU_TRADITIONAL_URL= 249SEABIOS_UPSTREAM_URL= 250MINIOS_UPSTREAM_URL= 251 252Using additional CFLAGS to build tools which will run in dom0 is 253required when building distro packages. These variables can be used to 254pass RPM_OPT_FLAGS. 255EXTRA_CFLAGS_XEN_TOOLS= 256EXTRA_CFLAGS_QEMU_TRADITIONAL= 257EXTRA_CFLAGS_QEMU_XEN= 258 259Additional CFLAGS may be supplied to the build of the hypervisor by 260using this variable. 261EXTRA_CFLAGS_XEN_CORE= 262 263This variable can be used to use DIR/include and DIR/lib during build. 264This is the same as PREPEND_LIB and PREPEND_INCLUDES. APPEND_LIB and 265APPEND_INCLUDES= will be appended to the CFLAGS/LDFLAGS variable. 266EXTRA_PREFIX=DIR 267PREPEND_LIB=DIR 268PREPEND_INCLUDES=DIR 269APPEND_LIB=DIR 270APPEND_INCLUDES=DIR 271 272While the tools build will set the path to the python binary with the 273configure script, the hypervisor build has to use this variable to use a 274different python binary. 275PYTHON= 276 277Building the python tools may fail unless certain options are passed to 278setup.py. Config.mk contains additional info how to use this variable. 279PYTHON_PREFIX_ARG= 280 281The hypervisor may be built with XSM/Flask support, which can be changed 282by running: 283make -C xen menuconfig 284and enabling XSM/Flask in the 'Common Features' menu. A security policy 285is required to use XSM/Flask; if the SELinux policy compiler is 286available, the policy from tools can be included in the hypervisor. 287This option is enabled by default if XSM is enabled and the compiler 288(checkpolicy) is found. The location of this executable can be set 289using the environment variable. 290CHECKPOLICY= 291 292Use clang instead of GCC. 293clang=y 294 295 296Systemd support 297=============== 298 299If the systemd development packages are available then the support for 300systemd will be enabled per default. It is required to manually enable 301the installed systemd service files. Systemd has dependency tracking, 302which means all dependencies will be started automatically: 303 304systemctl enable xen-qemu-dom0-disk-backend.service 305systemctl enable xen-init-dom0.service 306systemctl enable xenconsoled.service 307 308Other optional services are: 309systemctl enable xendomains.service 310systemctl enable xen-watchdog.service 311 312 313QEMU Deprivilege 314================ 315It is recommended to run QEMU as non-root. 316See docs/misc/qemu-deprivilege.txt for an explanation on what you need 317to do at installation time to run QEMU as a dedicated user. 318 319 320History of options 321================== 322 323Prior to xen-4.5 configure recognized essentially only the --prefix= and 324--libdir= option to specify target directories. Starting with xen-4.5 325all paths can be adjusted once with configure. 326 327 328Examples 329======== 330 331* To build a private copy of tools and xen: 332configure --prefix=/odd/path --sysconfdir=/odd/path/etc --enable-rpath 333make 334sudo make install BOOT_DIR=/ood/path/boot EFI_DIR=/odd/path/efi 335 336 337* Use configure and make to build a distro rpm package (it is required 338 to unset variables set by the rpm configure macro): 339%build 340export WGET=$(type -P false) 341export GIT=$(type -P false) 342export EXTRA_CFLAGS_XEN_TOOLS="$RPM_OPT_FLAGS" 343export EXTRA_CFLAGS_QEMU_TRADITIONAL="$RPM_OPT_FLAGS" 344export EXTRA_CFLAGS_QEMU_XEN="$RPM_OPT_FLAGS" 345%configure \ 346 --with-initddir=%{_initddir} 347unset CFLAGS CXXFLAGS FFLAGS LDFLAGS 348make 349%install 350make install \ 351 SYSCONFIG_DIR=/var/adm/fillup-templates \ 352 DESTDIR=$RPM_BUILD_ROOT 353 354 355* To build xen and tools using a cross compiler: 356./configure --build=x86_64-unknown-linux-gnu --host=aarch64-linux-gnu 357make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- 358make XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \ 359 DESTDIR=/some/path install 360 361 362 363# vim: tw=72 et 364