unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Karl Hallsby via Guix-patches via <guix-patches@gnu.org>
To: 72249@debbugs.gnu.org
Cc: "Karl Hallsby" <karl@hallsby.com>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#72249] [PATCH] services: Add xe-guest-utilities-service-type.
Date: Fri, 10 Jan 2025 01:00:59 -0600	[thread overview]
Message-ID: <73106db7b8187d4b6bcc5d0c421ea3314ed7a498.1736491649.git.karl@hallsby.com> (raw)
In-Reply-To: <cover.1721711392.git.karl@hallsby.com>

* gnu/services/virtualization.scm (xe-guest-utilities-configuration,
  xe-guest-utilities-service-type): New variables.
* doc/guix.texi: Document them.

Change-Id: Ife4e79fa6d1a9d5a21bf7479488884f2a5cf8d56
---
 doc/guix.texi                   | 71 +++++++++++++++++++++++++++++
 gnu/services/virtualization.scm | 81 ++++++++++++++++++++++++++++++++-
 2 files changed, 151 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f7b7569887..afb886128b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -37328,6 +37328,77 @@ Virtualization Services
 @end table
 @end deftp
 
+@subsubheading Xen Guest Agent
+
+@cindex Xen
+@cindex Xen guest agent
+
+The Xen guest agent allows a Xen host to control the emulated system.
+The @code{xe-guest-utilities} service runs the agent on Guix guests.
+
+@url{https://github.com/xenserver/xe-guest-utilities, xe-guest-utilities} collects information about the running virtualized guest. This includes:
+@itemize
+@item
+static information
+@itemize
+@item
+The operating system running
+@item
+The Linux kernel version
+@end itemize
+
+@item
+dynamic information
+@itemize
+@item
+Network interfaces (devices) being added/removed
+@item
+Network connections being unplugged/plugged-in
+@item
+CPUs being added or removed
+@item
+The guest migrating, being paused/resumed, etc.
+@end itemize
+
+@item
+ephemeral information
+@itemize
+@item
+The amount of memory currently in-use and free
+@item
+The amount of disk-space used
+@end itemize
+@end itemize
+
+@quotation Note
+The default Linux-libre kernel that Guix ships already enables the
+necessary paravirtualization features for a guest.  There is nothing you
+need to do for the guest to support Xen's paravirtualization features.
+
+The guest utilities are used to have the guest report information
+@emph{back} to the virtualizing host and support tasks that require
+cooperation between host and guest, like CPU hotplugging.
+@end quotation
+
+@defvar xe-guest-utilities-service-type
+Service type for the Xen guest utilities service.
+@end defvar
+
+@deftp {Data Type} xe-guest-utilities-configuration
+Configuration for the @code{xe-guest-utilities} service.
+
+@table @asis
+@item @code{package} (default: @code{xe-guest-utilities})
+The Xen guest utilities package to use.
+
+@item @code{pid-file} (default: @code{"/var/run/xe-daemon.pid"})
+Name of the file holding the PID of @code{xe-deamon}.
+
+@item @code{log-file} (default: @code{"/var/log/xe-guest-utilities.log"})
+Name of the @code{xe-guest-utilities} log file.
+@end table
+@end deftp
+
 
 @anchor{build-vm}
 @subsubheading Virtual Build Machines
diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm
index c32c47484c..874abcd73f 100644
--- a/gnu/services/virtualization.scm
+++ b/gnu/services/virtualization.scm
@@ -33,6 +33,9 @@ (define-module (gnu services virtualization)
   #:autoload   (gnu packages gnupg) (guile-gcrypt)
   #:use-module (gnu packages package-management)
   #:use-module (gnu packages ssh)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages gawk)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages virtualization)
   #:use-module (gnu services base)
   #:use-module (gnu services configuration)
@@ -107,7 +110,10 @@ (define-module (gnu services virtualization)
 
             qemu-guest-agent-configuration
             qemu-guest-agent-configuration?
-            qemu-guest-agent-service-type))
+            qemu-guest-agent-service-type
+
+            xe-guest-utilities-configuration
+            xe-guest-utilities-service-type))
 
 (define (uglify-field-name field-name)
   (let ((str (symbol->string field-name)))
@@ -1004,6 +1010,79 @@ (define qemu-guest-agent-service-type
    (default-value (qemu-guest-agent-configuration))
    (description "Run the QEMU guest agent.")))
 
+\f
+;;;
+;;; Guest agent for VMs running under Xen
+;;;
+(define-configuration/no-serialization xe-guest-utilities-configuration
+  (package
+   (package xe-guest-utilities)
+   "Xen guest management utilities package.")
+  (pid-file
+   (string "/var/run/xe-daemon.pid")
+   "Path to the file holding the PID of xe-deamon.")
+  (log-file
+   (string "/var/log/xe-guest-utilties.log")
+   "Path to xe-guest-utilities log file."))
+
+(define (generate-xe-guest-utilities-documentation)
+  "Generate documentation for xe-guest-utilities-configuration fields"
+  (generate-documentation
+   `((xe-guest-utilities-configuration ,xe-guest-utilities-configuration-fields))
+   'xe-guest-utilities-configuration))
+
+(define (xe-guest-utilities-shepherd-service config)
+  (let ((xe-guest-utils (xe-guest-utilities-configuration-package config))
+        (pid-file (xe-guest-utilities-configuration-pid-file config))
+        (log-file (xe-guest-utilities-configuration-log-file config)))
+    (list
+     (shepherd-service
+      (provision '(xen-guest-agent))
+      (requirement '(networking user-processes udev))
+      (documentation "Run the Xen guest management agent.")
+      (start
+       #~(lambda _
+           (let ((pid (make-forkexec-constructor
+                       (list
+                        #$(file-append xe-guest-utils
+                                       "/sbin/xe-daemon")
+                        "-p" #$pid-file)
+                       #:log-file #$log-file
+                       #:pid-file #$pid-file
+                       #:environment-variables
+                       (list (string-append
+                              "PATH="
+                              #$(file-append xe-guest-utils "/bin") ":"
+                              ;; logger
+                              #$(file-append inetutils "/bin"))))))
+             ;; Run xe-linux-distribution script before starting the actual
+             ;; daemon. The script collects some basic system information that
+             ;; is shared back to the Xen host.
+             (system* #$(file-append xe-guest-utils "/sbin/xe-linux-distribution")
+                      "/var/cache/xe-linux-distribution")
+             ;; Finally, start and return the PID made by
+             ;; make-forkexec-constructor.
+             pid)))
+      (stop #~(make-kill-destructor))))))
+
+(define (xe-guest-utilities-udev-rules-service config)
+  (let ((guest-utils (xe-guest-utilities-configuration-package config)))
+    (list
+     (file->udev-rule
+      "z10_xen-vcpu-hotplug.rules"
+      (file-append guest-utils "/lib/udev/rules.d/z10_xen-vcpu-hotplug.rules")))))
+
+(define xe-guest-utilities-service-type
+  (service-type
+   (name 'xe-guest-utilities)
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             xe-guest-utilities-shepherd-service)
+          (service-extension udev-service-type
+                             xe-guest-utilities-udev-rules-service)))
+   (default-value (xe-guest-utilities-configuration))
+   (description "Run the Xen guest management utilities.")))
+
 \f
 ;;;
 ;;; Secrets for guest VMs.

base-commit: 4eaeff997907bc1b67884a6dc087756a50f175e2
prerequisite-patch-id: daabcb5995f03ed867a27648e973e1c2203f2bc9
-- 
2.46.0





      parent reply	other threads:[~2025-01-10  7:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23  5:14 [bug#72249] [PATCH 0/2] Add xe-guest-utilities and daemon Karl Hallsby via Guix-patches via
2024-07-23  5:22 ` [bug#72249] [PATCH 1/2] gnu: Add xe-guest-utilities Karl Hallsby via Guix-patches via
2024-07-23  5:22 ` [bug#72249] [PATCH 2/2] services: Add xe-guest-utilities-service-type Karl Hallsby via Guix-patches via
2025-01-08 20:10 ` [bug#72249] [PATCH 1/2] gnu: Add xe-guest-utilities Karl Hallsby via Guix-patches via
2025-01-08 20:10   ` [bug#72249] [PATCH 2/2] services: Add xe-guest-utilities-service-type Karl Hallsby via Guix-patches via
2025-01-09 13:45     ` Ludovic Courtès
2025-01-10  7:00 ` Karl Hallsby via Guix-patches via [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=73106db7b8187d4b6bcc5d0c421ea3314ed7a498.1736491649.git.karl@hallsby.com \
    --to=guix-patches@gnu.org \
    --cc=72249@debbugs.gnu.org \
    --cc=karl@hallsby.com \
    --cc=ludo@gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).