Commit 77e5fa5e authored by Alois Wohlschlager's avatar Alois Wohlschlager Committed by Alyssa Ross
Browse files

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.
parent 62c8b51c
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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 = ''