From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KDrVCbIcqWGN9gAAgWs5BA (envelope-from ) for ; Thu, 02 Dec 2021 20:21:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id iDdZBbIcqWFvMwAAbx9fmQ (envelope-from ) for ; Thu, 02 Dec 2021 19:21:22 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AAD8315E28 for ; Thu, 2 Dec 2021 20:21:21 +0100 (CET) Received: from localhost ([::1]:52768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1msrdw-0006MY-RP for larch@yhetil.org; Thu, 02 Dec 2021 14:21:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1msrde-0006KO-JR for guix-patches@gnu.org; Thu, 02 Dec 2021 14:21:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:37765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1msrde-0001vq-AO for guix-patches@gnu.org; Thu, 02 Dec 2021 14:21:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1msrde-0007Oo-2w for guix-patches@gnu.org; Thu, 02 Dec 2021 14:21:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52204] [PATCH v2] guix system vm: Add --no-graphic CLI argument. References: <20211130191312.32131-1-attila@lendvai.name> In-Reply-To: <20211130191312.32131-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 02 Dec 2021 19:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52204 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52204@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 52204-submit@debbugs.gnu.org id=B52204.163847282328373 (code B ref 52204); Thu, 02 Dec 2021 19:21:02 +0000 Received: (at 52204) by debbugs.gnu.org; 2 Dec 2021 19:20:23 +0000 Received: from localhost ([127.0.0.1]:49311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1msrd1-0007NZ-4F for submit@debbugs.gnu.org; Thu, 02 Dec 2021 14:20:23 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:46930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1msrcx-0007NL-CW for 52204@debbugs.gnu.org; Thu, 02 Dec 2021 14:20:21 -0500 Received: by mail-wr1-f45.google.com with SMTP id u1so811655wru.13 for <52204@debbugs.gnu.org>; Thu, 02 Dec 2021 11:20:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uF1K7lidnTRGhem1CRqiI5IV9BFdU523IFUumItjcWg=; b=E6yXmTvowZsWnWhiim3OiBmAWAU2ZiYv1DP41gNQqy7OD/upnc+TTj2ULf2/ifnH9H ozEe8j0yvNtF1iZEZ/FZCr7GLB3/iUJxPkeTgpxPmpKvBD3cqWQsI/hIeFhrNvYedTZn 0qQmqD7i5JxWTbfM6xrTq+k2ZDDXYZdJY3dzhvTJt+Re6E8wLHg8UozttIs5SL/vZLIn bLQyEWLV9EpKTNBYifDoQkKgCFBofZ6eLLajKKc9WcNDtVaeEhfFCSAjMzNuTw2M2/hJ n1tuit1jXu2Gg/JXBuqTPscWQRrKX1ED+wWVEl4Zi7ne1sNrEDw1Joofv3xrm9qFfZuf mwiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=uF1K7lidnTRGhem1CRqiI5IV9BFdU523IFUumItjcWg=; b=JvYon0moHDmAAS4zvf0NTDNGwsCCrlRi1iJQVUQWzNxjjijFnZut44SO5XV0/GVM/W NRkOuRQYFiJFTY3KFa2XDcOYUUUCSGpxTTtcREpjvxoMLlVoW95+yUlprYx8lbZGwurM msnekBt/vlBUFML1wGneG6qlYUoSRQg+pY0KYF6M7IUa0+3cDLWFBtPJj1KVNzkRQCFu LLgQiDJnd/ts0KUK1c8cq5TAHWTYrdzzTxOuKHQ2Qylbaz9NqfvKi2wlZ354g1w4HQKZ bHz1bY/K35Fr/+PzxFav4ysmXZTSnI48nKS1axuUciLptF29JwEkkc6WYE7uj1DKksPE zjhA== X-Gm-Message-State: AOAM533qd/ErZuJWwp9ap/gos7p56J4Io86UcSba1G2jLHAmVjVq4RDo wkrnUM5FaALN/0i6pXR5MMYhPEVTvUdFuQ== X-Google-Smtp-Source: ABdhPJy0aVQNva/1wVzKu9RIQdEmi/UJUKX7cibn0M7IDjqadc6tvSf3N6hdqMIMi2F+dWhlXCFbaQ== X-Received: by 2002:a05:6000:1a41:: with SMTP id t1mr16695545wry.261.1638472813315; Thu, 02 Dec 2021 11:20:13 -0800 (PST) Received: from lelap.lan (catv-89-132-208-37.catv.broadband.hu. [89.132.208.37]) by smtp.gmail.com with ESMTPSA id y7sm589088wrw.55.2021.12.02.11.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 11:20:12 -0800 (PST) From: Attila Lendvai Date: Thu, 2 Dec 2021 20:18:56 +0100 Message-Id: <20211202191855.29552-1-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638472881; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=uF1K7lidnTRGhem1CRqiI5IV9BFdU523IFUumItjcWg=; b=NXuEAFaJ1BbY9cYqg/4dMTiysWjk95x+HJmqMLkcP39lvz4ZZ4jcT4sbfuEGJk0uqkajAP j4WTFo9V2IJZp5GgnLLghnH0k/np1bN+H3ukNdvmLRhWuecDyekp0kIS753U6kUYYzgr3F 3quWlTZ3+X6zP69JCm5+sbmgy/fi4F/YEw7lB8kaOOd4zQaMaCUfiwDwInHDALJUaw1IS0 dFL3npgcwBFK+/4FYuMaDljWUFFFgQl4RJ7+uoMbGeIh1NylR+EAw34CZi95fHUNrgDixt I/ohu3ovMJ/6gjk7BASzxqx2Uw40+JBouA8e70FE18V8gopodBokronnQ4JjGg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638472881; a=rsa-sha256; cv=none; b=lrEcTOfaSAocEd0a/v8KTlpSJcbUB3DuUuU6fZ3pQ/l8xvQYvo5tYLiB3OZjoq8oVGH2PG WC+wiqxFFB4zGoM7+XyttnIsFwETWwN8tMy5J1MS/UM7ccf1cXbTNkBiFT9fEm20K2QIH9 5HH/HvKp+ThTsSK+oYgh966GtupiwyQRpOMgA1Bkt/29HXrsR+elaw7TWcXeTmQaldGDj+ AYG4jb9p0VYFEN0Kq7W4jYQSXBV50JAqQ0rOq/pdsshKViUPLpVTBfIEtJ1zr7Hlael0L3 xxmVWLT5+/9OIr9OpLjn4kKuBDkgj6h6I8WdHG41JkGNnZ0hAf+1nU8WtoRh+g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=E6yXmTvo; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.42 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=E6yXmTvo; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: AAD8315E28 X-Spam-Score: -0.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: PWJVxWLaVrvT It configures QEMU to use the tty it was started in for IO (as opposed to opening a separate graphical window). This enables copy-pasting and scrollback. Exit QEMU with C-a x. * gnu/system/vm.scm (system-qemu-image/shared-store-script): Also add the '-nographic' QEMU argument when called with #:graphic? #false. * guix/scripts/system.scm (system-derivation-for-action): Propagate the #:graphic? keyword arg. (perform-action): Add and propagate the #:graphic? keyword arg. (show-help): Add --no-graphic CLI arg. (%options): Process the new --no-graphic CLI arg. (process-action): Feed in the CLI arg through the #:graphic? keyword arg. * doc/guix.texi (Invoking guix system): Add example to combine guix system and invoking the vm start script into one command. Split the description of the various options into separate paragraphs. Adde a paragraph to describe --no-graphic. --- after consuling on #guix, i'm resending the two commits (the doc and the code) as one, because that is preferred. doc/guix.texi | 23 +++++++++++++++++++---- gnu/system/vm.scm | 2 ++ guix/scripts/system.scm | 10 ++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2a166e3a89..ca670f8971 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -34500,8 +34500,8 @@ passed. @cindex virtual machine @cindex VM @anchor{guix system vm} -Build a virtual machine that contains the operating system declared in -@var{file}, and return a script to run that virtual machine (VM). +Build a virtual machine (VM) that contains the operating system declared +in @var{file}, and return a script to run that VM. @quotation Note The @code{vm} action and others below @@ -34520,6 +34520,12 @@ emulated machine: $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -nic user,model=virtio-net-pci @end example +It's possible to combine the two steps into one: + +@example +$ $(guix system vm my-config.scm) -m 1024 +@end example + The VM shares its store with the host system. Additional file systems can be shared between the host and the VM using @@ -34543,8 +34549,17 @@ store of the host can then be mounted. The @option{--full-boot} option forces a complete boot sequence, starting with the bootloader. This requires more disk space since a root image containing at least the kernel, initrd, and bootloader data files must -be created. The @option{--image-size} option can be used to specify the -size of the image. +be created. + +The @option{--image-size} option can be used to specify the size of the +image. + +The @option{--no-graphic} option will instruct @command{guix system} to +spawn a headless VM that will use the invoking tty for IO. Among other +things, this enables copy-pasting, and scrollback. Use the @kbd{ctrl-a} +prefix to issue QEMU commands; e.g. @kbd{ctrl-a h} prints a help, +@kbd{ctrl-a x} quits the VM, and @kbd{ctrl-a c} switches between the +QEMU monitor and the VM. @cindex System images, creation in various formats @cindex Creating system images in various formats diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 1e2d8b47c2..0a95302584 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -754,6 +754,8 @@ (define kernel-arguments (define qemu-exec #~(list #+(file-append qemu "/bin/" (qemu-command (or target system))) + ;; Tells qemu to use the terminal it was started in for IO. + #$@(if graphic? '() #~("-nographic")) #$@(if full-boot? #~() #~("-kernel" #$(operating-system-kernel-file os) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 7faa92fd7d..1675fccf50 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -689,6 +689,7 @@ (define file-systems (define* (system-derivation-for-action image action #:key full-boot? + (graphic? #t) container-shared-network? mappings) "Return as a monadic value the derivation for IMAGE according to ACTION." @@ -706,6 +707,7 @@ (define* (system-derivation-for-action image action ((vm) (system-qemu-image/shared-store-script os #:full-boot? full-boot? + #:graphic? graphic? #:disk-image-size (if full-boot? image-size @@ -772,6 +774,7 @@ (define* (perform-action action image dry-run? derivations-only? use-substitutes? target full-boot? + (graphic? #t) container-shared-network? (mappings '()) (gc-root #f)) @@ -825,6 +828,7 @@ (define bootcfg (mlet* %store-monad ((sys (system-derivation-for-action image action #:full-boot? full-boot? + #:graphic? graphic? #:container-shared-network? container-shared-network? #:mappings mappings)) @@ -1012,6 +1016,8 @@ (define (show-help) register it as a garbage collector root")) (display (G_ " --full-boot for 'vm', make a full boot sequence")) + (display (G_ " + --no-graphic for 'vm', use the tty that we are started in for IO")) (display (G_ " --skip-checks skip file system and initrd module safety checks")) (display (G_ " @@ -1081,6 +1087,9 @@ (define %options (option '("full-boot") #f #f (lambda (opt name arg result) (alist-cons 'full-boot? #t result))) + (option '("no-graphic") #f #f + (lambda (opt name arg result) + (alist-cons 'no-graphic? #t result))) (option '("save-provenance") #f #f (lambda (opt name arg result) (alist-cons 'save-provenance? #t result))) @@ -1266,6 +1275,7 @@ (define (graph-backend) #:validate-reconfigure (assoc-ref opts 'validate-reconfigure) #:full-boot? (assoc-ref opts 'full-boot?) + #:graphic? (if (assoc-ref opts 'no-graphic?) #f #t) #:container-shared-network? (assoc-ref opts 'container-shared-network?) #:mappings (filter-map (match-lambda -- 2.33.0