libvirt: make guest suspend work, use upstream units
This commit is contained in:
parent
ddb608814a
commit
d545772640
|
@ -90,14 +90,16 @@ in {
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages =
|
||||
[ pkgs.libvirt pkgs.netcat-openbsd ]
|
||||
++ optional cfg.enableKVM pkgs.qemu_kvm;
|
||||
environment.systemPackages = with pkgs;
|
||||
[ libvirt netcat-openbsd ]
|
||||
++ optional cfg.enableKVM qemu_kvm;
|
||||
|
||||
boot.kernelModules = [ "tun" ];
|
||||
|
||||
users.extraGroups.libvirtd.gid = config.ids.gids.libvirtd;
|
||||
|
||||
systemd.packages = [ pkgs.libvirt ];
|
||||
|
||||
systemd.services.libvirtd = {
|
||||
description = "Libvirt Virtual Machine Management Daemon";
|
||||
|
||||
|
@ -105,13 +107,17 @@ in {
|
|||
after = [ "systemd-udev-settle.service" ]
|
||||
++ optional vswitch.enable "vswitchd.service";
|
||||
|
||||
path = [
|
||||
pkgs.bridge-utils
|
||||
pkgs.dmidecode
|
||||
pkgs.dnsmasq
|
||||
pkgs.ebtables
|
||||
environment = {
|
||||
LIBVIRTD_ARGS = ''--config "${configFile}" ${concatStringsSep " " cfg.extraOptions}'';
|
||||
};
|
||||
|
||||
path = with pkgs; [
|
||||
bridge-utils
|
||||
dmidecode
|
||||
dnsmasq
|
||||
ebtables
|
||||
]
|
||||
++ optional cfg.enableKVM pkgs.qemu_kvm
|
||||
++ optional cfg.enableKVM qemu_kvm
|
||||
++ optional vswitch.enable vswitch.package;
|
||||
|
||||
preStart = ''
|
||||
|
@ -153,13 +159,17 @@ in {
|
|||
''; # */
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = ''@${pkgs.libvirt}/sbin/libvirtd libvirtd --config "${configFile}" ${concatStringsSep " " cfg.extraOptions}'';
|
||||
Type = "notify";
|
||||
KillMode = "process"; # when stopping, leave the VMs alone
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.libvirt-guests = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = with pkgs; [ coreutils libvirt gawk ];
|
||||
};
|
||||
|
||||
systemd.sockets.virtlogd = {
|
||||
description = "Virtual machine log manager socket";
|
||||
wantedBy = [ "sockets.target" ];
|
||||
|
|
|
@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
|
|||
"--with-numad"
|
||||
"--with-macvtap"
|
||||
"--with-virtualport"
|
||||
"--with-init-script=redhat"
|
||||
"--with-init-script=systemd+redhat"
|
||||
"--with-storage-zfs"
|
||||
] ++ optionals stdenv.isDarwin [
|
||||
"--with-init-script=none"
|
||||
|
@ -72,7 +72,9 @@ stdenv.mkDerivation rec {
|
|||
postInstall = ''
|
||||
sed -i 's/ON_SHUTDOWN=suspend/ON_SHUTDOWN=''${ON_SHUTDOWN:-suspend}/' $out/libexec/libvirt-guests.sh
|
||||
substituteInPlace $out/libexec/libvirt-guests.sh \
|
||||
--replace "$out/bin" "${gettext}/bin"
|
||||
--replace "$out/bin" "${gettext}/bin" \
|
||||
--replace "lock/subsys" "lock"
|
||||
rm $out/lib/systemd/system/{virtlockd,virtlogd}.*
|
||||
'' + optionalString stdenv.isLinux ''
|
||||
wrapProgram $out/sbin/libvirtd \
|
||||
--prefix PATH : ${makeBinPath [ iptables iproute pmutils numad numactl ]}
|
||||
|
|
Loading…
Reference in New Issue
Block a user