Re: [systemd-devel] [RFC] [PATCHv3 3/3] resume-generator: add a generator for instantiating the resume unit.

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

  Hmm, the fact that the kernel cmdline option is named resume is
  probably a strong indication we should stick to that nomenclature, after
  all that's UI already in away...
  
  But maybe call it systemd-hibernate-resume@.service and
  systemd-hibernate-resume-generator or so?
  
  Longer to type but more precise, and I figure nobody has to type this
  ever anyway...
 
 That's what will be reflected in manpages. I'd argue that systemd-resume
 is how one expects this feature to be named -- support from systemd side
 for the kernel feature called resume.

Well, I am mostly thinking about somebody who wonders what that service
is about if he doesn't know that the kernel details and the kernel
cmdline option yet.

I think systemd-hibernate-resume has the benefit that both folks who
already know the kernel side of things, and people who don't know
anything about this at all yet, have both a chance to grok what this is
about.

If I don#t now the kernel side of things, then I would always have
assume that systemd-resume is something that is involved with STR, not
STD... systemd-hibernate-resume.service otoh makes this very clear, and also
pairs this up nicely to the existing systemd-hibernate.service.

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] [RFC] [PATCHv3 3/3] resume-generator: add a generator for instantiating the resume unit.

2014-08-25 Thread Lennart Poettering
On Mon, 25.08.14 02:16, Ivan Shapovalov (intelfx...@gmail.com) wrote:

 +
 +static const char *arg_dest = /tmp;
 +static char *arg_resume_dev = NULL;
 +
 +static int parse_proc_cmdline_item(const char *key, const char *value) {
 +if (streq(key, resume)  value) {
 +free(arg_resume_dev);
 +arg_resume_dev = strdup(value);
 +if (!arg_resume_dev)
 +return log_oom();
 +}
 +
 +return 0;

There's something wrong with the indentation here...

 +}
 +
 +static int process_resume(void) {
 +_cleanup_free_ char *name = NULL, *lnk = NULL;
 +
 +name = unit_name_from_path_instance(systemd-resume, 
 arg_resume_dev, .service);
 +if (!name)
 +return log_oom();
 +
 +lnk = strjoin(arg_dest, / SPECIAL_SYSINIT_TARGET .wants/, name, 
 NULL);
 +if (!lnk)
 +return log_oom();
 +
 +mkdir_parents_label(lnk, 0755);
 +if (symlink(SYSTEM_DATA_UNIT_PATH /systemd-resume@.service, lnk)  
 0) {
 +log_error(Failed to create symlink %s: %m, lnk);
 +return -errno;
 +}
 +
 +return 0;
 +}
 +
 +int main(int argc, char *argv[]) {
 +int r = 0;
 +
 +if (argc  1  argc != 4) {
 +log_error(This program takes three or no arguments.);
 +return EXIT_FAILURE;
 +}
 +
 +if (argc  1)
 +arg_dest = argv[1];
 +
 +log_set_target(LOG_TARGET_SAFE);
 +log_parse_environment();
 +log_open();
 +
 +umask(0022);
 +
 +/* Don't even consider resuming outside of initramfs. */
 +if (!in_initrd())
 +return EXIT_SUCCESS;
 +
 +if (parse_proc_cmdline(parse_proc_cmdline_item)  0)
 +return EXIT_FAILURE;
 +
 +if (arg_resume_dev != NULL)
 +r = process_resume();
 +
 +free(arg_resume_dev);
 +
 +return r  0 ? EXIT_FAILURE : EXIT_SUCCESS;
 +}

Looks good otherwise!

One more question though, regarding the terminology. So far we used the
following terms:

suspend → means suspend-to-ram
hibernate → means suspend-to-disk
hybrid-sleep → means both STR + STD combined
sleep → a generic term for all of the above.

Now, I do wonder how we should call the operation when we come back from
the sleep states.

To me resume would probably most clearly be the reverse of suspend,
but you actually are looking for the reverse of hibernate here. 

The reverse of sleep would be wake I figure...

On the kernel side the terminology for all of this is completely
random. Especially given that the input layer names some keys with the
precise opposite of what the PM layer calls the operations... But we
really should try to clean this up a bit when exposing this in
userspace...

So, dunno, what's the antonym of hibernate? SOmething like thaw
maybe? Any native english speakers with ideas?

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] [RFC] [PATCHv3 3/3] resume-generator: add a generator for instantiating the resume unit.

2014-08-25 Thread Ivan Shapovalov
On Monday 25 August 2014 at 19:58:52, Lennart Poettering wrote: 
 [...]
 
 One more question though, regarding the terminology. So far we used the
 following terms:
 
 suspend → means suspend-to-ram
 hibernate → means suspend-to-disk
 hybrid-sleep → means both STR + STD combined
 sleep → a generic term for all of the above.
 
 Now, I do wonder how we should call the operation when we come back from
 the sleep states.
 
 To me resume would probably most clearly be the reverse of suspend,
 but you actually are looking for the reverse of hibernate here. 
 
 The reverse of sleep would be wake I figure...
 
 On the kernel side the terminology for all of this is completely
 random. Especially given that the input layer names some keys with the
 precise opposite of what the PM layer calls the operations... But we
 really should try to clean this up a bit when exposing this in
 userspace...
 
 So, dunno, what's the antonym of hibernate? SOmething like thaw
 maybe? Any native english speakers with ideas?
 
 Lennart

I've called it resume just because the kernel command line parameter
is named resume=, kernel messages use the term resume, the arch initramfs
hook is also named resume and so on... This may be inconsistent globally,
but the opposite of hibernation is called resume pretty much everywhere.

However, suggestions welcome.

-- 
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


Re: [systemd-devel] [RFC] [PATCHv3 3/3] resume-generator: add a generator for instantiating the resume unit.

2014-08-25 Thread Lennart Poettering
On Mon, 25.08.14 22:27, Ivan Shapovalov (intelfx...@gmail.com) wrote:

 On Monday 25 August 2014 at 19:58:52, Lennart Poettering wrote:   
  [...]
  
  One more question though, regarding the terminology. So far we used the
  following terms:
  
  suspend → means suspend-to-ram
  hibernate → means suspend-to-disk
  hybrid-sleep → means both STR + STD combined
  sleep → a generic term for all of the above.
  
  Now, I do wonder how we should call the operation when we come back from
  the sleep states.
  
  To me resume would probably most clearly be the reverse of suspend,
  but you actually are looking for the reverse of hibernate here. 
  
  The reverse of sleep would be wake I figure...
  
  On the kernel side the terminology for all of this is completely
  random. Especially given that the input layer names some keys with the
  precise opposite of what the PM layer calls the operations... But we
  really should try to clean this up a bit when exposing this in
  userspace...
  
  So, dunno, what's the antonym of hibernate? SOmething like thaw
  maybe? Any native english speakers with ideas?
 
 I've called it resume just because the kernel command line parameter
 is named resume=, kernel messages use the term resume, the arch initramfs
 hook is also named resume and so on... This may be inconsistent globally,
 but the opposite of hibernation is called resume pretty much everywhere.
 
 However, suggestions welcome.


Hmm, the fact that the kernel cmdline option is named resume is
probably a strong indication we should stick to that nomenclature, after
all that's UI already in away...

But maybe call it systemd-hibernate-resume@.service and
systemd-hibernate-resume-generator or so?

Longer to type but more precise, and I figure nobody has to type this
ever anyway...

Lennart

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


[systemd-devel] [RFC] [PATCHv3 3/3] resume-generator: add a generator for instantiating the resume unit.

2014-08-24 Thread Ivan Shapovalov
resume-generator understands resume= kernel command line parameter and
instantiates the systemd-resume@.service accordingly if it is passed.

This enables resume from hibernation using device specified on the kernel
command line, where the device path may point to an arbitrary udev-created
symlink, not only /dev/sdXY which is understood by the in-kernel
implementation.
---
 Makefile-man.am |  2 +
 Makefile.am | 11 +++-
 man/kernel-command-line.xml | 13 -
 man/systemd-resume-generator.xml| 91 +++
 src/resume-generator/Makefile   |  1 +
 src/resume-generator/resume-generator.c | 95 +
 6 files changed, 211 insertions(+), 2 deletions(-)
 create mode 100644 man/systemd-resume-generator.xml
 create mode 12 src/resume-generator/Makefile
 create mode 100644 src/resume-generator/resume-generator.c

diff --git a/Makefile-man.am b/Makefile-man.am
index be19905..00daae2 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -76,6 +76,7 @@ MANPAGES += \
man/systemd-nspawn.1 \
man/systemd-path.1 \
man/systemd-remount-fs.service.8 \
+   man/systemd-resume-generator.8 \
man/systemd-resume@.service.8 \
man/systemd-run.1 \
man/systemd-shutdownd.service.8 \
@@ -1632,6 +1633,7 @@ EXTRA_DIST += \
man/systemd-readahead-replay.service.xml \
man/systemd-remount-fs.service.xml \
man/systemd-resolved.service.xml \
+   man/systemd-resume-generator.xml \
man/systemd-res...@.service.xml \
man/systemd-rfk...@.service.xml \
man/systemd-run.xml \
diff --git a/Makefile.am b/Makefile.am
index c4327ca..820d082 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -378,7 +378,8 @@ systemgenerator_PROGRAMS = \
systemd-getty-generator \
systemd-fstab-generator \
systemd-system-update-generator \
-   systemd-debug-generator
+   systemd-debug-generator \
+   systemd-resume-generator
 
 dist_bashcompletion_DATA = \
shell-completion/bash/busctl \
@@ -1973,6 +1974,14 @@ systemd_system_update_generator_LDADD = \
libsystemd-label.la \
libsystemd-shared.la
 
+# 
--
+systemd_resume_generator_SOURCES = \
+   src/resume-generator/resume-generator.c
+
+systemd_resume_generator_LDADD = \
+   libsystemd-label.la \
+   libsystemd-shared.la
+
 if ENABLE_EFI
 # 
--
 systemgenerator_PROGRAMS +=  \
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
index f244bfc..4bc6cee 100644
--- a/man/kernel-command-line.xml
+++ b/man/kernel-command-line.xml
@@ -351,6 +351,16 @@
 /listitem
 /varlistentry
 
+varlistentry
+termvarnameresume=/varname/term
+
+listitem
+paraEnables resume from hibernation
+using the specified device. For
+details, see
+
citerefentryrefentrytitlesystemd-resume-generator/refentrytitlemanvolnum8/manvolnum/citerefentry./para
+/listitem
+/varlistentry
 /variablelist
 
 /refsect1
@@ -373,7 +383,8 @@
   
citerefentryrefentrytitlesystemd-gpt-auto-generator/refentrytitlemanvolnum8/manvolnum/citerefentry,
   
citerefentryrefentrytitlesystemd-modules-load.service/refentrytitlemanvolnum8/manvolnum/citerefentry,
   
citerefentryrefentrytitlesystemd-backlight@.service/refentrytitlemanvolnum8/manvolnum/citerefentry,
-  
citerefentryrefentrytitlesystemd-rfkill@.service/refentrytitlemanvolnum8/manvolnum/citerefentry
+  
citerefentryrefentrytitlesystemd-rfkill@.service/refentrytitlemanvolnum8/manvolnum/citerefentry,
+  
citerefentryrefentrytitlesystemd-resume-generator/refentrytitlemanvolnum8/manvolnum/citerefentry
   /para
 /refsect1
 
diff --git a/man/systemd-resume-generator.xml b/man/systemd-resume-generator.xml
new file mode 100644
index 000..7962534
--- /dev/null
+++ b/man/systemd-resume-generator.xml
@@ -0,0 +1,91 @@
+?xml version=1.0?
+!--*-nxml-*--
+!DOCTYPE refentry PUBLIC -//OASIS//DTD DocBook XML V4.2//EN 
http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd;
+!--
+  This file is part of systemd.
+
+  Copyright 2014 Ivan Shapovalov
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1