qemu-guest-agent: init module

Allow out of band communication between qemu VMs and the host.
Useful to retrieve IPs of VMs from the host (for instance when libvirt can't analyze
DHCP requests because VMs are configured with static addresses or when
there is connectivity default).

+48
+1
nixos/modules/module-list.nix
··· 777 777 ./virtualisation/hyperv-guest.nix 778 778 ./virtualisation/openvswitch.nix 779 779 ./virtualisation/parallels-guest.nix 780 + ./virtualisation/qemu-guest-agent.nix 780 781 ./virtualisation/rkt.nix 781 782 ./virtualisation/virtualbox-guest.nix 782 783 ./virtualisation/virtualbox-host.nix
+36
nixos/modules/virtualisation/qemu-guest-agent.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.qemuGuest; 7 + in { 8 + 9 + options.services.qemuGuest = { 10 + enable = mkOption { 11 + type = types.bool; 12 + default = false; 13 + description = "Whether to enable the qemu guest agent."; 14 + }; 15 + }; 16 + 17 + config = mkIf cfg.enable ( 18 + mkMerge [ 19 + { 20 + 21 + services.udev.extraRules = '' 22 + SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", TAG+="systemd" ENV{SYSTEMD_WANTS}="qemu-guest-agent.service" 23 + ''; 24 + 25 + systemd.services.qemu-guest-agent = { 26 + description = "Run the QEMU Guest Agent"; 27 + serviceConfig = { 28 + ExecStart = "${pkgs.kvm.ga}/bin/qemu-ga"; 29 + Restart = "always"; 30 + RestartSec = 0; 31 + }; 32 + }; 33 + } 34 + ] 35 + ); 36 + }
+11
nixos/modules/virtualisation/qemu-vm.nix
··· 343 343 (<literal>virtio</literal> or <literal>scsi</literal>). 344 344 ''; 345 345 }; 346 + 347 + guestAgent.enable = 348 + mkOption { 349 + default = true; 350 + type = types.bool; 351 + description = '' 352 + Enable the Qemu guest agent. 353 + ''; 354 + }; 346 355 }; 347 356 348 357 virtualisation.useBootLoader = ··· 493 502 494 503 # Don't run ntpd in the guest. It should get the correct time from KVM. 495 504 services.timesyncd.enable = false; 505 + 506 + services.qemuGuest.enable = cfg.qemu.guestAgent.enable; 496 507 497 508 system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } 498 509 ''