[PATCH version-1.3.0 0/3] Enable SPICE for the Guix VM image.

DoneSubmitted by Maxim Cournoyer.
Details
One participant
  • Maxim Cournoyer
Owner
unassigned
Severity
normal
M
M
Maxim Cournoyer wrote on 6 May 2021 19:23
(address . guix-patches@gnu.org)
20210506172355.11694-1-maxim.cournoyer@gmail.com
These three patches enable the use of the SPICE protocol for the VM image,
which provides benefits such as dynamically resizing the display of
the guest, sharing the clip-board, smoother mouse support, etc.

To test, generate the image with something like:

$ image=$(./pre-inst-env guix system image -t qcow2 gnu/system/examples/vm-image.tmpl)
$ cp $image /tmp/vm-test.qcow2
$ chmod +w /tmp/vm-test.qcow2

Then launch a SPICE-capable solution such as GNOME Boxes, and enjoy!

I'd like to have these patches included in the RC2 that will go out later today.

Thanks,

Maxim Cournoyer (3):
gnu: spice-vdagent: Update to 0.21.0 and enable GTK+ support.
services: spice-vdagent: Clear the socket file prior to starting.
gnu: system: Add SPICE capability to the VM image.

gnu/packages/spice.scm | 26 +++++++++++++++++++-------
gnu/services/spice.scm | 31 +++++++++++++++----------------
gnu/system/examples/vm-image.tmpl | 11 ++++++++++-
3 files changed, 44 insertions(+), 24 deletions(-)

--
2.31.1
M
M
Maxim Cournoyer wrote on 6 May 2021 19:27
[PATCH version-1.3.0 1/3] gnu: spice-vdagent: Update to 0.21.0 and enable GTK+ support.
(address . 48262@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20210506172732.12294-1-maxim.cournoyer@gmail.com
* gnu/packages/spice.scm (spice-vdagent): Update to 0.21.0.
Remove trailing #t.
[make-flags]: New argument.
[phases]{fix-test-termination}: New phase.
[inputs]: Add gtk+.
[native-inputs]{procps}: New input.
---
gnu/packages/spice.scm | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)

Toggle diff (73 lines)
diff --git a/gnu/packages/spice.scm b/gnu/packages/spice.scm
index 92aeef7f79..0e47609b9e 100644
--- a/gnu/packages/spice.scm
+++ b/gnu/packages/spice.scm
@@ -261,7 +261,7 @@ Internet and from a wide variety of machine architectures.")
 (define-public spice-vdagent
   (package
     (name "spice-vdagent")
-    (version "0.20.0")
+    (version "0.21.0")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -269,11 +269,14 @@ Internet and from a wide variety of machine architectures.")
                 "spice-vdagent-" version ".tar.bz2"))
               (sha256
                (base32
-                "0n9k2kna2gd1zi6jv45zsp2jlv439nz5l5jjijirxqaycwi74srf"))))
+                "0n8jlc1pv6mkry161y656b1nk9hhhminjq6nymzmmyjl7k95ymzx"))))
     (build-system gnu-build-system)
     (arguments
      `(#:configure-flags
        '("--localstatedir=/var")
+       ;; The test-session-info test fails for unknown reasons (see:
+       ;; https://gitlab.freedesktop.org/spice/linux/vd_agent/-/issues/24).
+       #:make-flags '("XFAIL_TESTS=tests/test-session-info")
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-makefile.in
@@ -281,19 +284,27 @@ Internet and from a wide variety of machine architectures.")
              (substitute* "Makefile.in"
                (((string-append "\\$\\(mkdir_p\\) \\$\\(DESTDIR\\)"
                                 "\\$\\(localstatedir\\)/run/spice-vdagentd"))
-                 "-$(mkdir_p) $(DESTDIR)$(localstatedir)/run/spice-vdagentd"))
-             #t))
+                 "-$(mkdir_p) $(DESTDIR)$(localstatedir)/run/spice-vdagentd"))))
          (add-after 'unpack 'patch-spice-vdagent.desktop
            (lambda* (#:key outputs #:allow-other-keys)
             (substitute* "data/spice-vdagent.desktop"
               (("Exec=/usr/bin/spice-vdagent")
                (string-append "Exec=" (assoc-ref outputs "out")
-                              "/bin/spice-vdagent")))
-             #t)))))
+                              "/bin/spice-vdagent")))))
+         (add-after 'unpack 'fix-test-termination
+           (lambda _
+             ;; The termination tests depend on finding the socket file name
+             ;; in the spice-vdagent command line it launched, but by default
+             ;; ps truncates its output, which causes the test to fail (see:
+             ;; https://gitlab.freedesktop.org/spice/linux/vd_agent/-/merge_requests/36).
+             (substitute* "tests/test-termination.c"
+               (("ps -ef")
+                "ps -efww")))))))
     (inputs
       `(("alsa-lib" ,alsa-lib)
         ("dbus" ,dbus)
         ("glib" ,glib)
+        ("gtk+" ,gtk+)
         ("libdrm" ,libdrm)
         ("libpciaccess" ,libpciaccess)
         ("libx11" ,libx11)
@@ -303,7 +314,8 @@ Internet and from a wide variety of machine architectures.")
         ("libxrandr" ,libxrandr)
         ("spice-protocol" ,spice-protocol)))
     (native-inputs
-      `(("pkg-config" ,pkg-config)))
+     `(("pkg-config" ,pkg-config)
+       ("procps" ,procps)))             ;tests use 'ps'
     (synopsis "Spice agent for Linux")
     (description "Spice-vdagent enables sharing the clipboard and guest display
 resolution scaling on graphical console window resize.")
-- 
2.31.1
M
M
Maxim Cournoyer wrote on 6 May 2021 19:27
[PATCH version-1.3.0 2/3] services: spice-vdagent: Clear the socket file prior to starting.
(address . 48262@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20210506172732.12294-2-maxim.cournoyer@gmail.com
This fixes the following issue where spice-vdagent would fail to start if the
spice-vdagent-sock socket file already existed:

spice-vdagentd: Fatal could not create the server socket
/run/spice-vdagentd/spice-vdagent-sock: Error binding to address: Address
already in use

The requirement is also modified to depend on dbus-system, a cue taken from
upstream's own systemd service file (see 'data/spice-vdagentd.service' in the
sources).

* gnu/services/spice.scm (spice-vdagent-activation): Delete procedure.
(spice-vdagent-shepherd-service): Fix indentation.
[requirement]: Replace udev by dbus-system.
[start]: Ensure the spice-vdagentd run-time directory exists and that the
spice-vdagent-sock socket file does *not* exist before forking the daemon.
---
gnu/services/spice.scm | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)

Toggle diff (59 lines)
diff --git a/gnu/services/spice.scm b/gnu/services/spice.scm
index a2aee4ab2a..3b88e29043 100644
--- a/gnu/services/spice.scm
+++ b/gnu/services/spice.scm
@@ -34,28 +34,29 @@
   (spice-vdagent spice-vdagent-configuration-spice-vdagent
                  (default spice-vdagent)))
 
-(define (spice-vdagent-activation config)
-  "Return the activation gexp for CONFIG."
-  #~(begin
-      (use-modules (guix build utils))
-      (mkdir-p "/run/spice-vdagentd")))
-
 (define (spice-vdagent-shepherd-service config)
   "Return a <shepherd-service> for spice-vdagentd with CONFIG."
   (define spice-vdagent (spice-vdagent-configuration-spice-vdagent config))
 
   (define spice-vdagentd-command
     (list
-      (file-append spice-vdagent "/sbin/spice-vdagentd")
-      "-x"))
+     (file-append spice-vdagent "/sbin/spice-vdagentd")
+     "-x"))
 
   (list
-    (shepherd-service
-      (documentation "Spice vdagentd service")
-      (requirement '(udev))
-      (provision '(spice-vdagentd))
-      (start #~(make-forkexec-constructor '#$spice-vdagentd-command))
-      (stop #~(make-kill-destructor)))))
+   (shepherd-service
+    (documentation "Spice vdagentd service")
+    (requirement '(dbus-system))
+    (provision '(spice-vdagentd))
+    (start #~(lambda args
+               ;; spice-vdagentd supports being activated upon the client
+               ;; connecting to its socket; when not using such feature, the
+               ;; socket should not exist before vdagentd creates it itself.
+               (mkdir-p "/run/spice-vdagentd")
+               (false-if-exception
+                (delete-file "/run/spice-vdagentd/spice-vdagent-sock"))
+               (fork+exec-command '#$spice-vdagentd-command)))
+    (stop #~(make-kill-destructor)))))
 
 (define spice-vdagent-profile
   (compose list spice-vdagent-configuration-spice-vdagent))
@@ -67,8 +68,6 @@
    (extensions
     (list (service-extension shepherd-root-service-type
                              spice-vdagent-shepherd-service)
-          (service-extension activation-service-type
-                             spice-vdagent-activation)
           (service-extension profile-service-type
                              spice-vdagent-profile)))))
 
-- 
2.31.1
M
M
Maxim Cournoyer wrote on 6 May 2021 19:27
[PATCH version-1.3.0 3/3] gnu: system: Add SPICE capability to the VM image.
(address . 48262@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20210506172732.12294-3-maxim.cournoyer@gmail.com
* gnu/system/examples/vm-image.tmpl (services)
[spice-vdagent-service-type]: Add service.
[slim-service-type] <xorg-configuration>: Add the xf86-video-qxl module.
---
gnu/system/examples/vm-image.tmpl | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

Toggle diff (36 lines)
diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl
index bcb2ba614c..1a2dfca452 100644
--- a/gnu/system/examples/vm-image.tmpl
+++ b/gnu/system/examples/vm-image.tmpl
@@ -5,7 +5,7 @@
 ;;
 
 (use-modules (gnu) (guix) (srfi srfi-1))
-(use-service-modules desktop networking ssh xorg)
+(use-service-modules desktop networking spice ssh xorg)
 (use-package-modules bootloaders certs fonts nvi
                      package-management wget xorg)
 
@@ -75,11 +75,20 @@ root ALL=(ALL) ALL
                            (default-user "guest")
                            (xorg-configuration
                             (xorg-configuration
+                             ;; The QXL virtual GPU driver is added to provide
+                             ;; a better SPICE experience.
+                             (modules (cons xf86-video-qxl
+                                            %default-xorg-modules))
                              (keyboard-layout keyboard-layout)))))
 
                  ;; Uncomment the line below to add an SSH server.
                  ;;(service openssh-service-type)
 
+                 ;; Add support for the SPICE protocol, which enables dynamic
+                 ;; resizing of the guest screen resolution, clipboard
+                 ;; integration with the host, etc.
+                 (service spice-vdagent-service-type)
+
                  ;; Use the DHCP client service rather than NetworkManager.
                  (service dhcp-client-service-type))
 
-- 
2.31.1
M
M
Maxim Cournoyer wrote on 7 May 2021 17:36
(address . 48262-done@debbugs.gnu.org)
87h7jewo6q.fsf@gmail.com
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (41 lines)
> * gnu/system/examples/vm-image.tmpl (services)
> [spice-vdagent-service-type]: Add service.
> [slim-service-type] <xorg-configuration>: Add the xf86-video-qxl module.
> ---
> gnu/system/examples/vm-image.tmpl | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl
> index bcb2ba614c..1a2dfca452 100644
> --- a/gnu/system/examples/vm-image.tmpl
> +++ b/gnu/system/examples/vm-image.tmpl
> @@ -5,7 +5,7 @@
> ;;
>
> (use-modules (gnu) (guix) (srfi srfi-1))
> -(use-service-modules desktop networking ssh xorg)
> +(use-service-modules desktop networking spice ssh xorg)
> (use-package-modules bootloaders certs fonts nvi
> package-management wget xorg)
>
> @@ -75,11 +75,20 @@ root ALL=(ALL) ALL
> (default-user "guest")
> (xorg-configuration
> (xorg-configuration
> + ;; The QXL virtual GPU driver is added to provide
> + ;; a better SPICE experience.
> + (modules (cons xf86-video-qxl
> + %default-xorg-modules))
> (keyboard-layout keyboard-layout)))))
>
> ;; Uncomment the line below to add an SSH server.
> ;;(service openssh-service-type)
>
> + ;; Add support for the SPICE protocol, which enables dynamic
> + ;; resizing of the guest screen resolution, clipboard
> + ;; integration with the host, etc.
> + (service spice-vdagent-service-type)
> +
> ;; Use the DHCP client service rather than NetworkManager.
> (service dhcp-client-service-type))

I've now pushed this series to the version-1.3.0 branch.

Thank you,

Maxim
Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 48262@debbugs.gnu.org