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 ./virtualisation/hyperv-guest.nix 778 ./virtualisation/openvswitch.nix 779 ./virtualisation/parallels-guest.nix 780 ./virtualisation/rkt.nix 781 ./virtualisation/virtualbox-guest.nix 782 ./virtualisation/virtualbox-host.nix
··· 777 ./virtualisation/hyperv-guest.nix 778 ./virtualisation/openvswitch.nix 779 ./virtualisation/parallels-guest.nix 780 + ./virtualisation/qemu-guest-agent.nix 781 ./virtualisation/rkt.nix 782 ./virtualisation/virtualbox-guest.nix 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 (<literal>virtio</literal> or <literal>scsi</literal>). 344 ''; 345 }; 346 }; 347 348 virtualisation.useBootLoader = ··· 493 494 # Don't run ntpd in the guest. It should get the correct time from KVM. 495 services.timesyncd.enable = false; 496 497 system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } 498 ''
··· 343 (<literal>virtio</literal> or <literal>scsi</literal>). 344 ''; 345 }; 346 + 347 + guestAgent.enable = 348 + mkOption { 349 + default = true; 350 + type = types.bool; 351 + description = '' 352 + Enable the Qemu guest agent. 353 + ''; 354 + }; 355 }; 356 357 virtualisation.useBootLoader = ··· 502 503 # Don't run ntpd in the guest. It should get the correct time from KVM. 504 services.timesyncd.enable = false; 505 + 506 + services.qemuGuest.enable = cfg.qemu.guestAgent.enable; 507 508 system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } 509 ''