From e83419d043e4f1e11f52d9a3360b0e5bdea71031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 26 Sep 2018 07:31:10 +0200 Subject: [PATCH] hib-res-generator: add "noresume" This is an override parameter, to totally skip dehiberanation. --- TODO | 5 ++--- man/systemd-hibernate-resume-generator.xml | 14 +++++++++++--- .../hibernate-resume-generator.c | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index f848b9741e..59ea95746c 100644 --- a/TODO +++ b/TODO @@ -86,11 +86,10 @@ Features: 1. add resume_offset support to the resume code (i.e. support swap files properly) - 2. check of swap is on weird storage and refuse if so + 2. check if swap is on weird storage and refuse if so 3. add env-var based option to disable hibernation 4. figure out what to do with swap-on-luks - 5. add autodetection of hibernation images, and add "noresume" to disable - this + 5. add autodetection of hibernation images * portables: introduce a new unit file directory /etc/systemd/system.attached/ or so, where we attach portable services to diff --git a/man/systemd-hibernate-resume-generator.xml b/man/systemd-hibernate-resume-generator.xml index 86d45dc4af..8f0cc5d044 100644 --- a/man/systemd-hibernate-resume-generator.xml +++ b/man/systemd-hibernate-resume-generator.xml @@ -28,11 +28,13 @@ Description - systemd-hibernate-resume-generator is a - generator that instantiates + systemd-hibernate-resume-generator is a + generator that initiates the procedure to resume the system from hibernation. + It instantiates the systemd-hibernate-resume@.service8 unit according to the value of parameter - specified on the kernel command line. + specified on the kernel command line, which will instruct the kernel + to resume the system from the hibernation image on that device. @@ -54,6 +56,12 @@ supported. + + noresume + + Do not try to resume from hibernation. If this parameter is + present, resume= is ignored. + diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index 8ff44c3bb9..036493a389 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -15,6 +15,7 @@ static const char *arg_dest = "/tmp"; static char *arg_resume_device = NULL; +static bool arg_noresume = false; static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { @@ -28,8 +29,15 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (!s) return log_oom(); - free(arg_resume_device); - arg_resume_device = s; + free_and_replace(arg_resume_device, s); + + } else if (streq(key, "noresume")) { + if (value) { + log_warning("\"noresume\" kernel command line switch specified with an argument, ignoring."); + return 0; + } + + arg_noresume = true; } return 0; @@ -85,6 +93,11 @@ int main(int argc, char *argv[]) { if (r < 0) log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m"); + if (arg_noresume) { + log_notice("Found \"noresume\" on the kernel command line, quitting."); + return EXIT_SUCCESS; + } + r = process_resume(); free(arg_resume_device);