[systemd-devel] [PATCHv5 0/3] hibernate-resume: implement support for resuming from hibernation

2014-08-26 Thread Ivan Shapovalov
This patchset allows systemd to parse resume= kernel command line parameter
and initiate resume from the specified device.

It adds:
- a 'systemd-hibernate-resume' tool which takes path to a device node and
  writes its major:minor to /sys/power/resume;
- a corresponding 'systemd-hibernate-resume@.service' templated unit;
- a 'systemd-hibernate-resume-generator' generator which parses the kernel
  command line and instantiates the unit as necessary.

This functionality already exists in-kernel, but only for /dev/sdXY-style
pathes. Implementing it in userspace allows to use arbitrary udev-created
symlinks, e. g. persistent block device pathes (/dev/disk/by-foo/bar) or
fstab-like specifiers (FOO=bar).

Userspace parsing of resume= kernel command line parameter has been
traditionally done in initramfs via shell scripts (for Arch Linux, this is
resume mkinitcpio hook), so I feel that this feature has its place within
systemd.

Due to the nature of hibernation, the resume unit must be activated before
any modifications to filesystems take place. This can happen only in initramfs
before mounting anything.

So, first patch orders all non-root fsck after local-fs-pre.target, which in
turn allows to order the resume unit before those fsck instances.

Second and third patches add the tool, the unit and the generator.

Thanks for reviewing!

v2: fix issues pointed out by Andrei:
- don't RemainAfterExit because it's useless
- don't attempt to resume outside of initramfs because it's unsafe
  (reiserfs replays journal even if mounted RO)

v3: fix mistakes spotted by Thomas:
- return 0 in main path of resume.c:process_resume()
- fix type and add missing cleanup attribute in resume-generator.c:main()

v4: drop the [RFC] prefix as there are no more issues with this approach;
incorporate feedback from Lennart:
- fix indentation in resume-generator.c:parse_proc_cmdline_item()
- remove overly aggressive 80-column line breaks
- don't Before=usr.mount and After=systemd-udevd.service
  as the respective configurations are deemed broken
- reword the Failed to resume message and downgrade it to log_info()

v5: add the binaries and preprocessed unit to respective .gitignore files
incorporate feedback from Lennart:
- rename systemd-resume-* to systemd-hibernate-resume-*
incorporate feedback from Dave:
- use fstab_node_to_udev_node() in the generator to also handle fstab-like
  specifiers

Ivan Shapovalov (3):
  units: order systemd-fsck@.service after local-fs-pre.target.
  hibernate-resume: add a tool to write a device node's major:minor to 
/sys/power/resume.
  hibernate-resume-generator: add a generator for instantiating the resume unit.

 .gitignore |  2 +
 Makefile-man.am| 21 +++
 Makefile.am| 28 +++--
 man/kernel-command-line.xml| 14 -
 man/systemd-hibernate-resume-generator.xml | 93 +
 man/systemd-hibernate-res...@.service.xml  | 81 +
 src/hibernate-resume/Makefile  |  1 +
 src/hibernate-resume/hibernate-resume.c| 81 +
 src/resume-generator/Makefile  |  1 +
 src/resume-generator/resume-generator.c| 95 ++
 units/.gitignore   |  1 +
 units/systemd-f...@.service.in |  2 +-
 units/systemd-hibernate-res...@.service.in | 20 +++
 13 files changed, 422 insertions(+), 18 deletions(-)
 create mode 100644 man/systemd-hibernate-resume-generator.xml
 create mode 100644 man/systemd-hibernate-res...@.service.xml
 create mode 12 src/hibernate-resume/Makefile
 create mode 100644 src/hibernate-resume/hibernate-resume.c
 create mode 12 src/resume-generator/Makefile
 create mode 100644 src/resume-generator/resume-generator.c
 create mode 100644 units/systemd-hibernate-res...@.service.in

-- 
2.1.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCHv5 0/3] hibernate-resume: implement support for resuming from hibernation

2014-08-26 Thread Lennart Poettering
On Tue, 26.08.14 23:53, Ivan Shapovalov (intelfx...@gmail.com) wrote:

Looks great, wanted to commit. But the series doesn't apply to current
git. Could you please rebase?

Thanks!

 This patchset allows systemd to parse resume= kernel command line parameter
 and initiate resume from the specified device.
 
 It adds:
 - a 'systemd-hibernate-resume' tool which takes path to a device node and
   writes its major:minor to /sys/power/resume;
 - a corresponding 'systemd-hibernate-resume@.service' templated unit;
 - a 'systemd-hibernate-resume-generator' generator which parses the kernel
   command line and instantiates the unit as necessary.
 
 This functionality already exists in-kernel, but only for /dev/sdXY-style
 pathes. Implementing it in userspace allows to use arbitrary udev-created
 symlinks, e. g. persistent block device pathes (/dev/disk/by-foo/bar) or
 fstab-like specifiers (FOO=bar).
 
 Userspace parsing of resume= kernel command line parameter has been
 traditionally done in initramfs via shell scripts (for Arch Linux, this is
 resume mkinitcpio hook), so I feel that this feature has its place within
 systemd.
 
 Due to the nature of hibernation, the resume unit must be activated before
 any modifications to filesystems take place. This can happen only in initramfs
 before mounting anything.
 
 So, first patch orders all non-root fsck after local-fs-pre.target, which in
 turn allows to order the resume unit before those fsck instances.
 
 Second and third patches add the tool, the unit and the generator.
 
 Thanks for reviewing!
 
 v2: fix issues pointed out by Andrei:
 - don't RemainAfterExit because it's useless
 - don't attempt to resume outside of initramfs because it's unsafe
   (reiserfs replays journal even if mounted RO)
 
 v3: fix mistakes spotted by Thomas:
 - return 0 in main path of resume.c:process_resume()
 - fix type and add missing cleanup attribute in resume-generator.c:main()
 
 v4: drop the [RFC] prefix as there are no more issues with this approach;
 incorporate feedback from Lennart:
 - fix indentation in resume-generator.c:parse_proc_cmdline_item()
 - remove overly aggressive 80-column line breaks
 - don't Before=usr.mount and After=systemd-udevd.service
   as the respective configurations are deemed broken
 - reword the Failed to resume message and downgrade it to log_info()
 
 v5: add the binaries and preprocessed unit to respective .gitignore files
 incorporate feedback from Lennart:
 - rename systemd-resume-* to systemd-hibernate-resume-*
 incorporate feedback from Dave:
 - use fstab_node_to_udev_node() in the generator to also handle fstab-like
   specifiers
 
 Ivan Shapovalov (3):
   units: order systemd-fsck@.service after local-fs-pre.target.
   hibernate-resume: add a tool to write a device node's major:minor to 
 /sys/power/resume.
   hibernate-resume-generator: add a generator for instantiating the resume 
 unit.
 
  .gitignore |  2 +
  Makefile-man.am| 21 +++
  Makefile.am| 28 +++--
  man/kernel-command-line.xml| 14 -
  man/systemd-hibernate-resume-generator.xml | 93 +
  man/systemd-hibernate-res...@.service.xml  | 81 +
  src/hibernate-resume/Makefile  |  1 +
  src/hibernate-resume/hibernate-resume.c| 81 +
  src/resume-generator/Makefile  |  1 +
  src/resume-generator/resume-generator.c| 95 
 ++
  units/.gitignore   |  1 +
  units/systemd-f...@.service.in |  2 +-
  units/systemd-hibernate-res...@.service.in | 20 +++
  13 files changed, 422 insertions(+), 18 deletions(-)
  create mode 100644 man/systemd-hibernate-resume-generator.xml
  create mode 100644 man/systemd-hibernate-res...@.service.xml
  create mode 12 src/hibernate-resume/Makefile
  create mode 100644 src/hibernate-resume/hibernate-resume.c
  create mode 12 src/resume-generator/Makefile
  create mode 100644 src/resume-generator/resume-generator.c
  create mode 100644 units/systemd-hibernate-res...@.service.in
 


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCHv5 0/3] hibernate-resume: implement support for resuming from hibernation

2014-08-26 Thread Ivan Shapovalov
On Tuesday 26 August 2014 at 22:02:32, Lennart Poettering wrote:
 On Tue, 26.08.14 23:53, Ivan Shapovalov (intelfx...@gmail.com) wrote:
 
 Looks great, wanted to commit. But the series doesn't apply to current
 git. Could you please rebase?

Sorry, I've been writing against v215 which is current in arch. Just sent
the v6 against current master.

-- 
Ivan Shapovalov / intelfx /

signature.asc
Description: This is a digitally signed message part.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel