diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-03-26 23:21:11 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-03-26 23:45:41 +0100 |
commit | be6520e6a58d7f6ee58f4cab76db9d1245410113 (patch) | |
tree | 0ac32bca8086d876583a9ae148b032a29ec9de64 /gnu/system | |
parent | 60eee3e6de2a11b425496bbdf90bfe1f807c8f49 (diff) | |
download | guix-be6520e6a58d7f6ee58f4cab76db9d1245410113.tar guix-be6520e6a58d7f6ee58f4cab76db9d1245410113.tar.gz |
vm: Distinguish between success and failure of the guest code.
Fixes <https://bugs.gnu.org/34276>.
Reported by Tobias Geerinckx-Rice <me@tobias.gr>.
* gnu/system/vm.scm (expression->derivation-in-linux-vm)[loader]:
Produce '/xchg/.exit-status' file upon success.
* gnu/build/vm.scm (load-in-linux-vm): Check for 'xchg/.exit-status'
once QEMU has completed and respond accordingly.
Diffstat (limited to 'gnu/system')
-rw-r--r-- | gnu/system/vm.scm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index d1c131ecb4..c6ec25a895 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -186,12 +186,15 @@ made available under the /xchg CIFS share." ;; the initrd. See example at ;; <https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00233.html>. (program-file "linux-vm-loader" - ;; When USER-BUILDER succeeds, reboot (indicating a - ;; success), otherwise die, which causes a kernel panic - ;; ("Attempted to kill init!"). - #~(if (zero? (system* #$user-builder)) - (reboot) - (exit 1)))) + ;; Communicate USER-BUILDER's exit status via /xchg so that + ;; the host can distinguish between success, failure, and + ;; kernel panic. + #~(let ((status (system* #$user-builder))) + (call-with-output-file "/xchg/.exit-status" + (lambda (port) + (write status port))) + (sync) + (reboot)))) (let ((initrd (or initrd (base-initrd file-systems |