@@ 230,10 230,35 @@ services as defined by OS."
to-restart)))))))
(define (load-system-for-kexec eval os)
- "Load OS so that it can be rebooted into via kexec, if supported. Return
-true on success."
- (eval #~(and (string-contains %host-type "-linux")
- (primitive-load #$(kexec-loading-program os)))))
+ "Load OS so that it can be rebooted into via kexec, if supported. Print a
+warning in case of failure."
+ (mlet %store-monad
+ ((result (eval
+ #~(and (string-contains %host-type "-linux")
+ (with-exception-handler
+ (lambda (c)
+ (define kind-and-args?
+ (exception-predicate &exception-with-kind-and-args))
+
+ (list 'exception
+ (if (kind-and-args? c)
+ (call-with-output-string
+ (lambda (port)
+ (print-exception port #f
+ (exception-kind c)
+ (exception-args c))))
+ (object->string c))))
+ (lambda ()
+ (primitive-load #$(kexec-loading-program os))
+ 'success)
+ #:unwind? #t)))))
+ (match result
+ ('success
+ (return #t))
+ (('exception message)
+ (warning (G_ "failed to load operating system for kexec: ~a~%")
+ message)
+ (return #f)))))
;;;