From be6520e6a58d7f6ee58f4cab76db9d1245410113 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 26 Mar 2020 23:21:11 +0100 Subject: vm: Distinguish between success and failure of the guest code. Fixes . Reported by Tobias Geerinckx-Rice . * 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. --- gnu/build/vm.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gnu/build') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 9a9e5bd001..79eed48c1f 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Christopher Allan Webber ;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe @@ -183,6 +183,15 @@ the #:references-graphs parameter of 'derivation'." '()) arch-specific-flags)) + (unless (file-exists? "xchg/.exit-status") + (error "VM did not produce an exit code")) + + (match (call-with-input-file "xchg/.exit-status" read) + (0 #t) + (status (error "guest VM code exited with a non-zero status" status))) + + (delete-file "xchg/.exit-status") + ;; When MAKE-DISK-IMAGE? is true, the image is in OUTPUT already. (unless make-disk-image? (if single-file-output? -- cgit v1.2.3