From patchwork Mon Apr 1 17:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zheng Junjie X-Patchwork-Id: 62455 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 8D62C27BBE9; Tue, 2 Apr 2024 16:42: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.9 required=5.0 tests=BAYES_00,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 0928727BBE2 for ; Tue, 2 Apr 2024 16:42:14 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrgH1-0004ZI-9p; Tue, 02 Apr 2024 11:42:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rrgGv-0004Yu-AE for guix-patches@gnu.org; Tue, 02 Apr 2024 11:42:01 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rrgGs-0000ty-Nc for guix-patches@gnu.org; Tue, 02 Apr 2024 11:42:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rrgGw-0001HH-Fr for guix-patches@gnu.org; Tue, 02 Apr 2024 11:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69899] [PATCH 0/7] support to use `guix system vm' with riscv64. Resent-From: Zheng Junjie Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 02 Apr 2024 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69899 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 69899@debbugs.gnu.org, Leo Famulari Received: via spool by 69899-submit@debbugs.gnu.org id=B69899.17120724684681 (code B ref 69899); Tue, 02 Apr 2024 15:42:02 +0000 Received: (at 69899) by debbugs.gnu.org; 2 Apr 2024 15:41:08 +0000 Received: from localhost ([127.0.0.1]:55027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrgG4-0001DR-9q for submit@debbugs.gnu.org; Tue, 02 Apr 2024 11:41:08 -0400 Received: from smtp81.cstnet.cn ([159.226.251.81]:39484 helo=cstnet.cn) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrgFz-0001C7-MS for 69899@debbugs.gnu.org; Tue, 02 Apr 2024 11:41:06 -0400 Received: from m (unknown [111.0.51.68]) by APP-03 (Coremail) with SMTP id rQCowADnCCb+JgxmeS0BAQ--.25712S2; Tue, 02 Apr 2024 23:40:48 +0800 (CST) References: <87ttksgheo.fsf@iscas.ac.cn> <877chidsht.fsf@gnu.org> User-agent: mu4e 1.10.8; emacs 30.0.50 From: Zheng Junjie Date: Tue, 02 Apr 2024 01:20:12 +0800 In-reply-to: <877chidsht.fsf@gnu.org> Message-ID: <87zfub3h8l.fsf@iscas.ac.cn> MIME-Version: 1.0 X-CM-TRANSID: rQCowADnCCb+JgxmeS0BAQ--.25712S2 X-Coremail-Antispam: 1UD129KBjvJXoW7WrWfWryrtr1DCrWkKF17KFg_yoW8Xw4UpF 4SgF42kF4DGrySyrnFgr17ZFyxtrWjkw13WFykA3yrG3s09rnFvrnayF48Cr98Gr1Fg3W2 yFyjva43Xa4DA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvFb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vE77IFxV W8XVW5AwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE 14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j6r4UM28EF7xvwVC2z280aV AFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x0 82IY62kv0487M2AExVA0xI801c8C04v7Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcVAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWU XVWUAwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAF wI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvj xUgg_TUUUUU X-Originating-IP: [111.0.51.68] X-CM-SenderInfo: x2kh0wxmxqyx3h6l2u1dvotugofq/ 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Ludovic Courtès writes: > Hi, > > Zheng Junjie skribis: > >> Leo Famulari writes: >> >>> Hi, thanks for these patches! >>> >>> On Tue, Mar 19, 2024 at 11:15:53PM +0800, Zheng Junjie wrote: >>>> hello!. this patchset make `guix system vm --target=riscv64-linux-gnu' work. >>>> and `guix system vm --system=riscv64-linux` also work, But there is a problem >>>> that the qemu running with --system=riscv64-linux is also riscv architecture, >>>> now you have to manually modify to use native qemu or the guix of qemu-system >>>> on qemu-user is too slow. and must enable qemu-binfmt. >>> >>> So, what should we do about the problem? What's the ideal solution for >>> Guix? I don't have any experience with this subject matter. >> >> I've come up with two ideas: >> >> 1. Force the current system's qemu to be used, on x86_64 and -s >> riscv64-linux, use x86_64's qemu. >> 2. add an environment variable, GUIX_QEMU, to allow the internal qemu >> execution to be replaced >> >> There may be other solutions, but I can't think of them yet. > > Thing is, ‘--system=X’ is supposed to be giving the exact same result as > if you were building natively on X. Thus, it’s not surprising that > ‘guix system vm --system=X’ gives on a QEMU binary built for X. > > Now, it’s admittedly not very useful in this case. I believe the > attached patch implements #1 (I wasn’t able to test it yet because too > many things had to be built). How does it sound? it works, and the following patch is required. And maybe shebang interpreter also need override %CURRENT-SYSTEM?[1] Even though when the Shebang interpreter cannot execute, the file will be interpreted and executed by the current shell. > > diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm > index 7d9d07ebb7..a2743453e7 100644 > --- a/gnu/system/vm.scm > +++ b/gnu/system/vm.scm > @@ -287,8 +287,11 @@ (define* (system-qemu-image/shared-store-script os > #~(format #f "/tmp/guix-image-~a" (basename #$base-image))) > > (define qemu-exec > - #~(list #+(file-append qemu "/bin/" > - (qemu-command (or target system))) > + #~(list #+(with-parameters ((%current-system %system) > + (%current-target-system #f)) > + ;; Override %CURRENT-SYSTEM to always use a native emulator. > + (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? > > > Thanks, > Ludo’. [1] https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/vm.scm?h=9e9ec741d0dc5ce58f8d21d31800ff2cafce128f#n328 From e178de931859399abdd4bd3300b7ce7c5593a6e3 Mon Sep 17 00:00:00 2001 Message-ID: From: Zheng Junjie Date: Tue, 2 Apr 2024 00:59:54 +0800 Subject: [PATCH] vm: Don't add -enable-kvm when SYSTEM and %system are not same. * gnu/system/vm.scm (common-qemu-options): Don't add -enable-kvm when SYSTEM and %system are not same. Change-Id: Ie6c602b297c39423a693fdc26bed1627266e5911 --- gnu/system/vm.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index a2743453e7..42e9a08722 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -212,7 +212,8 @@ (define* (virtualized-operating-system os (define* (common-qemu-options image shared-fs #:key rw-image? - (target (%current-target-system))) + (target (%current-target-system)) + (system (%current-system))) "Return the a string-value gexp with the common QEMU options to boot IMAGE, with '-virtfs' options for the host file systems listed in SHARED-FS." @@ -223,7 +224,9 @@ (define* (common-qemu-options image shared-fs #~(;; Only enable kvm if we see /dev/kvm exists. ;; This allows users without hardware virtualization to still use these ;; commands. - #$@(if (and (not target) (file-exists? "/dev/kvm")) + #$@(if (and (not target) + (string=? system %system) + (file-exists? "/dev/kvm")) '("-enable-kvm") '()) @@ -308,7 +311,8 @@ (define* (system-qemu-image/shared-store-script os (map file-system-mapping-source (cons %store-mapping mappings)) #:rw-image? (not volatile?) - #:target target) + #:target target + #:system system) "-m " (number->string #$memory-size) #$@options)) base-commit: 9e9ec741d0dc5ce58f8d21d31800ff2cafce128f prerequisite-patch-id: 6183d199c58355eea1a85e1f1fe51f2f5fe44f65 -- 2.41.0