about summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorAlois Wohlschlager <alois1@gmx-topmail.de>2023-12-31 07:25:34 +0100
committerAlyssa Ross <hi@alyssa.is>2024-01-13 00:39:33 +0100
commit77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94 (patch)
tree7a221ac13f615c3efcb42727a4b2837806e6dfc9 /nixos/modules/virtualisation
parent62c8b51c2720b31c76dda52626b6d914597b18d9 (diff)
downloadnixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.tar
nixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.tar.gz
nixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.tar.bz2
nixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.tar.lz
nixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.tar.xz
nixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.tar.zst
nixlib-77e5fa5ea6f11617e5852eb82dfd39b4f2df8a94.zip
nixos/libvirtd: support out-of-tree vhost-user drivers
Add an option allowing packages containing out-of-tree vhost-user drivers for
QEMU to be specified. The relevant configurations are then linked at runtime
where libvirt expects them.
An example use case for this is virtiofs.
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/libvirtd.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/libvirtd.nix b/nixos/modules/virtualisation/libvirtd.nix
index e195ff937d68..217242a8fbd2 100644
--- a/nixos/modules/virtualisation/libvirtd.nix
+++ b/nixos/modules/virtualisation/libvirtd.nix
@@ -116,6 +116,15 @@ let
           QEMU's swtpm options.
         '';
       };
+
+      vhostUserPackages = mkOption {
+        type = types.listOf types.package;
+        default = [ ];
+        example = lib.literalExpression "[ pkgs.virtiofsd ]";
+        description = lib.mdDoc ''
+          Packages containing out-of-tree vhost-user drivers.
+        '';
+      };
     };
   };
 
@@ -502,6 +511,14 @@ in
     # https://libvirt.org/daemons.html#monolithic-systemd-integration
     systemd.sockets.libvirtd.wantedBy = [ "sockets.target" ];
 
+    systemd.tmpfiles.rules = let
+      vhostUserCollection = pkgs.buildEnv {
+        name = "vhost-user";
+        paths = cfg.qemu.vhostUserPackages;
+        pathsToLink = [ "/share/qemu/vhost-user" ];
+      };
+    in [ "L+ /var/lib/qemu/vhost-user - - - - ${vhostUserCollection}/share/qemu/vhost-user" ];
+
     security.polkit = {
       enable = true;
       extraConfig = ''