unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Attila Lendvai <attila@lendvai.name>
To: 52204@debbugs.gnu.org
Cc: Attila Lendvai <attila@lendvai.name>
Subject: [bug#52204] [PATCH] guix system vm: Add --no-graphic CLI argument.
Date: Tue, 30 Nov 2021 20:13:13 +0100	[thread overview]
Message-ID: <20211130191312.32131-1-attila@lendvai.name> (raw)

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.
---
 gnu/system/vm.scm       |  2 ++
 guix/scripts/system.scm | 10 ++++++++++
 2 files changed, 12 insertions(+)

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





             reply	other threads:[~2021-11-30 19:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 19:13 Attila Lendvai [this message]
2021-12-02 14:24 ` [bug#52204] [PATCH] guix system vm: Add --no-graphic CLI argument Mathieu Othacehe
2021-12-02 19:09 ` [bug#52204] [PATCH 2/2] doc: Document guix system --no-graphic Attila Lendvai
2021-12-02 19:18 ` [bug#52204] [PATCH v2] guix system vm: Add --no-graphic CLI argument Attila Lendvai
2021-12-03 10:38   ` [bug#52204] [PATCH] " Mathieu Othacehe
2021-12-03 12:22 ` [bug#52204] [PATCH v3] " Attila Lendvai
2021-12-03 13:34   ` bug#52204: [PATCH] " Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211130191312.32131-1-attila@lendvai.name \
    --to=attila@lendvai.name \
    --cc=52204@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).