The libvirt service does not contain a way to turn-on remote listening

  • Open
  • quality assurance status badge
Details
2 participants
  • Brice Waegeneire
  • Katherine Cox-Buday
Owner
unassigned
Submitted by
Katherine Cox-Buday
Severity
normal
K
K
Katherine Cox-Buday wrote on 10 Feb 2022 18:09
(name . Guix Bugs)(address . bug-guix@gnu.org)
8735kq8x86.fsf@gmail.com
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:

Toggle quote (2 lines)
> You must set listen for this to have any effect.

From libvirt's documentation[2]:

Toggle quote (4 lines)
> Note: it is also necessary to start the server in listening mode by
> running it with --listen or adding a LIBVIRTD_ARGS="--listen" line to
> /etc/sysconfig/libvirtd.

Our service definition requires the ability to specify that shepherd should start the service with the `--listen` flag.


--
Katherine
B
B
Brice Waegeneire wrote on 12 Feb 2022 13:30
[PATCH] services: libvirt: Enable listening mode based on configuration.
(address . cox.katherine.e@gmail.com)(address . 53921@debbugs.gnu.org)
20220212123028.6320-1-brice@waegenei.re

* 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 <cox.katherine.e@gmail.com> writes:

Toggle quote (4 lines)
> 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(-)

Toggle diff (40 lines)
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 <ludo@gnu.org>
;;; Copyright © 2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2021 Timotej Lazar <timotej.lazar@araneo.si>
+;;; Copyright © 2022 Brice Waegeneire <brice@waegenei.re>
;;;
;;; 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
K
K
Katherine Cox-Buday wrote on 12 Feb 2022 16:56
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 53921@debbugs.gnu.org)
87v8xk6pu0.fsf@gmail.com
Brice Waegeneire <brice@waegenei.re> writes:

Toggle quote (3 lines)
> Good catch! This patch fixes the reported issue, I've tested it with
> success.

Thanks, Brice! This looks great!

--
Katherine
?