Bug 856389

Summary: systemd - stop hibernation when there is no resume parameter on kernel cmdline
Product: [openSUSE] openSUSE Tumbleweed Reporter: Vojtech Dziewiecki <vdziewiecki>
Component: BasesystemAssignee: Thomas Blume <thomas.blume>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: systemd-maintainers, thomas.blume
Version: 13.2 Milestone 0   
Target Milestone: ---   
Hardware: All   
OS: SUSE Other   
Whiteboard:
Found By: Development Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Proposed patch.
systemd-sleep check for resume parameters on command line
systemd-sleep check for resume parameters on command line
prepare-suspend-to-disk.patch

Description Vojtech Dziewiecki 2013-12-19 18:40:39 UTC
Created attachment 572622 [details]
Proposed patch.

Hi,
I believe this functionality has to be added before switching from pm-utils to systemd suspend/hibernate.
If there's no resume parameter on kernel command line, then there is no point in hibernating since the system won't resume. 
I propose this patch. Please check if it's ok, I wrote it myself and I'm not a particularly experienced programmer.
Thanks.
Comment 1 Thomas Blume 2014-03-04 15:40:23 UTC
Wouldn't it be simpler to just do a port of:

/usr/lib/pm-utils/sleep.d/30s2disk-check

to a hook in /usr/lib/systemd/system-sleep?

At least in bug 856392 you did port:

/usr/lib/pm-utils/sleep.d/99Zgrub and the ported script has only some minor changes from the pm-utils one.
And 30s2disk-check does some more checks which might also be necessary for a successfull resume.
Comment 2 Vojtech Dziewiecki 2014-03-10 10:52:01 UTC
Hi,
systemd already does the other checks.
Also preventing suspend or hibernation seems harder in systemd then it was in pm-utils, I don't know what I would use in the systemd hook you propose instead of $INHIBIT in the pm-utils hook.
systemd-inhibit is quite inconvenient here, since it has to be run with a command and it only prevents suspend/hibernation while that command is running.

So I think this patch I proposed is simpler.
Comment 3 Thomas Blume 2014-03-19 15:50:22 UTC
Ok, agreed, I've modified the patch to align better to the code used in the other parts of systemd. This will give better upstream acceptance.

I've also added functionality to distinguish between swap device and swap file.
Patch attached below.

Any comment welcome.
Comment 4 Thomas Blume 2014-03-19 15:52:23 UTC
Created attachment 582827 [details]
systemd-sleep check for resume parameters on command line
Comment 6 Thomas Blume 2014-03-20 08:31:35 UTC
Created attachment 582911 [details]
systemd-sleep check for resume parameters on command line

Ok, here is the patch without the messy tabs
Comment 7 Thomas Blume 2014-03-24 12:29:20 UTC
Actually it is much simpler.
Systemd already provides an command line parser that can check for parameters specified via a service file.
Instead of hacking the systemd code, we could just add: 

ConditionKernelCommandLine="resume"

to systemd-hibernate.service and systemd-hybrid-sleep.service.
Comment 8 Dr. Werner Fink 2014-03-24 12:36:26 UTC
(In reply to comment #7)

Indeed this way we should go
Comment 9 Thomas Blume 2014-03-25 15:18:12 UTC
Created attachment 583604 [details]
prepare-suspend-to-disk.patch

Patch submitted to factory
Comment 11 Thomas Blume 2014-03-28 08:43:01 UTC
Patch submitted to SLE-12
Comment 15 Swamp Workflow Management 2016-02-03 14:24:36 UTC
openSUSE-RU-2016:0320-1: An update that has 146 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 737690,742774,750845,818044,838475,841544,849870,852015,852021,852232,853293,854884,856389,856392,856858,857204,858864,859072,859365,860574,860937,861316,861489,863217,864745,864904,865834,866732,866933,867128,867663,867664,867840,868019,868230,868439,868931,869142,869603,872929,873432,873444,874665,875502,876587,876694,877021,877674,878525,880438,880732,881125,881559,881942,882393,882714,883565,884271,884403,885232,885288,886211,886599,886852,888178,888215,888612,889297,889357,890977,892096,892162,892300,893797,895087,896664,897799,897801,897803,898233,898240,898432,900558,901481,902240,902901,903009,903963,904214,904517,904828,905550,906709,906900,907318,907393,908476,909358,910643,911347,912030,912334,913517,916420,918118,919095,920195,921831,921898,921920,926169,927250,927457,928265,931388,932284,933365,933512,933521,933533,934077,934901,937512,937900,938908,939571,940264,941576,944132,944799,945282,947212,948458,948555,948705,949574,949683,949739,950510,951265,951663,953241,954336,954781,955635,961576
CVE References: 
Sources used:
openSUSE 13.1 (src):    systemd-210-40.1, systemd-mini-210-40.1