oomd: implement a prekill varlink event
When a cgroup is selected for termination, send varlink messages to hooks registered in `/run/systemd/oomd.prekill-hooks/`. oomd waits up to `PreKillHookTimeoutSec=` seconds for response before proceeding with the kill.
This commit is contained in:
@@ -224,6 +224,7 @@ shared_sources = files(
|
||||
'varlink-io.systemd.Unit.c',
|
||||
'varlink-io.systemd.UserDatabase.c',
|
||||
'varlink-io.systemd.oom.c',
|
||||
'varlink-io.systemd.oom.Prekill.c',
|
||||
'varlink-io.systemd.service.c',
|
||||
'varlink-io.systemd.sysext.c',
|
||||
'varlink-serialize.c',
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "varlink-io.systemd.oom.Prekill.h"
|
||||
|
||||
/* This is a new Varlink interface for pre-kill notifications from oomd.
|
||||
* It will be available through /run/systemd/oomd.prekill.hook/ */
|
||||
|
||||
static SD_VARLINK_DEFINE_METHOD(
|
||||
Notify,
|
||||
SD_VARLINK_FIELD_COMMENT("The cgroup which is going to be killed"),
|
||||
SD_VARLINK_DEFINE_INPUT(cgroup, SD_VARLINK_STRING, 0));
|
||||
|
||||
SD_VARLINK_DEFINE_INTERFACE(
|
||||
io_systemd_oom_Prekill,
|
||||
"io.systemd.oom.Prekill",
|
||||
SD_VARLINK_INTERFACE_COMMENT("Prekill notifications from oomd"),
|
||||
SD_VARLINK_SYMBOL_COMMENT("Notify about an imminent OOM kill"),
|
||||
&vl_method_Notify);
|
||||
@@ -0,0 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-varlink-idl.h"
|
||||
|
||||
extern const sd_varlink_interface vl_interface_io_systemd_oom_Prekill;
|
||||
Reference in New Issue
Block a user