[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
08/17: PRELIMINARY: Add support for hibernation.
From: |
Mark H. Weaver |
Subject: |
08/17: PRELIMINARY: Add support for hibernation. |
Date: |
Mon, 23 Apr 2018 03:07:28 -0400 (EDT) |
mhw pushed a commit to branch reproduce-bug-29774
in repository guix.
commit af8d58efa05927b24694c87379cccc378f3fdde7
Author: Mark H Weaver <address@hidden>
Date: Sun Aug 14 05:33:12 2016 -0400
PRELIMINARY: Add support for hibernation.
* gnu/build/linux-boot.scm (boot-system): Look for a resume=<device-name>
argument on the linux command line, and if present, attempt to resume from
hibernation.
* gnu/services/desktop.scm (<elogind-configuration>): Change the default
value of the 'handle-hibernate-key' key to 'hibernate'.
---
gnu/build/linux-boot.scm | 50 +++++++++++++++++++++++++++++++++++++++++++++---
gnu/services/desktop.scm | 6 +-----
2 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d8726..3d2828a 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -479,9 +479,10 @@ upon error."
(call-with-error-handling
(lambda ()
(mount-essential-file-systems)
- (let* ((args (linux-command-line))
- (to-load (find-long-option "--load" args))
- (root (find-long-option "--root" args)))
+ (let* ((args (linux-command-line))
+ (to-load (find-long-option "--load" args))
+ (root (find-long-option "--root" args))
+ (resume-device (find-long-option "resume" args)))
(when (member "--repl" args)
(start-repl))
@@ -506,6 +507,49 @@ upon error."
(unless (pre-mount)
(error "pre-mount actions failed")))
+ ;;
+ ;; Attempt to resume from hibernation.
+ ;;
+ ;; IMPORTANT: This *must* happen before we mount any filesystems on
+ ;; disk. Quoting linux-libre/Documentation/swsusp.txt:
+ ;;
+ ;; * BIG FAT WARNING **************************************************
+ ;; *
+ ;; * If you touch anything on disk between suspend and resume...
+ ;; * ...kiss your data goodbye.
+ ;; *
+ ;; * If you do resume from initrd after your filesystems are mounted...
+ ;; * ...bye bye root partition.
+ ;; * [this is actually same case as above]
+ ;; *
+ (when (and resume-device
+ (file-exists? resume-device)
+ (file-exists? "/sys/power/resume"))
+ (false-if-exception
+ (let* ((device-base-name
+ ;; The base name of the device file, after resolving
+ ;; symlinks.
+ (let loop ((file resume-device))
+ (match (stat:type (lstat file))
+ ('symlink
+ (let ((target (readlink file)))
+ (if (string-prefix? "/" target)
+ (loop target)
+ (loop (string-append (dirname file) "/"
target)))))
+ (_ (basename file)))))
+ (major+minor
+ ;; The major:minor string (e.g. "8:2") corresponding
+ ;; to the resume device.
+ (call-with-input-file (string-append "/sys/class/block/"
+ device-base-name
+ "/dev")
+ read-line)))
+ ;; Write the major:minor string to /sys/power/resume
+ ;; to attempt resume from hibernation.
+ (when major+minor
+ (call-with-output-file "/sys/power/resume"
+ (cut display major+minor <>))))))
+
(if root
(mount-root-file-system (canonicalize-device-spec root)
root-fs-type
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 517d5d3..e19c85c 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -574,11 +574,7 @@ include the @command{udisksctl} command, part of UDisks,
and GNOME Disks."
(handle-suspend-key elogind-handle-suspend-key
(default 'suspend))
(handle-hibernate-key elogind-handle-hibernate-key
- ;; (default 'hibernate)
- ;; XXX Ignore it for now, since we don't
- ;; yet handle resume-from-hibernation in
- ;; our initrd.
- (default 'ignore))
+ (default 'hibernate))
(handle-lid-switch elogind-handle-lid-switch
(default 'suspend))
(handle-lid-switch-docked elogind-handle-lid-switch-docked
- branch reproduce-bug-29774 created (now aa4c57d), Mark H. Weaver, 2018/04/23
- 04/17: gnu: tracker: Use openjpeg-2., Mark H. Weaver, 2018/04/23
- 03/17: LOCAL_ONLY: gnu: emacs: Remove imagemagick from inputs., Mark H. Weaver, 2018/04/23
- 02/17: LOCAL_ONLY: profiles: Use the canonical glibc-utf8-locales to build profiles., Mark H. Weaver, 2018/04/23
- 10/17: TEMPORARY_HACK: Disable tests for e2fsprogs., Mark H. Weaver, 2018/04/23
- 07/17: gnu: golly: More tweaks., Mark H. Weaver, 2018/04/23
- 09/17: BROKEN: gnu: e2fsprogs: Update to 1.44.1., Mark H. Weaver, 2018/04/23
- 12/17: TEMPORARY_HACK: gnu: modem-manager: Update to 1.7.991 [unstable branch!], Mark H. Weaver, 2018/04/23
- 11/17: TEMPORARY_HACK: gnu: python-pygobject: Disable tests., Mark H. Weaver, 2018/04/23
- 08/17: PRELIMINARY: Add support for hibernation.,
Mark H. Weaver <=
- 13/17: DRAFT: Fix gjs build., Mark H. Weaver, 2018/04/23
- 14/17: WIP: gnu: libnl: Use invoke., Mark H. Weaver, 2018/04/23
- 17/17: UNTESTED: records: Detect duplicate field initializers., Mark H. Weaver, 2018/04/23
- 06/17: gnu: golly: Use system lua., Mark H. Weaver, 2018/04/23
- 01/17: Merge branch 'master' into core-updates, Mark H. Weaver, 2018/04/23
- 16/17: DRAFT: gnu: vlc: Update to 3.0.1, and add more inputs., Mark H. Weaver, 2018/04/23
- 05/17: PRELIMINARY: Add celestia., Mark H. Weaver, 2018/04/23
- 15/17: WIP: gnu: Add icedove., Mark H. Weaver, 2018/04/23