From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id aBJUHTwNqmFkRQAAgWs5BA (envelope-from ) for ; Fri, 03 Dec 2021 13:27:40 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id cAkTGTwNqmE0WwAAB5/wlQ (envelope-from ) for ; Fri, 03 Dec 2021 12:27:40 +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 0EFCA2D20 for ; Fri, 3 Dec 2021 13:27:40 +0100 (CET) Received: from localhost ([::1]:37916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mt7f8-0003Y9-TC for larch@yhetil.org; Fri, 03 Dec 2021 07:27:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mt7be-0007cV-CB for guix-patches@gnu.org; Fri, 03 Dec 2021 07:24:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mt7be-0007Aj-2U for guix-patches@gnu.org; Fri, 03 Dec 2021 07:24:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mt7bd-0004zu-Ml for guix-patches@gnu.org; Fri, 03 Dec 2021 07:24:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52204] [PATCH v3] 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: Fri, 03 Dec 2021 12:24:01 +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.163853419519146 (code B ref 52204); Fri, 03 Dec 2021 12:24:01 +0000 Received: (at 52204) by debbugs.gnu.org; 3 Dec 2021 12:23:15 +0000 Received: from localhost ([127.0.0.1]:50196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mt7as-0004yk-Lq for submit@debbugs.gnu.org; Fri, 03 Dec 2021 07:23:15 -0500 Received: from mail-ed1-f54.google.com ([209.85.208.54]:40523) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mt7ap-0004yT-6M for 52204@debbugs.gnu.org; Fri, 03 Dec 2021 07:23:13 -0500 Received: by mail-ed1-f54.google.com with SMTP id r25so10703240edq.7 for <52204@debbugs.gnu.org>; Fri, 03 Dec 2021 04:23:11 -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=GtPB2OeTkxwSqHLT1GcJtZ+b3K4XcC5cbFUjHwWf3j0=; b=DRFtTQ765fZA970FZIDVCz0G3Of0HR24/kLb+Mu/5+FEIO3cX+ineeWL4EOoxEEH9B SUdzoDfEH+63Xm4/AGYCTvceWaoPkc+u3wpsi0vNkmzvFktQBEAniQD1wf37E2sMiPMC oE0wUY8VOXxNnY2VkQvbL01fFlU1lSRJanGp1EnVjTTZ92ZhgVywKu989F+U301XQRu4 4/3zOcPMXRyHQGBbOHwgMtQERq/+jO0zd2OlkrYwllsGy9Lb7TjxQI22sRJcwf37ioOW PCQ2t8fp6vZCn+g/DVgSx4jvbEhcL1LjUx/NdhzkBgm/BEqRWadMRVTOH7K00brdFp2g 9U6A== 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=GtPB2OeTkxwSqHLT1GcJtZ+b3K4XcC5cbFUjHwWf3j0=; b=v2dg1RIyr7qRWDTqjk5goN+10DoCWqEtZa4+n8UAhCANfg31GsYHVyXTDf9X02Plmf Lbqub+V0w0OvXWDWcop8sGWOJhtbSPQ4ZKpC0BqQyH0I3XVYRw9mEMmrEvZ4SNmOdOdg rDDVXjVn7JZ4yz26H3O3la1fpvqehBE6ZivVz9l0b21yR9rZyDKSsXZZE7DLVYCAwu7g +z9fF+hotkp8mJ4NGpsn66QxPAJJBWOlYTMSN18boI9ZQwSn3kD95LmgMfzjs5pSx2bJ YzhyLlFOu2Aa6zLCktVwZRs1Pd/YNOXWhFhlCKR18DIToxOrZrTlbNjGZ1lD1C1A0PCM JU8w== X-Gm-Message-State: AOAM530JhUYJi2qcFSLukIjAbKepQ5sRy+6lsCnzqrSpFK7MjkbCxLPr fCnyI094LAg/2QnRGVNzklOj4TeCLHlWAQ== X-Google-Smtp-Source: ABdhPJwCnp49zLJMXgcrHWeI3I7EJzZj2cMQxR9sYDoppQJUFwR9aTBDUDVViuDSMoI+7xpbZMWVuw== X-Received: by 2002:a17:906:6851:: with SMTP id a17mr22883378ejs.338.1638534185185; Fri, 03 Dec 2021 04:23:05 -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 gn26sm1922362ejc.14.2021.12.03.04.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 04:23:04 -0800 (PST) From: Attila Lendvai Date: Fri, 3 Dec 2021 13:22:02 +0100 Message-Id: <20211203122201.483-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=1638534460; 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=GtPB2OeTkxwSqHLT1GcJtZ+b3K4XcC5cbFUjHwWf3j0=; b=YzBr/aF4Fr8mT8nagnq7ZiDKDA/tP+VpYw7z20eBuYAimKEq65e0oJgt6yrr1tJISFrYcB aYX43ZQ45wsfJQdNMZqWgeQzqSYfLSqkjdjpHoi9Opp0W70gYcRpoZm4LVYFyXPmn5kzQu zc7xsSmUuezX9CGvbarvtwIznAgCQZEQKNk9xtL5ueKXmY1YCfS47g70K5sE5t2DIHMp8e UcYMECpHwissJxBWZEMaJVcfFLZ0RYuEoT6wsW8QnhMw1h6cRciL+LpLvQ4Jun1vMcpHsY Fn6q4BZ1Slrio5kYiNzxRy9LGkmoDJHvbriexQ25yBuxVSMvMNy1k5Yi3ptvlQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638534460; a=rsa-sha256; cv=none; b=PAP2UHBjadEeUj0xEsM8zZyf+k+CZeIIFRhcyH7UxwnDjj/mTIu5T98bsZjfigmFZOmnwp nMPqOBmIZ+mERvrwwh1rr8sQavi0Q/aojEUMs6kpZQdnsT4vqiyUq9mnSzRQP6e5KxrCYk kq4C3Ybv1IBG2R45WCiyTE+/cqu/FjN0eq1+Rvx+1ymbi50H73a7CBK4BSaa7gD1zm+Y+1 pRPoJQY/cqslbIj/JwnHofPCYYub9DCfS0ETHJVU8aTMeC2p2rOG4xbxqMljO3I2GqL1Nk OkxCJ5p05TWM8G56P2oO8uWtbCpXB2h3urd2bK0Rt5oc1umqPHK3A6sMH9NBPQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=DRFtTQ76; 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=DRFtTQ76; 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: 0EFCA2D20 X-Spam-Score: -0.42 X-Migadu-Scanner: scn0.migadu.com X-TUID: hnbdyfYmBGJ7 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. (common-qemu-options): Remove '-vga stg'; it is the default since QEMU 2.2. * 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. --- v3: also remove the '-vga std' from the qemu command line; it's been the default since forever. doc/guix.texi | 23 +++++++++++++++++++---- gnu/system/vm.scm | 3 ++- guix/scripts/system.scm | 10 ++++++++++ 3 files changed, 31 insertions(+), 5 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..f1541cf30c 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -712,7 +712,6 @@ (define (virtfs-option fs) "-device" "virtio-rng-pci,rng=guixsd-vm-rng" #$@(map virtfs-option shared-fs) - "-vga std" (format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly=on" #$image))) @@ -754,6 +753,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