lkml.org 
[lkml]   [2019]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 2/3] hv_utils: Support host-initiated hibernation request
Date
> From: Vitaly Kuznetsov <vkuznets@redhat.com>
> Sent: Thursday, September 12, 2019 9:27 AM
>
> Dexuan Cui <decui@microsoft.com> writes:
>
> > +static void perform_hibernation(struct work_struct *dummy)
> > +{
> > + /*
> > + * The user is expected to create the program, which can be a simple
> > + * script containing two lines:
> > + * #!/bin/bash
> > + * echo disk > /sys/power/state
>
> 'systemctl hibernate' is what people do nowadays :-)

Thanks for sharing this command!

> > + */
> > + static char hibernate_cmd[PATH_MAX] = "/sbin/hyperv-hibernate";
> > +
>
> Let's not do that (I remember when we were triggering network restart
> from netvsc and it was a lot of pain).
>
> Receiving hybernation request from the host is similar to pushing power
> button on your desktop: an ACPI event is going to be generated and your
> userspace will somehow react to it. I see two options:
> 1) We try to hook up some existing userspace (udev?)
> 2) We write a new hyperv-daemon handling the request (with a config file
> instead of hardcoding please).
>
> Vitaly

Thanks for the suggestions!
I prefer the udev method, e.g. something like this:

char *uevent_env[2] = { "EVENT=hibernate", NULL };
kobject_uevent_env(&ctx->dev->device.kobj, KOBJ_CHANGE, uevent_env);

Then the user is expected to create the below udev rule file, which is applied
upon the host-initiated hibernation request:

root@localhost:~# cat /usr/lib/udev/rules.d/40-vm-hibernation.rules
SUBSYSTEM=="vmbus", ACTION=="change", DRIVER=="hv_utils", ENV{EVENT}=="hibernate", RUN+="/usr/bin/systemctl hibernate"

The full patch is here:
https://github.com/dcui/linux/commit/0d92b53f48a8dca92bbd3493ea9c5bd098c99623

I'll post it as v2.

Thanks,
-- Dexuan

\
 
 \ /
  Last update: 2019-09-13 18:44    [W:0.099 / U:4.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site