diff options
Diffstat (limited to 'nixpkgs/nixos/modules/virtualisation/libvirtd.nix')
-rw-r--r-- | nixpkgs/nixos/modules/virtualisation/libvirtd.nix | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/nixpkgs/nixos/modules/virtualisation/libvirtd.nix b/nixpkgs/nixos/modules/virtualisation/libvirtd.nix index 817d7180a022..8dfe04cea542 100644 --- a/nixpkgs/nixos/modules/virtualisation/libvirtd.nix +++ b/nixpkgs/nixos/modules/virtualisation/libvirtd.nix @@ -81,7 +81,7 @@ let type = types.package; default = pkgs.qemu; defaultText = literalExpression "pkgs.qemu"; - description = '' + description = lib.mdDoc '' Qemu package to use with libvirt. `pkgs.qemu` can emulate alien architectures (e.g. aarch64 on x86) `pkgs.qemu_kvm` saves disk space allowing to emulate only host architectures. @@ -220,6 +220,17 @@ in ''; }; + parallelShutdown = mkOption { + type = types.ints.unsigned; + default = 0; + description = lib.mdDoc '' + Number of guests that will be shutdown concurrently, taking effect when onShutdown + is set to "shutdown". If set to 0, guests will be shutdown one after another. + Number of guests on shutdown at any time will not exceed number set in this + variable. + ''; + }; + allowedBridges = mkOption { type = types.listOf types.str; default = [ "virbr0" ]; @@ -282,7 +293,7 @@ in setuid = true; owner = "root"; group = "root"; - source = "/run/${dirName}/nix-helpers/qemu-bridge-helper"; + source = "${cfg.qemu.package}/libexec/qemu-bridge-helper"; }; systemd.packages = [ cfg.package ]; @@ -297,7 +308,9 @@ in libvirt/nwfilter/*.xml ); do mkdir -p /var/lib/$(dirname $i) -m 755 - cp -npd ${cfg.package}/var/lib/$i /var/lib/$i + if [ ! -e /var/lib/$i ]; then + cp -pd ${cfg.package}/var/lib/$i /var/lib/$i + fi done # Copy generated qemu config to libvirt directory @@ -308,7 +321,7 @@ in ln -s --force "$emulator" /run/${dirName}/nix-emulators/ done - for helper in libexec/qemu-bridge-helper bin/qemu-pr-helper; do + for helper in bin/qemu-pr-helper; do ln -s --force ${cfg.qemu.package}/$helper /run/${dirName}/nix-helpers/ done @@ -336,6 +349,7 @@ in }; systemd.services.libvirtd = { + wantedBy = [ "multi-user.target" ]; requires = [ "libvirtd-config.service" ]; after = [ "libvirtd-config.service" ] ++ optional vswitch.enable "ovs-vswitchd.service"; @@ -372,6 +386,7 @@ in environment.ON_BOOT = "${cfg.onBoot}"; environment.ON_SHUTDOWN = "${cfg.onShutdown}"; + environment.PARALLEL_SHUTDOWN = "${toString cfg.parallelShutdown}"; }; systemd.sockets.virtlogd = { @@ -401,13 +416,16 @@ in # https://libvirt.org/daemons.html#monolithic-systemd-integration systemd.sockets.libvirtd.wantedBy = [ "sockets.target" ]; - security.polkit.extraConfig = '' - polkit.addRule(function(action, subject) { - if (action.id == "org.libvirt.unix.manage" && - subject.isInGroup("libvirtd")) { - return polkit.Result.YES; - } - }); - ''; + security.polkit = { + enable = true; + extraConfig = '' + polkit.addRule(function(action, subject) { + if (action.id == "org.libvirt.unix.manage" && + subject.isInGroup("libvirtd")) { + return polkit.Result.YES; + } + }); + ''; + }; }; } |