diff options
author | xeji <36407913+xeji@users.noreply.github.com> | 2018-05-10 01:22:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 01:22:52 +0200 |
commit | 3d6f752c51ee69aa508995db509c5c70b1253f8f (patch) | |
tree | 1106332b874fb4035da3b2070bedeab93f0ce4c2 /nixos | |
parent | 1682353805e37b29b2dc0f06efdbe8a33a07363c (diff) | |
parent | ca0604190e4428e1cdf9bb369fbbf73e1679e007 (diff) | |
download | nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.tar nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.tar.gz nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.tar.bz2 nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.tar.lz nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.tar.xz nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.tar.zst nixpkgs-3d6f752c51ee69aa508995db509c5c70b1253f8f.zip |
Merge pull request #39099 from teto/qemu_agent
qemu-guest-agent: init module
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/virtualisation/qemu-guest-agent.nix | 36 | ||||
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 11 |
3 files changed, 48 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 6c4326046ef..31f504ce556 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -780,6 +780,7 @@ ./virtualisation/hyperv-guest.nix ./virtualisation/openvswitch.nix ./virtualisation/parallels-guest.nix + ./virtualisation/qemu-guest-agent.nix ./virtualisation/rkt.nix ./virtualisation/virtualbox-guest.nix ./virtualisation/virtualbox-host.nix diff --git a/nixos/modules/virtualisation/qemu-guest-agent.nix b/nixos/modules/virtualisation/qemu-guest-agent.nix new file mode 100644 index 00000000000..e0d2b3dc509 --- /dev/null +++ b/nixos/modules/virtualisation/qemu-guest-agent.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.qemuGuest; +in { + + options.services.qemuGuest = { + enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the qemu guest agent."; + }; + }; + + config = mkIf cfg.enable ( + mkMerge [ + { + + services.udev.extraRules = '' + SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", TAG+="systemd" ENV{SYSTEMD_WANTS}="qemu-guest-agent.service" + ''; + + systemd.services.qemu-guest-agent = { + description = "Run the QEMU Guest Agent"; + serviceConfig = { + ExecStart = "${pkgs.kvm.ga}/bin/qemu-ga"; + Restart = "always"; + RestartSec = 0; + }; + }; + } + ] + ); +} diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index f7ec5b088c1..d271144af48 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -360,6 +360,15 @@ in type = types.enum [ "virtio" "scsi" "ide" ]; description = "The interface used for the virtual hard disks."; }; + + guestAgent.enable = + mkOption { + default = true; + type = types.bool; + description = '' + Enable the Qemu guest agent. + ''; + }; }; virtualisation.useBootLoader = @@ -511,6 +520,8 @@ in # Don't run ntpd in the guest. It should get the correct time from KVM. services.timesyncd.enable = false; + services.qemuGuest.enable = cfg.qemu.guestAgent.enable; + system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } '' mkdir -p $out/bin |