2021-03-12 07:34:15 +00:00
|
|
|
====================
|
|
|
|
libvirt Installation
|
|
|
|
====================
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
|
2022-09-09 08:19:43 +00:00
|
|
|
Installing from distribution repositories
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
This is the recommended option to install libvirt. Libvirt is present in the
|
|
|
|
package repositories of all major distributions. Installing a package from the
|
2022-09-09 13:57:40 +00:00
|
|
|
package manager ensures that it's properly compiled, installed, started, and
|
|
|
|
updated during the lifecycle of the distribution.
|
2022-09-09 08:19:43 +00:00
|
|
|
|
|
|
|
For users who wish to use the most recent version, certain distributions also
|
|
|
|
allow installing the most recent versions of virtualization packages:
|
|
|
|
|
|
|
|
**Fedora**
|
|
|
|
|
|
|
|
Refer to https://fedoraproject.org/wiki/Virtualization_Preview_Repository
|
|
|
|
|
|
|
|
**Gentoo**
|
|
|
|
|
|
|
|
The ``app-emulation/libvirt`` is regularly updated, but newest versions are
|
|
|
|
usually marked as testing by the ``~*`` keyword.
|
|
|
|
|
2022-09-29 20:05:41 +00:00
|
|
|
**openSUSE**
|
|
|
|
|
|
|
|
Refer to https://build.opensuse.org/package/show/Virtualization/libvirt
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Preparing sources
|
|
|
|
-----------------
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Libvirt can be built both from release tarballs and from a git checkout using
|
|
|
|
the same steps once the source code is prepared. Note that the build system
|
|
|
|
requires that the build directory is separate from the top level source
|
|
|
|
directory.
|
|
|
|
|
|
|
|
By default further steps will build libvirt inside a subdirectory of the source
|
|
|
|
tree named ``build``.
|
|
|
|
|
|
|
|
Refer to the `downloads page <downloads.html>`__ for official tarballs and the
|
|
|
|
git repository.
|
|
|
|
|
|
|
|
Unpacking a source tarball
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Download a source tarball of the version you want to compile and unpack it
|
|
|
|
using the following commands:
|
2021-03-12 07:34:15 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ xz -dc libvirt-x.x.x.tar.xz | tar xvf -
|
|
|
|
$ cd libvirt-x.x.x
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Git checkout
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
A git checkout/clone is already in correct state for next steps. Just change
|
|
|
|
your working directory to the checkout.
|
|
|
|
|
|
|
|
Configuring the project
|
|
|
|
-----------------------
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
The libvirt build process uses the **Meson** build system. To configure for a
|
|
|
|
build use the following command. Note that the ``build`` argument is the name
|
|
|
|
of the build directory which will be created.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ meson build [options]
|
2021-03-16 09:19:45 +00:00
|
|
|
|
2021-03-12 07:34:15 +00:00
|
|
|
To get the complete list of the options run the following command:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ meson configure
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Be aware that by default the build is configured with a local ``prefix`` path
|
|
|
|
which will not interoperate with OS vendor provided binaries, since the UNIX
|
|
|
|
socket paths will all be different. To produce a build that is compatible with
|
|
|
|
normal OS vendor prefixes, use
|
2021-03-12 07:34:15 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
$ meson build -Dsystem=true
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:45:47 +00:00
|
|
|
Explicitly enabling required functionality
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
By default each module of functionality of libvirtd is optionally enabled,
|
|
|
|
meaning it will be enabled if the build environment contains the required
|
|
|
|
dependencies.
|
|
|
|
|
|
|
|
To ensure that your build contains the required functionality it's recommended
|
|
|
|
to explicitly enable given modules, in which case the configure step will end
|
|
|
|
with an error if dependencies are not present. **Example:** to build the
|
|
|
|
libvirt project with support for the **qemu** driver use the following options:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ meson build -Dsystem=true -Ddriver_qemu=enabled
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
~~~~~~
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
By default when the ``meson`` is run from within a GIT checkout, it will turn
|
|
|
|
on -Werror for builds. This can be disabled with --werror=false, but this is
|
|
|
|
not recommended.
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Please ensure that you have the appropriate minimal ``meson`` version installed
|
|
|
|
in your build environment. The minimal version for a specific package can be
|
|
|
|
checked in the top level ``meson.build`` file in the ``meson_version`` field.
|
2021-03-12 07:34:15 +00:00
|
|
|
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Compiling the sources
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
To build the configured project run (note that ``-C build`` is a path to the
|
|
|
|
build directory):
|
2021-03-12 07:34:15 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ ninja -C build
|
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
The ``build`` directory now contains the built binaries.
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
Additionally you can also run the test suite:
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
::
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 13:33:25 +00:00
|
|
|
$ ninja -C build test
|
2021-03-12 07:34:15 +00:00
|
|
|
|
2022-09-09 12:20:15 +00:00
|
|
|
Running compiled binaries from build directory
|
|
|
|
----------------------------------------------
|
|
|
|
|
|
|
|
For testing or development purposes it's usually not necessary to install the
|
|
|
|
built binaries into your system. Instead simply run libvirt directly from the
|
|
|
|
source tree. For example to run a privileged libvirtd instance
|
2021-03-12 07:34:15 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ su -
|
|
|
|
# service libvirtd stop (or systemctl stop libvirtd.service)
|
|
|
|
# /home/to/your/checkout/build/src/libvirtd
|
|
|
|
|
|
|
|
|
|
|
|
It is also possible to run virsh directly from the build tree using the
|
|
|
|
./run script (which sets some environment variables):
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ pwd
|
|
|
|
/home/to/your/checkout/build
|
|
|
|
$ ./run ./tools/virsh ....
|
2022-09-09 08:44:13 +00:00
|
|
|
|
2022-09-09 13:57:40 +00:00
|
|
|
**Note:** The libvirt project provides `multiple daemons <daemons.html>`__ and
|
|
|
|
the above steps may replace only some of them with the custom compiled instances.
|
|
|
|
In most cases this should work but keep that fact in mind.
|
|
|
|
|
2022-09-09 08:44:13 +00:00
|
|
|
Installing compiled binaries
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
**Important:** Manual installation of libvirt is generally not recommended and
|
|
|
|
you should prefer installation from your operating system's package repository
|
|
|
|
or from manually built packages which are then installed using the package
|
|
|
|
manager. Overwriting an installation of libvirt from the package manager by a
|
|
|
|
manually compiled installation may not work properly.
|
|
|
|
|
|
|
|
Installing the compiled binaries into the appropriate location (based on
|
|
|
|
how the build was configured) is done by the following command:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
$ sudo ninja -C build install
|
|
|
|
|
|
|
|
Note the use of **sudo** with the *ninja install* command. Using
|
|
|
|
sudo is only required when installing to a location your user does not
|
|
|
|
have write access to. Installing to a system location is a good example
|
|
|
|
of this.
|
|
|
|
|
|
|
|
If you are installing to a location that your user *does* have write
|
|
|
|
access to, then you can instead run the *ninja install* command without
|
|
|
|
putting **sudo** before it.
|
|
|
|
|
|
|
|
After installation you you **may** have to run ``ldconfig`` or a similar
|
|
|
|
utility to update your list of installed shared libs, or adjust the paths where
|
|
|
|
the system looks for binaries and shared libraries.
|
2022-09-09 13:57:40 +00:00
|
|
|
|
|
|
|
The libvirt project provides `multiple daemons <daemons.html>`__ based on your
|
|
|
|
configuration. You have to ensure that you start the appropriate processes for
|
|
|
|
the freshly installed libvirt to be usable (e.g. even monolithic ``libvirtd``
|
|
|
|
requires in most configurations that ``virtlogd`` is started).
|