1002f5604SAndre Przywara Installation instructions for kvmtool 2002f5604SAndre Przywara--------------------------------------- 3002f5604SAndre Przywara 4002f5604SAndre Przywara========================================================================== 5002f5604SAndre PrzywaraFor the impatient: 6002f5604SAndre PrzywaraJust typing "make" should do the trick most of the times. 7002f5604SAndre PrzywaraYou will get a binary called "lkvm" which is self-contained. 8002f5604SAndre PrzywaraNo extra libraries or files need to be installed. 9002f5604SAndre Przywara========================================================================== 10002f5604SAndre Przywara 11002f5604SAndre Przywara"make install" will copy the compiled file into $HOME/bin, this can be 12002f5604SAndre Przywarachanged by providing "prefix=" on the make command-line. DESTDIR will be 13002f5604SAndre Przywarahonoured. 14002f5604SAndre Przywara 15002f5604SAndre PrzywaraPrerequisites 16002f5604SAndre Przywara-------------- 17002f5604SAndre PrzywaraFor compilation you will need a recent GNU tool chain (binutils, gcc, make), 18002f5604SAndre Przywaraalso the standard C library. 19002f5604SAndre Przywara 20002f5604SAndre PrzywaraFor deb based systems: 21002f5604SAndre Przywara $ sudo apt-get install build-essential 22002f5604SAndre Przywara On x86-64 systems you have to add the 32-bit compat headers: 23002f5604SAndre Przywara $ sudo apt-get install libc6-dev-i386 24002f5604SAndre PrzywaraFor Fedora based systems: 25002f5604SAndre Przywara # yum install glibc-static 26002f5604SAndre PrzywaraFor OpenSUSE based systems: 27002f5604SAndre Przywara # zypper install glibc-devel-static 28002f5604SAndre Przywara 292e996783SAnup PatelArchitectures which require device tree (PowerPC, ARM, ARM64, RISC-V) also 302e996783SAnup Patelrequire libfdt. 31002f5604SAndre Przywara deb: $ sudo apt-get install libfdt-dev 32002f5604SAndre Przywara Fedora: # yum install libfdt-devel 33002f5604SAndre Przywara OpenSUSE: # zypper install libfdt1-devel 34002f5604SAndre PrzywaraAlso see "Cross compiling" below. 35002f5604SAndre Przywara 36002f5604SAndre PrzywaraOptional libraries 37002f5604SAndre Przywara------------------- 38002f5604SAndre PrzywaraBy running "make" some checks are invoked that determine the availability 39002f5604SAndre Przywaraof certain optional libraries. Those are: 40002f5604SAndre Przywara- libbfd: enable symbol look-up support in debug mode 41002f5604SAndre Przywara- gtk3: enable support for displaying the guest framebuffer in a GTK+-3 window 42002f5604SAndre Przywara- vncserver: enable support for exporting the guest framebuffer in a VNC session 43002f5604SAndre Przywara- SDL: enable support for displaying the guest framebuffer in a SDL window 44002f5604SAndre Przywara- zlib: enable support for compressed QCOW images 45002f5604SAndre Przywara- aio: enable support for asynchronous I/O 46002f5604SAndre Przywara(Note that a guest framebuffer is currently only supported on x86.) 47002f5604SAndre PrzywaraSo for the full glory you would need: 48002f5604SAndre Przywara(on a .deb based system): 49002f5604SAndre Przywara$ sudo apt-get install binutils-dev libgtk-3-dev libvncserver-dev libsdl2-dev \ 50002f5604SAndre Przywara zlib1g-dev libaio-dev 51002f5604SAndre Przywara(on RPM based systems): 52002f5604SAndre Przywara# $TOOL install binutils-devel gtk3-devel libvncserver-devel SDL-devel \ 53002f5604SAndre Przywara zlib-devel libaio-devel 54002f5604SAndre Przywara$TOOL is "yum" for Fedora and "zypper" for OpenSUSE. 55002f5604SAndre Przywara 56002f5604SAndre PrzywaraCross compiling 57002f5604SAndre Przywara---------------- 58002f5604SAndre PrzywaraThe Makefile will honour the CROSS_COMPILE environment variable when calling 59002f5604SAndre Przywarathe compiler and the linker binary. To trigger cross compilation, also set ARCH 60002f5604SAndre Przywarato the Linux name of the architecture. Architectures supported: 61002f5604SAndre Przywara- i386 62002f5604SAndre Przywara- x86_64 63002f5604SAndre Przywara- powerpc 64002f5604SAndre Przywara- arm 65002f5604SAndre Przywara- arm64 66002f5604SAndre Przywara- mips 672e996783SAnup Patel- riscv 68002f5604SAndre PrzywaraIf ARCH is not provided, the target architecture will be automatically 69002f5604SAndre Przywaradetermined by running "uname -m" on your host, resulting in a native build. 70002f5604SAndre Przywara 71002f5604SAndre PrzywaraTo cross-compile to ARM for instance, install a cross-compiler, put the 72002f5604SAndre Przywararequired libraries in the cross-compiler's SYSROOT and type: 73002f5604SAndre Przywara$ make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm 74002f5604SAndre Przywara 75002f5604SAndre PrzywaraMissing libraries when cross-compiling 76002f5604SAndre Przywara--------------------------------------- 77002f5604SAndre PrzywaraThe cross-compiler will look for target libraries in its SYSROOT directory, 78002f5604SAndre Przywaraso you need to put the header and library files (.so) there. 79002f5604SAndre PrzywaraWhile most cross compiler packages come with the target's glibc already 80002f5604SAndre Przywarainstalled, optional libraries (or libfdt) maybe not. 81002f5604SAndre PrzywaraOn multiarch system you should be able to install those be appending 82002f5604SAndre Przywarathe architecture name after the package (example for ARM64): 83002f5604SAndre Przywara$ sudo apt-get install libfdt-dev:arm64 84002f5604SAndre Przywara 852e996783SAnup PatelPowerPC, ARM/ARM64 and RISC-V require libfdt to be installed. If you cannot use 86002f5604SAndre Przywaraprecompiled mulitarch packages, you could either copy the required header and 87002f5604SAndre Przywaralibrary files from an installed target system into the SYSROOT (you will need 88002f5604SAndre Przywara/usr/include/*fdt*.h and /usr/lib64/libfdt-v.v.v.so and its symlinks), or you 89002f5604SAndre Przywaracan cross-compile the libfdt library yourself: 90002f5604SAndre Przywara 91002f5604SAndre Przywara$ git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git 92002f5604SAndre Przywara$ cd dtc 93002f5604SAndre Przywara$ export CC=${CROSS_COMPILE}gcc 94*336751fbSAlexandru Elisei$ make libfdt 95*336751fbSAlexandru Elisei 96*336751fbSAlexandru EliseiAfter compiling libfdt, the library can be installed system-wide: 97*336751fbSAlexandru Elisei 98002f5604SAndre Przywara$ TRIPLET=$($CC -dumpmachine) 99002f5604SAndre Przywara$ SYSROOT=$($CC -print-sysroot) 100002f5604SAndre Przywara$ sudo make DESTDIR=$SYSROOT PREFIX=/usr LIBDIR=/usr/lib/$TRIPLET install-lib install-includes 101002f5604SAndre Przywara 102002f5604SAndre PrzywaraThis assumes a multiarch-enabled system, if there is no per-arch directory for 103002f5604SAndre Przywaralibraries, replace the LIBDIR paths above with LIBDIR=/usr/lib or /usr/lib64. 104*336751fbSAlexandru Elisei 105*336751fbSAlexandru EliseiAlternatively, if installing the shared library is not desirable or possible, 106*336751fbSAlexandru Eliseiyou can instruct kvmtool to use the static library when compiling by using the 107*336751fbSAlexandru Eliseivariable LIBFDT_DIR. LIBFDT_DIR should point to the dtc/libfdt directory. 108*336751fbSAlexandru Eliseikvmtool will include the static library LIBFDT_DIR/libfdt.a in the executable, 109*336751fbSAlexandru Eliseiremoving the need for the shared library to be present on the system. 110*336751fbSAlexandru EliseiLIBFDT_DIR, when set, takes precedence over the system library. 111