[bug#75445,7/7] services: Add xen-guest-agent-service-type.

Message ID 7945dde8e89d4efaf17b2ec64f7489631d0a0bab.1736366802.git.karl@hallsby.com
State New
Headers
Series Add xen-guest-agent and daemon |

Commit Message

Raven Hallsby Jan. 8, 2025, 8:19 p.m. UTC
* gnu/services/virtualization.scm (xen-guest-agent-configuration,
  xen-guest-agent-service-type): New variables.
* doc/guix.texi: Document them.

Change-Id: Id1b1f4fc2b193d73f4401e74a214222dfe1b6ea7
---
 doc/guix.texi                   | 24 +++++++++++++++++++++++
 gnu/services/virtualization.scm | 34 ++++++++++++++++++++++++++++++++-
 2 files changed, 57 insertions(+), 1 deletion(-)
  

Comments

Ludovic Courtès Feb. 21, 2025, 1:31 p.m. UTC | #1
Karl Hallsby <karl@hallsby.com> skribis:

> * gnu/services/virtualization.scm (xen-guest-agent-configuration,
>   xen-guest-agent-service-type): New variables.
> * doc/guix.texi: Document them.
>
> Change-Id: Id1b1f4fc2b193d73f4401e74a214222dfe1b6ea7

Applied, thanks!

As mentioned before, it would be great if you could see what it would
take to write a system test (and thus, a way to boot Xen) so that these
services don’t bitrot.

Thanks,
Ludo’.
  
Raven Hallsby Feb. 23, 2025, 3:29 a.m. UTC | #2
> Applied, thanks!

Excellent! Thanks!

> As mentioned before, it would be great if you could see what it would
> take to write a system test (and thus, a way to boot Xen) so that these
> services don’t bitrot.

I agree. Looking at the system-level marionette virtual machine
infrastructure, it looks like the only supported hypervisor is QEMU &
Linux's KVM. Xen fundamentally behaves differently than QEMU & KVM, so
getting system tests working might be difficult.

I have been toying with the idea that the marionette VM could create a
fake Xen device entry in /dev/xen... socket(?) that we can pull the
known sent data out of. This would workaround the Linux VM expecting Xen
running underneath it. Does this seem like a reasonable work-around?

Or should we investigate abstracting the virtualization backend to
support running a Guix VM on both QEMU/KVM and Xen? This would give us
another way to verify reproducibility by running system tests inside a
different hypervisor.

help-debbugs@gnu.org (GNU bug Tracking System) writes:

> Your bug report
>
> #75445: [PATCH 0/7] Add xen-guest-agent and daemon
>
> which was filed against the guix-patches package, has been closed.
>
> The explanation is attached below, along with your original report.
> If you require more details, please reply to 75445@debbugs.gnu.org.
>
> --
> 75445: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75445
> GNU Bug Tracking System
> Contact help-debbugs@gnu.org with problems
>
> From: Ludovic Courtès <ludo@gnu.org>
> Subject: Re: [bug#75445] [PATCH 7/7] services: Add
>  xen-guest-agent-service-type.
> To: Karl Hallsby <karl@hallsby.com>
> Cc: 75445-done@debbugs.gnu.org, Maxim Cournoyer <maxim.cournoyer@gmail.com>
> Date: Fri, 21 Feb 2025 14:31:47 +0100 (1 day, 13 hours, 51 minutes ago)
>
> Karl Hallsby <karl@hallsby.com> skribis:
>
>> * gnu/services/virtualization.scm (xen-guest-agent-configuration,
>>   xen-guest-agent-service-type): New variables.
>> * doc/guix.texi: Document them.
>>
>> Change-Id: Id1b1f4fc2b193d73f4401e74a214222dfe1b6ea7
>

>
>
> Thanks,
> Ludo’.
>
> ----------
>
> From: Karl Hallsby <karl@hallsby.com>
> Subject: [PATCH 0/7] Add xen-guest-agent and daemon
> To: guix-patches@gnu.org
> Cc: Karl Hallsby <karl@hallsby.com>
> Date: Wed,  8 Jan 2025 14:12:48 -0600
> Date: Wed,  8 Jan 2025 14:12:48 -0600 (6 weeks, 3 days, 7 hours ago)
>
> This train adds the necessary Rust packages requried to build the
> xen-guest-agent package, builds it, and defines a service-type for
> running it as a daemon.
>
> The guest agent allows the virtualizing host (Xen) to receive
> information about the running OS guest and the host to send graceful
> versions of commands to the guest.
>
> The service-type is mutually exclusive with the xe-guest-utilities
> service-type and daemon introduced in issue #72249.
>
> Karl Hallsby (7):
>   gnu: Add rust-uname-0.1.
>   gnu: Add rust-xenstore-sys-0.3
>   gnu: Add rust-xenstore-sys-0.2
>   gnu: Add rust-xenstore-rs-0.7
>   gnu: Add rust-xenstore-rs-0.6
>   gnu: Add xen-guest-agent.
>   services: Add xen-guest-agent-service-type.
>
>  doc/guix.texi                   |  24 +++++++
>  gnu/packages/crates-io.scm      | 112 ++++++++++++++++++++++++++++++++
>  gnu/packages/virtualization.scm |  51 +++++++++++++++
>  gnu/services/virtualization.scm |  34 +++++++++-
>  4 files changed, 220 insertions(+), 1 deletion(-)
>
>
> base-commit: 4eaeff997907bc1b67884a6dc087756a50f175e2
> prerequisite-patch-id: daabcb5995f03ed867a27648e973e1c2203f2bc9
> prerequisite-patch-id: 10ca9a0912c5ab863ed39f14959581e75962ada9

--
Raven Hallsby
  

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index ee827717a1..89f153146a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -37365,6 +37365,30 @@  Virtualization Services
 @end table
 @end deftp
 
+@code{xe-guest-utilities} is the standard guest utilities used for Xen
+guests.  More recently the Xen Project has been working to develop
+@code{xen-guest-agent}, a modern drop-in replacement for
+@code{xe-guest-utilities}.  While they nearly have feature-parity,
+@code{xen-guest-agent} currently lacks some of the features of its
+predecessor, namely disk metrics and ``PV drivers version''.
+
+@defvar xen-guest-agent-service-type
+Service type for the Xen guest agent service.
+@end defvar
+
+@deftp {Data Type} xen-guest-agent-configuration
+Configuration for the @code{xen-guest-agent} service.
+
+@table @asis
+@item @code{package} (default: @code{xen-guest-agent})
+The Xen guest agent package to use.
+@end table
+@end deftp
+
+@quotation Warning
+@code{xe-guest-utilities} and @code{xen-guest-agent} are mutually exclusive.
+@end quotation
+
 
 @anchor{build-vm}
 @subsubheading Virtual Build Machines
diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm
index 874abcd73f..b697ae9526 100644
--- a/gnu/services/virtualization.scm
+++ b/gnu/services/virtualization.scm
@@ -113,7 +113,9 @@  (define-module (gnu services virtualization)
             qemu-guest-agent-service-type
 
             xe-guest-utilities-configuration
-            xe-guest-utilities-service-type))
+            xe-guest-utilities-service-type
+            xen-guest-agent-configuration
+            xen-guest-agent-service-type))
 
 (define (uglify-field-name field-name)
   (let ((str (symbol->string field-name)))
@@ -1083,6 +1085,36 @@  (define xe-guest-utilities-service-type
    (default-value (xe-guest-utilities-configuration))
    (description "Run the Xen guest management utilities.")))
 
+(define-configuration/no-serialization xen-guest-agent-configuration
+  (package
+    (package xen-guest-agent)
+    "Xen guest agent package."))
+
+(define (generate-xen-guest-agent-documentation)
+  "Generate documentation for xen-guest-agent-configuration fields"
+  (generate-documentation
+   `((xen-guest-agent-configuration ,xen-guest-agent-configuration-fields))
+   'xen-guest-agent-configuration))
+
+(define (xen-guest-agent-shepherd-service config)
+  (list
+   (shepherd-service
+    (provision '(xen-guest-agent))
+    (requirement '(networking user-processes udev))
+    (documentation "Run the Xen guest management agent.")
+    (start #~(make-forkexec-constructor
+              (list #$(file-append xen-guest-agent "/bin/xen-guest-agent"))))
+    (stop #~(make-kill-destructor)))))
+
+(define xen-guest-agent-service-type
+  (service-type
+   (name 'xen-guest-agent)
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             xen-guest-agent-shepherd-service)))
+   (default-value (xen-guest-agent-configuration))
+   (description "Run the Xen guest management utilities.")))
+
 
 ;;;
 ;;; Secrets for guest VMs.