Package: guix-patches;
Reported by: Karl Hallsby <karl <at> hallsby.com>
Date: Tue, 23 Jul 2024 05:16:01 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72249 in the body.
You can then email your comments to 72249 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Tue, 23 Jul 2024 05:16:01 GMT) Full text and rfc822 format available.Karl Hallsby <karl <at> hallsby.com>
:pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
.
(Tue, 23 Jul 2024 05:16:01 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Karl Hallsby <karl <at> hallsby.com> To: guix-patches <at> gnu.org Cc: Karl Hallsby <karl <at> hallsby.com> Subject: [PATCH 0/2] Add xe-guest-utilities and daemon Date: Tue, 23 Jul 2024 00:14:42 -0500
This service allows Xen hosts to *nicely* control Guix guests by requesting graceful shutdowns, restarts, etc. You also get some system information about the guest displayed by the Xen host. Karl Hallsby (2): gnu: Add xe-guest-utilities. services: Add xe-guest-utilities-service-type. doc/guix.texi | 30 ++++++ gnu/packages/virtualization.scm | 60 +++++++++++ gnu/services/virtualization.scm | 179 +++++++++++++++++++++++++++++++- 3 files changed, 268 insertions(+), 1 deletion(-) base-commit: ad97f1bdb67015cffe92adba3b94c3b3df576008 -- 2.45.2
guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Tue, 23 Jul 2024 05:24:01 GMT) Full text and rfc822 format available.Message #8 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: Karl Hallsby <karl <at> hallsby.com> To: 72249 <at> debbugs.gnu.org Cc: Karl Hallsby <karl <at> hallsby.com> Subject: [PATCH 1/2] gnu: Add xe-guest-utilities. Date: Tue, 23 Jul 2024 00:22:37 -0500
* gnu/packages/virtualization.scm (xe-guest-utilities): Init at 8.4.0 Change-Id: I4daf19dc1964be00554e1c598ef88897081f5d52 --- gnu/packages/virtualization.scm | 60 +++++++++++++++++++++++++++++++++ gnu/services/virtualization.scm | 1 + 2 files changed, 61 insertions(+) diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm index 061748bb4a..dc5602e06a 100644 --- a/gnu/packages/virtualization.scm +++ b/gnu/packages/virtualization.scm @@ -91,6 +91,7 @@ (define-module (gnu packages virtualization) #:use-module (gnu packages gnome) #:use-module (gnu packages gnupg) #:use-module (gnu packages golang) + #:use-module (gnu packages golang-build) #:use-module (gnu packages graphviz) #:use-module (gnu packages gtk) #:use-module (gnu packages haskell) @@ -2778,6 +2779,65 @@ (define-public xen (license license:gpl2) (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux")))) +(define-public xe-guest-utilities + (package + (name "xe-guest-utilities") + (version "8.4.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/xenserver/xe-guest-utilities") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1yqspizhq3ii6cz2w75slaxy8838yyri9pmgc2q1radnm7w735if")))) + (build-system go-build-system) + (arguments + (list + #:import-path "github.com/xenserver/xe-guest-utilities" + #:install-source? #f + #:tests? #f ; There are no tests. + #:phases + #~(modify-phases %standard-phases + ;; Despite using go-build-system, this project does not use Go's build + ;; infrastructure to do anything, instead relying on a Makefile. + ;; NOTE: This target builds a tarball, but it is only filled with + ;; 2 binaries, 1 script, and a bunch of text files; it is tiny. + (add-after 'patch-source-shebangs 'fix-udev-rule + (lambda* (#:key inputs import-path #:allow-other-keys) + (substitute* (string-append "src/" import-path "/mk/xen-vcpu-hotplug.rules") + (("/bin/sh") (search-input-file inputs "/bin/sh"))))) + (replace 'build + (lambda* (#:key import-path #:allow-other-keys) + (with-directory-excursion (string-append "src/" import-path) + ;; Explicitly state version, removes git as native-input. + ;; NOTE: The final step of the Makefile's build target is to "cd" + ;; to the final build directory. + (invoke "make" (string-append "RELEASE=" #$version) "build")))) + ;; The default "install" actions produce package-manager-specific + ;; outputs, .deb, .rpm, and .tgz. We just copy the final build + ;; products out. + (replace 'install + (lambda* (#:key outputs import-path #:allow-other-keys) + (let* ((stage (string-append "src/" import-path "/build/stage")) + (out (assoc-ref outputs "out"))) + ;; Put udev rules in #$output/lib/udev/rules.d/ + (copy-recursively (string-append stage "/etc/udev") + (string-append out "/lib/udev")) + ;; Copy produced binaries and scripts + (copy-recursively (string-append stage "/usr") out))))))) + (native-inputs (list go-golang-org-x-sys)) + (inputs (list bash-minimal)) + (home-page "https://github.com/xenserver/xe-guest-utilities") + (synopsis "XenServer guest utilities for unix-like operating systems") + (description "The XenServer guest utilities enable a Xen-based hypervisor, +(Citrix XenServer, XCP-NG, etc.) to work with a Xen-enabled Unix-like guest VMs. +This allows the guest to share information about its state back to the host, +such IP address, memory usage, etc. and allows the host to inform the guest VM +about events that change the virtualized hardware, such as hotplugging.") + (license license:bsd-2))) + (define-public osinfo-db-tools (package (name "osinfo-db-tools") diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm index d87e494348..c9f8225570 100644 --- a/gnu/services/virtualization.scm +++ b/gnu/services/virtualization.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2022 Oleg Pykhalov <go.wigust <at> gmail.com> ;;; Copyright © 2022 Leo Nikkilä <hello <at> lnikki.la> ;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il> +;;; Copyright © 2024 Raven Hallsby <karl <at> hallsby.com> ;;; ;;; This file is part of GNU Guix. ;;; -- 2.45.2
pelzflorian <at> pelzflorian.de, ludo <at> gnu.org, matt <at> excalamus.com, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Tue, 23 Jul 2024 05:25:01 GMT) Full text and rfc822 format available.Message #11 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: Karl Hallsby <karl <at> hallsby.com> To: 72249 <at> debbugs.gnu.org Cc: Karl Hallsby <karl <at> hallsby.com> Subject: [PATCH 2/2] services: Add xe-guest-utilities-service-type. Date: Tue, 23 Jul 2024 00:22:38 -0500
* gnu/services/virtualization.scm (xe-guest-utilities-configuration, xe-guest-utilities-service-type): New variables. Change-Id: Ife4e79fa6d1a9d5a21bf7479488884f2a5cf8d56 --- doc/guix.texi | 30 ++++++ gnu/services/virtualization.scm | 178 +++++++++++++++++++++++++++++++- 2 files changed, 207 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9ba96af459..6a29731b95 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -36873,6 +36873,36 @@ 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-agent} service runs the agent on Guix guests. + +@quotation Note +The default Linux-libre kernel that Guix ships already enables the +necessary features for a guest. There is nothing you need to enable for +the guest to fully support paravirtualization features. +@end quotation + +@defvar xe-guest-agent-service-type +Service type for the QEMU guest agent service. +@end defvar + +@deftp {Data Type} xe-guest-agent-configuration +Configuration for the @code{xen-guest-agent} service. + +@table @asis +@item @code{package} (default: @code{xen-guest-utilities}) +The Xen guest utilities package to use. + +@item @code{pid-file} (default: @code{"/var/run/xe-daemon.pid"}) +Path to the file holding the PID of xe-deamon. +@end table +@end deftp + @anchor{build-vm} @subsubheading Virtual Build Machines diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm index c9f8225570..29d5de6cc7 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-agent-configuration + xe-guest-agent-service-type)) (define (uglify-field-name field-name) (let ((str (symbol->string field-name))) @@ -1004,6 +1010,77 @@ (define qemu-guest-agent-service-type (default-value (qemu-guest-agent-configuration)) (description "Run the QEMU guest agent."))) + +;;; +;;; Guest agent for VMs running under Xen +;;; +(define-configuration/no-serialization xe-guest-agent-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.")) + +(define (generate-xe-guest-agent-documentation) + "Generate documentation for xe-guest-agent fields" + (generate-documentation + `((xe-guest-agent-configuration ,xe-guest-agent-configuration-fields)) + 'xe-guest-agent-configuration)) + +(define (xe-guest-agent-shepherd-service config) + (let ((xe-guest-utils (xe-guest-agent-configuration-package config)) + (pid-file (xe-guest-agent-configuration-pid-file config))) + (list + (shepherd-service + (provision '(xe-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 "/var/log/xe-daemon.log" + #: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-agent-udev-rules-service config) + (let ((guest-utils (xe-guest-agent-configuration-package config))) + (list + (file->udev-rule "z10_xen-vcpu-hotplug.rules" + (file-append + guest-utils + ;; I hate this z10_ prefix too + "/lib/udev/rules.d/z10_xen-vcpu-hotplug.rules"))))) + +(define xe-guest-agent-service-type + (service-type + (name 'xe-guest-agent) + (extensions + (list (service-extension shepherd-root-service-type + xe-guest-agent-shepherd-service) + (service-extension udev-service-type + xe-guest-agent-udev-rules-service))) + (default-value (xe-guest-agent-configuration)) + (description "Run the Xen guest management utilities."))) + ;;; ;;; Secrets for guest VMs. @@ -1860,3 +1937,102 @@ (define hurd-vm-service-type (description "Provide a virtual machine (VM) running GNU/Hurd, also known as a @dfn{childhurd}."))) + +(define-configuration/no-serialization xe-guest-utilities-configuration + (xe-guest-utilities + (file-like xe-guest-utilities) + "XenServer guest utilities package.") + (pid-file + (string "/var/run/xe-daemon.pid") + "File holding the PID of xe-deamon.")) + +(define (generate-xe-guest-utilities-documentation) + "Generate documentation for xe-guest-utilities fields" + (generate-documentation + `((xe-guest-utilities-configuration ,xe-guest-utilities-configuration-fields)) + 'xe-guest-utilities-configuration)) + +(define (xe-guest-utils-service config) + (let ((pid-file (xe-guest-utilities-configuration-pid-file config))) + (list + ;; Generate <shepherd-service>s that run the xe-daemon forever. + (shepherd-service + (documentation "Run the xe-guest-utilities daemon.") + (provision '(xe-guest-utilities-daemon)) + (requirement '(xe-guest-utilities-procfs + xe-guest-utilities-distro)) + (start #~(make-forkexec-constructor + (list #$(file-append xe-guest-utilities "/bin/xe-daemon") + "-p" #$pid-file) + #:pid-file #$pid-file + #:environment-variables + (list (string-append + "PATH=/run/current-system/profile/bin:" + "/run/current-system/profile/sbin:" + #$(file-append coreutils "/bin") ":" + #$(file-append iproute "/bin"))))) + (stop #~(make-kill-destructor))) + + ;; Generate one-shot <shepherd-service>s that informs the host hypervisor about + ;; the distribution of the guest (Guix in this case) + (shepherd-service + (documentation "Inform host hypervisor of guest's distribution.") + (provision '(xe-guest-utilities-distro)) + (requirement '(;;xe-guest-utilities-xend + )) + (one-shot? #t) + (start #~(make-forkexec-constructor + (list #$(file-append xe-guest-utilities "/bin/xe-linux-distribution") + "/var/run/xe-linux-distribution") + #:environment-variables + (list (string-append + "PATH=" + #$(file-append xe-guest-utilities "/bin") ":" + #$(file-append coreutils "/bin") ":" ;uname & co + #$(file-append gawk "/bin") ":" + #$(file-append sed "/bin"))))) + (stop #~(make-kill-destructor))) + + ;; Generate <shepherd-service>s to mount the xen directory in /proc. + (shepherd-service + (documentation "Mount /proc/xen files.") + (provision '(xe-guest-utilities-procfs)) + (requirement '(file-systems)) + (start #~(lambda () + (mount "xenfs" "/proc/xen" "/proc/xen") + (member "/proc/xen" (mount-points)))) + (stop #~(lambda () + (umount "/proc/xen" MNT_DETACH) + (not (member "/proc/xen" (mount-points)))))) + + ;; Generate <shepherd-service>s to create the necessary temporary directories for XenStore. + (shepherd-service + (documentation "Provide a temporary directory for XenStore.") + (provision '(xe-guest-utilities-tmp-dir)) + (one-shot? #t) + (requirement '(file-systems)) + (start #~(lambda () + (mkdir "/var/run/xenstored") + (chmod o755 "/var/run/xenstored"))) + (stop #~(lambda () + (delete-file-recursively "/var/run/xenstored"))))))) + +(define (xe-guest-utils-udev-rules-service config) + (let ((guest-utils (xe-guest-utilities-configuration-xe-guest-utilities config))) + (list + (file->udev-rule "z10_xen-vcpu-hotplug.rules" + (file-append + guest-utils + ;; I hate this z10_ prefix too + "/etc/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-utils-service) + (service-extension udev-service-type + xe-guest-utils-udev-rules-service))) + (default-value (xe-guest-utilities-configuration)) + (description + "Enable a Guix System VM to communicate with a Xen-based hypervisor host."))) -- 2.45.2
sharlatanus <at> gmail.com, guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Wed, 08 Jan 2025 20:11:02 GMT) Full text and rfc822 format available.Message #14 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: Karl Hallsby <karl <at> hallsby.com> To: 72249 <at> debbugs.gnu.org Cc: Karl Hallsby <karl <at> hallsby.com> Subject: [PATCH 1/2] gnu: Add xe-guest-utilities. Date: Wed, 8 Jan 2025 14:10:25 -0600
* gnu/packages/virtualization.scm (xe-guest-utilities): Init at 8.4.0 Change-Id: I4daf19dc1964be00554e1c598ef88897081f5d52 --- gnu/packages/virtualization.scm | 88 +++++++++++++++++++++++++++++++++ gnu/services/virtualization.scm | 1 + 2 files changed, 89 insertions(+) diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm index 9dff421341..3b162474af 100644 --- a/gnu/packages/virtualization.scm +++ b/gnu/packages/virtualization.scm @@ -104,6 +104,7 @@ (define-module (gnu packages virtualization) #:use-module (gnu packages gnome) #:use-module (gnu packages gnupg) #:use-module (gnu packages golang) + #:use-module (gnu packages golang-build) #:use-module (gnu packages gperf) #:use-module (gnu packages graphviz) #:use-module (gnu packages gtk) @@ -2772,6 +2773,93 @@ (define-public xen (license license:gpl2) (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux")))) +(define-public xe-guest-utilities + (package + (name "xe-guest-utilities") + (version "8.4.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/xenserver/xe-guest-utilities") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1yqspizhq3ii6cz2w75slaxy8838yyri9pmgc2q1radnm7w735if")))) + (build-system go-build-system) + (arguments + (list + #:import-path "github.com/xenserver/xe-guest-utilities" + #:install-source? #f + #:tests? #f ; There are no tests. + #:phases + #~(modify-phases %standard-phases + ;; Despite using go-build-system, this project does not use Go's build + ;; infrastructure to do anything, instead relying on a Makefile. + ;; NOTE: This target builds a tarball, but it is only filled with + ;; 2 binaries, 1 script, and a bunch of text files; it is tiny. + (add-after 'patch-source-shebangs 'fix-udev-rule + (lambda* (#:key inputs import-path #:allow-other-keys) + (substitute* (string-append "src/" import-path "/mk/xen-vcpu-hotplug.rules") + (("/bin/sh") (search-input-file inputs "/bin/sh"))))) + (replace 'build + (lambda* (#:key import-path #:allow-other-keys) + (let* ((version #$version) + (version-split (string-split version #\.)) + (major-version (list-ref version-split 0)) + (minor-version (list-ref version-split 1)) + (micro-version (list-ref version-split 2)) + (build-number "0")) + (with-directory-excursion (string-append "src/" import-path) + ;; Perform a buggy substitution. In Guix, the Go's guestmetric + ;; import will resolve to the source version, NOT the version + ;; the Makefile and sed substituted into build/. So we perform + ;; the correct substitution. + ;; This file list is what make & sed substitute, but we do it + ;; in-place too. + (substitute* (list "xe-daemon/xe-daemon.go" + "syslog/syslog.go" + "system/system.go" + "guestmetric/guestmetric.go" + "guestmetric/guestmetric_linux.go" + "xenstoreclient/xenstore.go" + "xenstore/xenstore.go") + (("@PRODUCT_MAJOR_VERSION@") major-version) + (("@PRODUCT_MINOR_VERSION@") minor-version) + (("@PRODUCT_MICRO_VERSION@") micro-version) + (("@NUMERIC_BUILD_NUMBER@") build-number)) + ;; Explicitly state version, removes git as native-input and + ;; removes using git commit hash as an ID. + ;; NOTE: The final step of the Makefile's build target is to "cd" + ;; to the final build directory. + (invoke "make" "build" + (string-append "RELEASE=" version) + (string-append "PRODUCT_MAJOR_VERSION=" major-version) + (string-append "PRODUCT_MINOR_VERSION=" minor-version) + (string-append "PRODUCT_MICRO_VERSION=" micro-version)))))) + ;; The default "install" actions produce package-manager-specific + ;; outputs, .deb, .rpm, and .tgz. We just copy the final build + ;; products out. + (replace 'install + (lambda* (#:key outputs import-path #:allow-other-keys) + (let* ((stage (string-append "src/" import-path "/build/stage")) + (out (assoc-ref outputs "out"))) + ;; Put udev rules in #$output/lib/udev/rules.d/ + (copy-recursively (string-append stage "/etc/udev") + (string-append out "/lib/udev")) + ;; Copy produced binaries and scripts + (copy-recursively (string-append stage "/usr") out))))))) + (native-inputs (list go-golang-org-x-sys)) + (inputs (list bash-minimal)) + (home-page "https://github.com/xenserver/xe-guest-utilities") + (synopsis "XenServer guest utilities for unix-like operating systems") + (description "The XenServer guest utilities enable a Xen-based hypervisor, +(Citrix XenServer, XCP-ng, etc.) to work with a Xen-enabled Unix-like guest VMs. +This allows the guest to share information about its state back to the host, +such IP address, memory usage, etc. and allows the host to inform the guest VM +about events that change the virtualized hardware, such as hotplugging.") + (license license:bsd-2))) + (define-public osinfo-db-tools (package (name "osinfo-db-tools") diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm index 53f79e367b..c32c47484c 100644 --- a/gnu/services/virtualization.scm +++ b/gnu/services/virtualization.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2022 Oleg Pykhalov <go.wigust <at> gmail.com> ;;; Copyright © 2022 Leo Nikkilä <hello <at> lnikki.la> ;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il> +;;; Copyright © 2024 Raven Hallsby <karl <at> hallsby.com> ;;; ;;; This file is part of GNU Guix. ;;; base-commit: 4eaeff997907bc1b67884a6dc087756a50f175e2 -- 2.46.0
ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Wed, 08 Jan 2025 20:11:02 GMT) Full text and rfc822 format available.Message #17 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: Karl Hallsby <karl <at> hallsby.com> To: 72249 <at> debbugs.gnu.org Cc: Karl Hallsby <karl <at> hallsby.com> Subject: [PATCH 2/2] services: Add xe-guest-utilities-service-type. Date: Wed, 8 Jan 2025 14:10:26 -0600
* 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 | 37 +++++++++++++++ gnu/services/virtualization.scm | 81 ++++++++++++++++++++++++++++++++- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index f7b7569887..ee827717a1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -37328,6 +37328,43 @@ 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. + +@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"}) +Path to the file holding the PID of xe-deamon. + +@item @code{log-file} (default: @code{"/var/log/xe-guest-utilities.log"}) +Path to @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."))) + +;;; +;;; 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."))) + ;;; ;;; Secrets for guest VMs. -- 2.46.0
guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Thu, 09 Jan 2025 13:46:01 GMT) Full text and rfc822 format available.Message #20 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: Karl Hallsby <karl <at> hallsby.com> Cc: 72249 <at> debbugs.gnu.org, Maxim Cournoyer <maxim.cournoyer <at> gmail.com> Subject: Re: [bug#72249] [PATCH 2/2] services: Add xe-guest-utilities-service-type. Date: Thu, 09 Jan 2025 14:45:00 +0100
Hello, Karl Hallsby <karl <at> hallsby.com> skribis: > * gnu/services/virtualization.scm (xe-guest-utilities-configuration, > xe-guest-utilities-service-type): New variables. > * doc/guix.texi: Document them. > > Change-Id: Ife4e79fa6d1a9d5a21bf7479488884f2a5cf8d56 I’m only looking at the doc side of things. Minor comments: > +@cindex xen > +@cindex xen guest agent “Xen”, capitalized. > +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. I’m surprised it’s all “xe-”, not “xen-”, but I guess that’s the way it is. :-) It would be nice to add a sentence or two about what said utilities do, perhaps with a link to upstream documentation if that helps? > +@item @code{log-file} (default: @code{"/var/log/xe-guest-utilities.log"}) > +Path to @code{xe-guest-utilities} log file. “Name of the @code{xe-guest-utilities} log file.” (We use the term “path” for “search paths”.) Apart from that LGTM! Thanks, Ludo’.
ludo <at> gnu.org, maxim.cournoyer <at> gmail.com, guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Fri, 10 Jan 2025 07:02:01 GMT) Full text and rfc822 format available.Message #23 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: Karl Hallsby <karl <at> hallsby.com> To: 72249 <at> debbugs.gnu.org Cc: Karl Hallsby <karl <at> hallsby.com> Subject: [PATCH] services: Add xe-guest-utilities-service-type. Date: Fri, 10 Jan 2025 01:00:59 -0600
* 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."))) + +;;; +;;; 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."))) + ;;; ;;; Secrets for guest VMs. base-commit: 4eaeff997907bc1b67884a6dc087756a50f175e2 prerequisite-patch-id: daabcb5995f03ed867a27648e973e1c2203f2bc9 -- 2.46.0
guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Sat, 11 Jan 2025 21:47:01 GMT) Full text and rfc822 format available.Message #26 received at 72249 <at> debbugs.gnu.org (full text, mbox):
From: "Karl G. Hallsby" <karl <at> hallsby.com> To: 72249 <at> debbugs.gnu.org Cc: Ludovic Courtès <ludo <at> gnu.org>, Maxim Cournoyer <maxim.cournoyer <at> gmail.com> Subject: Re: [bug#72249] [PATCH 2/2] services: Add xe-guest-utilities-service-type. Date: Sat, 11 Jan 2025 15:45:59 -0600
Hi, Ludovic Courtès <ludo <at> gnu.org> writes: > “Xen”, capitalized. > It would be nice to add a sentence or two about what said utilities do, > perhaps with a link to upstream documentation if that helps? > (We use the term “path” for “search paths”.) All requested changes to documentation have been made. P.S. Sorry for double-emailing you Ludo, I'm still figuring out how to make Emacs, mu4e, debbugs, and everything else play well together.
Ludovic Courtès <ludo <at> gnu.org>
:Karl Hallsby <karl <at> hallsby.com>
:Message #31 received at 72249-done <at> debbugs.gnu.org (full text, mbox):
From: Ludovic Courtès <ludo <at> gnu.org> To: "Karl G. Hallsby" <karl <at> hallsby.com> Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, 72249-done <at> debbugs.gnu.org Subject: Re: [bug#72249] [PATCH 2/2] services: Add xe-guest-utilities-service-type. Date: Thu, 16 Jan 2025 09:04:36 +0100
Hello, Finally applied both patches, thank you! As a followup, it would be great if you could come up with a system test for this service and for Xen (I believe we have all the necessary packages for that, right?). Ludo’.
guix-patches <at> gnu.org
:bug#72249
; Package guix-patches
.
(Thu, 16 Jan 2025 17:03:02 GMT) Full text and rfc822 format available.Message #34 received at 72249-done <at> debbugs.gnu.org (full text, mbox):
From: "Karl G. Hallsby" <karl <at> hallsby.com> To: Ludovic Courtès <ludo <at> gnu.org> Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>, 72249-done <at> debbugs.gnu.org Subject: Re: [bug#72249] [PATCH 2/2] services: Add xe-guest-utilities-service-type. Date: Thu, 16 Jan 2025 11:02:39 -0600
Hello, > ... Xen (I believe we have all the necessary packages for that, right?) If you are talking about xen-guest-agent-service-type in 75445, then yes. Efraim merged the necessary packages, the service-type definition just needs to be merged. If you are talking about the xen package itself, I'm not sure. I have some patches sitting around for it because I wanted to separate some outputs. > As a followup, it would be great if you could come up with a system test > for this service and for Xen (I believe we have all the necessary > packages for that, right?). I agree, I would like some tests too. One of the problems for a system test for both this service-type (xe-guest-utilities-service-type) and xen-guest-utilities-service-type (the Rust-based one) is that they rely on the kernel exposing some Xen-related files in /proc and /dev. So unless the system test is running as a guest under a Xen hypervisor, I don't see how to test this. -- Raven Hallsby
Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Fri, 14 Feb 2025 12:24:15 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.