Subject: [PATCH 1/2] vm: override %CURRENT-SYSTEM to always use a native emulator.

From: Zheng Junjie <[email-masked]>
Date: Mon, 15 Apr 2024 23:33:37 +0800

From: Ludovic Courtès <[email-masked]>

* gnu/system/vm.scm (system-qemu-image/shared-store-script): override
%CURRENT-SYSTEM to always use a native emulator.

Change-Id: Ia2cb7cca33eec018d810bd00d0208b58392ea483
---
 gnu/system/vm.scm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 7d9d07ebb7..2d1a4a9df1 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?
@@ -325,7 +328,9 @@ (define* (system-qemu-image/shared-store-script os
       #~(call-with-output-file #$output
           (lambda (port)
             (format port "#!~a~%"
-                    #+(file-append bash "/bin/sh"))
+                    #+(with-parameters ((%current-system %system)
+                                        (%current-target-system #f))
+                        (file-append bash "/bin/sh")))
             #$@(if volatile?
                    #~()
                    #~((format port "~a~%" #+copy-image)))

base-commit: 6b3c90f638292f9604a221ac6dbf22234f6e4c4b
-- 
2.41.0