Subject: [PATCH] services: libvirt: Enable listening mode based on configuration.

From: Brice Waegeneire <[email-masked]>
Date: Sat, 12 Feb 2022 13:30:28 +0100

Fixes <https://bugs.gnu.org/53921>.

* gnu/services/virtualization.scm (libvirt-shepherd-service): Use
  'match-record' instead of accessors.
  Conditionally add "--listen" flag to the start command.
---
Hello Katherine,

Katherine Cox-Buday <[email-masked]> writes:

> The shepherd libvirt service contains ways to configure "listening mode"
> (i.e. listening over TCP) capabilities, but contains no way to actually turn
> this feature on, despite referencing[1] an unimplemented `listen` option:

Good catch!  This patch fixes the reported issue, I've tested it with success.

Cheers,
- Brice

 gnu/services/virtualization.scm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm
index 66ae1a1565..ba9fe0505c 100644
--- a/gnu/services/virtualization.scm
+++ b/gnu/services/virtualization.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2018, 2020, 2021 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2020,2021 Jan (janneke) Nieuwenhuizen <[email-masked]>
 ;;; Copyright © 2021 Timotej Lazar <[email-masked]>
+;;; Copyright © 2022 Brice Waegeneire <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -467,16 +468,18 @@ (define (%libvirt-activation config)
         (use-modules (guix build utils))
         (mkdir-p #$sock-dir))))
 
-
 (define (libvirt-shepherd-service config)
-  (let* ((config-file (libvirt-conf-file config))
-         (libvirt (libvirt-configuration-libvirt config)))
+  (match-record config <libvirt-configuration>
+    (libvirt listen-tcp? listen-tls?)
     (list (shepherd-service
            (documentation "Run the libvirt daemon.")
            (provision '(libvirtd))
            (start #~(make-forkexec-constructor
-                     (list (string-append #$libvirt "/sbin/libvirtd")
-                           "-f" #$config-file)
+                     (list #$(file-append libvirt "/sbin/libvirtd")
+                           (if (or #$listen-tcp? #$listen-tls?)
+                               "--listen"
+                               "")
+                           "-f" #$(libvirt-conf-file config))
                      ;; For finding qemu and ip binaries.
                      #:environment-variables
                      (list (string-append

base-commit: 068d99978a0c9c6fb66f95455060c8d08ba55ac5
-- 
2.34.0