Libvirt: Difference between revisions

From NixOS Wiki
imported>Gnidorah
No edit summary
imported>Booxter
document how to enable nested virtualization for intel kvm
Line 11: Line 11:


This backend works and is enabled by default. To use <code>virt-manager</code> with your user, locally and via SSH, it will be necessary to add yourself to the <code>libvirtd</code> group.
This backend works and is enabled by default. To use <code>virt-manager</code> with your user, locally and via SSH, it will be necessary to add yourself to the <code>libvirtd</code> group.
If you would like to enable nested virtualization for your guests to run KVM hypervisors inside them, you should enable it as follows:  {{nixos:option|boot.extraModprobeConfig}}, for example:
<code>boot.extraModprobeConfig = "options kvm_intel nested=1";</code>


== Tools ==
== Tools ==

Revision as of 19:27, 14 March 2019

libvirt is a toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes). It does so by providing a common API to different virtualization backends.

Using the virtualisation.libvirtd options, libvirtd can be enabled on a NixOS machine.

Backends

QEMU/KVM

This backend works and is enabled by default. To use virt-manager with your user, locally and via SSH, it will be necessary to add yourself to the libvirtd group.

If you would like to enable nested virtualization for your guests to run KVM hypervisors inside them, you should enable it as follows: boot.extraModprobeConfig, for example:

boot.extraModprobeConfig = "options kvm_intel nested=1";

Tools

NixOS provides some packages that can make use of libvirt or are useful with libvirt.

libguestfs

libguestfs is a set of tools for accessing and modifying virtual machines disk images.

Following are notes regarding the use of some of those tools

virt-builder

virt-builder is installed with libguestfs, but has some issues from its packaging.

It is possible to work around those issues without modifying the package (when a pristine nixpkgs is needed).

$ mkdir -p ~/.config/virt-builder
$ cd ~/.config/virt-builder
$ ln -s /run/current-system/sw/etc/xdg/virt-builder/repos.d
$ cd ~/.config
$ ln -s virt-builder/ .virt-builder-wrapped

This will make your user use the shipped repo configurations, and works around the fact that virt-builder reads its executable name to build its configuration path. The executable being wrapped, it is named differently.