GNU bug report logs -
#56813
[PATCH 0/2] Add a test for qemu-guest-agent service
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56813 in the body.
You can then email your comments to 56813 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#56813
; Package
guix-patches
.
(Thu, 28 Jul 2022 14:59:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Timotej Lazar <timotej.lazar <at> araneo.si>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Thu, 28 Jul 2022 14:59:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
these patches fix some issues with the QEMU guest agent service, and add
a system test for it. The test runs the service in a marionette VM and
tries communicating with it. For that, I enabled the guest agent serial
device in marionette QEMU options. This change touches all system tests,
but should be harmless.
I’m not sure if it would be better instead to add a keyword argument to
make-marionette for (extra) extra QEMU options. In any case, all tests
that pass on master still pass after this change, at least on x86_64
(most installation tests currently fail here).
Please let me know if I should change or improve anything. Thanks!
Timotej Lazar (2):
services: qemu-guest-agent: Fix arguments to qemu-ga.
tests: Add qemu-guest-agent system test.
gnu/build/marionette.scm | 5 +-
gnu/services/virtualization.scm | 12 ++---
gnu/tests/virtualization.scm | 84 +++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+), 8 deletions(-)
--
2.36.1
Information forwarded
to
guix-patches <at> gnu.org
:
bug#56813
; Package
guix-patches
.
(Thu, 28 Jul 2022 15:04:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 56813 <at> debbugs.gnu.org (full text, mbox):
Fix the check for empty device path. Do not use --daemonize, since that is
handled by make-forkexec-constructor. Drop the --pidfile option which is
unused without --daemonize.
* gnu/services/virtualization.scm (qemu-guest-agent-shepherd-service): Modify
command arguments.
---
gnu/services/virtualization.scm | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm
index 41afe451c1..406752b35c 100644
--- a/gnu/services/virtualization.scm
+++ b/gnu/services/virtualization.scm
@@ -879,13 +879,11 @@ (define (qemu-guest-agent-shepherd-service config)
(provision '(qemu-guest-agent))
(documentation "Run the QEMU guest agent.")
(start #~(make-forkexec-constructor
- `(,(string-append #$qemu "/bin/qemu-ga") "--daemon"
- "--pidfile=/var/run/qemu-ga.pid"
- "--statedir=/var/run"
- ,@(if #$device
- (list (string-append "--path=" #$device))
- '()))
- #:pid-file "/var/run/qemu-ga.pid"
+ `(,(string-append #$qemu "/bin/qemu-ga")
+ "--statedir" "/var/run"
+ ,@(if (string-null? #$device)
+ '()
+ (list "--path" #$device)))
#:log-file "/var/log/qemu-ga.log"))
(stop #~(make-kill-destructor))))))
--
2.36.1
Information forwarded
to
guix-patches <at> gnu.org
:
bug#56813
; Package
guix-patches
.
(Thu, 28 Jul 2022 15:04:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 56813 <at> debbugs.gnu.org (full text, mbox):
Enable the QEMU guest agent interface in marionette VMs, run the
qemu-guest-agent service in one and try talking to it.
* gnu/build/marionette.scm (make-marionette): Enable the guest agent device.
* gnu/tests/virtualization.scm (run-qemu-guest-agent-test): New procedure.
(%test-qemu-guest-agent): New variable.
---
gnu/build/marionette.scm | 5 ++-
gnu/tests/virtualization.scm | 84 ++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/gnu/build/marionette.scm b/gnu/build/marionette.scm
index 0d2af642c8..2b241d19e8 100644
--- a/gnu/build/marionette.scm
+++ b/gnu/build/marionette.scm
@@ -105,11 +105,14 @@ (define extra-options
"-monitor" (string-append "unix:" socket-directory "/monitor")
"-chardev" (string-append "socket,id=repl,path=" socket-directory
"/repl")
+ "-chardev" (string-append "socket,id=qga,server=on,wait=off,path="
+ socket-directory "/qemu-ga")
;; See
;; <http://www.linux-kvm.org/page/VMchannel_Requirements#Invocation>.
"-device" "virtio-serial"
- "-device" "virtserialport,chardev=repl,name=org.gnu.guix.port.0"))
+ "-device" "virtserialport,chardev=repl,name=org.gnu.guix.port.0"
+ "-device" "virtserialport,chardev=qga,name=org.qemu.guest_agent.0"))
(define (accept* port)
(match (select (list port) '() (list port) timeout)
diff --git a/gnu/tests/virtualization.scm b/gnu/tests/virtualization.scm
index 299acc4945..4bd56e5d9d 100644
--- a/gnu/tests/virtualization.scm
+++ b/gnu/tests/virtualization.scm
@@ -37,6 +37,7 @@ (define-module (gnu tests virtualization)
#:use-module (guix records)
#:use-module (guix store)
#:export (%test-libvirt
+ %test-qemu-guest-agent
%test-childhurd))
@@ -115,6 +116,89 @@ (define %test-libvirt
(description "Connect to the running LIBVIRT service.")
(value (run-libvirt-test))))
+
+;;;
+;;; QEMU Guest Agent service.
+;;;
+
+(define %qemu-guest-agent-os
+ (simple-operating-system
+ (service qemu-guest-agent-service-type)))
+
+(define (run-qemu-guest-agent-test)
+ "Run tests in %QEMU-GUEST-AGENT-OS."
+ (define os
+ (marionette-operating-system
+ %qemu-guest-agent-os
+ #:imported-modules '((gnu services herd))))
+
+ (define vm
+ (virtual-machine
+ (operating-system os)
+ (port-forwardings '())))
+
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (gnu build marionette)
+ (ice-9 rdelim)
+ (srfi srfi-64))
+
+ (define marionette
+ ;; Ensure we look for the socket in the correct place below.
+ (make-marionette (list #$vm) #:socket-directory "/tmp"))
+
+ (define* (try-read port #:optional (attempts 10))
+ ;; Try reading from a port several times before giving up.
+ (cond ((char-ready? port)
+ (let ((response (read-line port)))
+ (close-port port)
+ response))
+ ((> attempts 1)
+ (sleep 1)
+ (try-read port (- attempts 1)))
+ (else "")))
+
+ (define (run command)
+ ;; Run a QEMU guest agent command and return the response.
+ (let ((s (socket PF_UNIX SOCK_STREAM 0)))
+ (connect s AF_UNIX "/tmp/qemu-ga")
+ (display command s)
+ (try-read s)))
+
+ (test-runner-current (system-test-runner #$output))
+ (test-begin "qemu-guest-agent")
+
+ (test-assert "service running"
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (match (start-service 'qemu-guest-agent)
+ (#f #f)
+ (('service response-parts ...)
+ (match (assq-ref response-parts 'running)
+ ((pid) (number? pid))))))
+ marionette))
+
+ (test-equal "ping guest"
+ "{\"return\": {}}"
+ (run "{\"execute\": \"guest-ping\"}"))
+
+ (test-assert "get network interfaces"
+ (string-contains
+ (run "{\"execute\": \"guest-network-get-interfaces\"}")
+ "127.0.0.1"))
+
+ (test-end))))
+
+ (gexp->derivation "qemu-guest-agent-test" test))
+
+(define %test-qemu-guest-agent
+ (system-test
+ (name "qemu-guest-agent")
+ (description "Run commands in a virtual machine using QEMU guest agent.")
+ (value (run-qemu-guest-agent-test))))
+
;;;
;;; GNU/Hurd virtual machines, aka. childhurds.
--
2.36.1
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Tue, 09 Aug 2022 15:24:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Timotej Lazar <timotej.lazar <at> araneo.si>
:
bug acknowledged by developer.
(Tue, 09 Aug 2022 15:24:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 56813-done <at> debbugs.gnu.org (full text, mbox):
Hi Timotej,
Timotej Lazar <timotej.lazar <at> araneo.si> skribis:
> these patches fix some issues with the QEMU guest agent service, and add
> a system test for it. The test runs the service in a marionette VM and
> tries communicating with it. For that, I enabled the guest agent serial
> device in marionette QEMU options. This change touches all system tests,
> but should be harmless.
Yes, sounds good.
> I’m not sure if it would be better instead to add a keyword argument to
> make-marionette for (extra) extra QEMU options. In any case, all tests
> that pass on master still pass after this change, at least on x86_64
> (most installation tests currently fail here).
Perfect.
> services: qemu-guest-agent: Fix arguments to qemu-ga.
> tests: Add qemu-guest-agent system test.
Applied, thanks!
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 07 Sep 2022 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 346 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.