From patchwork Thu Jul 28 15:03:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timotej Lazar X-Patchwork-Id: 41038 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id EFA6127BBEA; Thu, 28 Jul 2022 16:05:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3A61227BBE9 for ; Thu, 28 Jul 2022 16:05:18 +0100 (BST) Received: from localhost ([::1]:59408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH54f-0003Xs-AG for patchwork@mira.cbaines.net; Thu, 28 Jul 2022 11:05:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH53W-0003Vt-FY for guix-patches@gnu.org; Thu, 28 Jul 2022 11:04:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH53S-0003Yt-5I for guix-patches@gnu.org; Thu, 28 Jul 2022 11:04:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oH53R-0000Xj-Py for guix-patches@gnu.org; Thu, 28 Jul 2022 11:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56813] [PATCH 1/2] services: qemu-guest-agent: Fix arguments to qemu-ga. Resent-From: Timotej Lazar Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 28 Jul 2022 15:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56813 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56813@debbugs.gnu.org Cc: Timotej Lazar Received: via spool by 56813-submit@debbugs.gnu.org id=B56813.16590206262046 (code B ref 56813); Thu, 28 Jul 2022 15:04:01 +0000 Received: (at 56813) by debbugs.gnu.org; 28 Jul 2022 15:03:46 +0000 Received: from localhost ([127.0.0.1]:59262 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oH53B-0000Ww-W4 for submit@debbugs.gnu.org; Thu, 28 Jul 2022 11:03:46 -0400 Received: from araneo.si ([90.157.193.204]:53554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oH539-0000Wk-0f for 56813@debbugs.gnu.org; Thu, 28 Jul 2022 11:03:45 -0400 Received: from araneo.si (localhost.lan [127.0.0.1]) by araneo.si (OpenSMTPD) with ESMTP id eba549bc for <56813@debbugs.gnu.org>; Thu, 28 Jul 2022 15:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=araneo.si; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=20180623; bh=f6UJHSAe+ZRty9GlWclPM aONNgU=; b=ot4JtNiAFHkAHw+rLArNppHHtbro2OL5e7byfSr+KSH1pMqrcnSRM IVN3TzjJyQ15v9uxqrUNRuILmltCKBkz7ijjNxgr8KivExlTaJXVgGyOjkv8TJ92 8P1JUBvRkYFB/ge980LJi4WGZSoWuXZ0XIHm7fKf+519O/tmWOGfhm4EbauKx6+g oEb+bNjz7ssTq8FIwqSexqTehrNnstw4ZH2nk8Y9za7CxQJ9QKKJGEVtRLct9AXH QclQCqIUXuWE52elEDDOHZ6VQAQ9mVnkdhoNbo3wp1m6GkZ2xih3Ms5VVaUTEOaY 2+HV385Uqx5DyUHt38gvI7whL6GRf8eBA== Received: by araneo.si (OpenSMTPD) with ESMTPSA id 519c11cb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 28 Jul 2022 15:03:41 +0000 (UTC) From: Timotej Lazar Date: Thu, 28 Jul 2022 17:03:25 +0200 Message-Id: <20220728150326.14182-1-timotej.lazar@araneo.si> X-Mailer: git-send-email 2.36.1 In-Reply-To: <87y1wdb7yk.fsf@araneo.si> References: <87y1wdb7yk.fsf@araneo.si> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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)))))) From patchwork Thu Jul 28 15:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timotej Lazar X-Patchwork-Id: 41039 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1193927BBEA; Thu, 28 Jul 2022 16:06:52 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 79BC427BBE9 for ; Thu, 28 Jul 2022 16:06:51 +0100 (BST) Received: from localhost ([::1]:33354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH56A-00058Y-KM for patchwork@mira.cbaines.net; Thu, 28 Jul 2022 11:06:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH53W-0003Vu-EM for guix-patches@gnu.org; Thu, 28 Jul 2022 11:04:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41285) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH53S-0003Yu-8W for guix-patches@gnu.org; Thu, 28 Jul 2022 11:04:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oH53S-0000Xq-4b for guix-patches@gnu.org; Thu, 28 Jul 2022 11:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56813] [PATCH 2/2] tests: Add qemu-guest-agent system test. Resent-From: Timotej Lazar Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 28 Jul 2022 15:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56813 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56813@debbugs.gnu.org Cc: Timotej Lazar Received: via spool by 56813-submit@debbugs.gnu.org id=B56813.16590206302066 (code B ref 56813); Thu, 28 Jul 2022 15:04:02 +0000 Received: (at 56813) by debbugs.gnu.org; 28 Jul 2022 15:03:50 +0000 Received: from localhost ([127.0.0.1]:59266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oH53G-0000XG-At for submit@debbugs.gnu.org; Thu, 28 Jul 2022 11:03:50 -0400 Received: from araneo.si ([90.157.193.204]:53554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oH53B-0000Wk-T0 for 56813@debbugs.gnu.org; Thu, 28 Jul 2022 11:03:46 -0400 Received: from araneo.si (localhost.lan [127.0.0.1]) by araneo.si (OpenSMTPD) with ESMTP id 58c9ebac for <56813@debbugs.gnu.org>; Thu, 28 Jul 2022 15:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=araneo.si; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=20180623; bh=2uAWWxxuFtNTO66J0AV8h OEeA14=; b=XqwV2hjNXFxqqPolKuaqAYqI5MeZZDzJpbs437kZY7ygj4I+Kvd0m /0sV1rNCykXkNZvutoB9fiT3mtc76VOhogVoH9eqlpqXKSkSpSpSAuO21ZuG9bWg CMGxLGI2FLI8qSHAtZRcnmF1FgVU3FelaHLo0nvAEY6gUtexDfHuKSTZcbMIKxSu SnVICS+Z5UitTCXkvJcM4OeRs2B2MTwEzjCImEK0UGoCo5l2PsakhOCaFTW9Aeoc qc+suyfIg/f81s+nz54tVilUe8brYRmVbslyGjzVGYDn9tpRtyEyyv/1x5fPECVy fPsF7VrTwX2UuYbNN1A/Sp4/Natls61WQ== Received: by araneo.si (OpenSMTPD) with ESMTPSA id 5a514d13 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 28 Jul 2022 15:03:42 +0000 (UTC) From: Timotej Lazar Date: Thu, 28 Jul 2022 17:03:26 +0200 Message-Id: <20220728150326.14182-2-timotej.lazar@araneo.si> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220728150326.14182-1-timotej.lazar@araneo.si> References: <87y1wdb7yk.fsf@araneo.si> <20220728150326.14182-1-timotej.lazar@araneo.si> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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 ;; . "-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.