mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
Merge pull request #17361 from keszybz/oomd-introspection-stub
Implement --version,--bus-introspect in oomd, add man page for the dbus api
This commit is contained in:
commit
dd82626a0d
74
man/org.freedesktop.oom1.xml
Normal file
74
man/org.freedesktop.oom1.xml
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?xml version='1.0'?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" >
|
||||
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
|
||||
|
||||
<refentry id="org.freedesktop.oom1" conditional='ENABLE_OOMD'
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<refentryinfo>
|
||||
<title>org.freedesktop.oom1</title>
|
||||
<productname>systemd</productname>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>org.freedesktop.oom1</refentrytitle>
|
||||
<manvolnum>5</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>org.freedesktop.oom1</refname>
|
||||
<refpurpose>The D-Bus interface of systemd-oomd</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>
|
||||
<citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
is a system service which implements a userspace out-of-memory (OOM) killer. This page describes the
|
||||
D-Bus interface.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>The Manager Object</title>
|
||||
|
||||
<para>The service exposes the following interfaces on the Manager object on the bus:</para>
|
||||
|
||||
<programlisting executable="systemd-oomd" node="/org/freedesktop/oom1" interface="org.freedesktop.oom1.Manager">
|
||||
node /org/freedesktop/oom1 {
|
||||
interface org.freedesktop.oom1.Manager {
|
||||
methods:
|
||||
DumpByFileDescriptor(out h fd);
|
||||
};
|
||||
interface org.freedesktop.DBus.Peer { ... };
|
||||
interface org.freedesktop.DBus.Introspectable { ... };
|
||||
interface org.freedesktop.DBus.Properties { ... };
|
||||
};
|
||||
</programlisting>
|
||||
|
||||
<!--method DumpByFileDescriptor is not documented!-->
|
||||
|
||||
<!--Autogenerated cross-references for systemd.directives, do not edit-->
|
||||
|
||||
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.oom1.Manager"/>
|
||||
|
||||
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.oom1.Manager"/>
|
||||
|
||||
<variablelist class="dbus-method" generated="True" extra-ref="DumpByFileDescriptor()"/>
|
||||
|
||||
<!--End of Autogenerated section-->
|
||||
|
||||
<refsect2>
|
||||
<title>Methods</title>
|
||||
|
||||
<para>...</para>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Versioning</title>
|
||||
|
||||
<para>These D-Bus interfaces follow <ulink url="http://0pointer.de/blog/projects/versioning-dbus.html">
|
||||
the usual interface versioning guidelines</ulink>.</para>
|
||||
</refsect1>
|
||||
</refentry>
|
|
@ -54,6 +54,7 @@ manpages = [
|
|||
['org.freedesktop.locale1', '5', [], 'ENABLE_LOCALED'],
|
||||
['org.freedesktop.login1', '5', [], 'ENABLE_LOGIND'],
|
||||
['org.freedesktop.machine1', '5', [], 'ENABLE_MACHINED'],
|
||||
['org.freedesktop.oom1', '5', [], 'ENABLE_OOMD'],
|
||||
['org.freedesktop.resolve1', '5', [], 'ENABLE_RESOLVE'],
|
||||
['org.freedesktop.systemd1', '5', [], ''],
|
||||
['org.freedesktop.timedate1', '5', [], 'ENABLE_TIMEDATED'],
|
||||
|
|
|
@ -29,8 +29,19 @@ static int bus_method_dump_by_fd(sd_bus_message *message, void *userdata, sd_bus
|
|||
return sd_bus_reply_method_return(message, "h", fd);
|
||||
}
|
||||
|
||||
const sd_bus_vtable manager_vtable[] = {
|
||||
static const sd_bus_vtable manager_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
SD_BUS_METHOD("DumpByFileDescriptor", NULL, "h", bus_method_dump_by_fd, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD_WITH_NAMES("DumpByFileDescriptor",
|
||||
NULL,,
|
||||
"h",
|
||||
SD_BUS_PARAM(fd),
|
||||
bus_method_dump_by_fd,
|
||||
SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_VTABLE_END
|
||||
};
|
||||
|
||||
const BusObjectImplementation manager_object = {
|
||||
"/org/freedesktop/oom1",
|
||||
"org.freedesktop.oom1.Manager",
|
||||
.vtables = BUS_VTABLES(manager_vtable),
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "bus-object.h"
|
||||
|
||||
typedef struct Manager Manager;
|
||||
|
||||
extern const sd_bus_vtable manager_vtable[];
|
||||
extern const BusObjectImplementation manager_object;
|
||||
|
|
|
@ -455,9 +455,9 @@ static int manager_connect_bus(Manager *m) {
|
|||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
||||
|
||||
r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/oom1", "org.freedesktop.oom1.Manager", manager_vtable, m);
|
||||
r = bus_add_implementation(m->bus, &manager_object, m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add manager object vtable: %m");
|
||||
return r;
|
||||
|
||||
r = bus_log_control_api_register(m->bus);
|
||||
if (r < 0)
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
#include <getopt.h>
|
||||
|
||||
#include "bus-log-control-api.h"
|
||||
#include "bus-object.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "daemon-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "oomd-manager.h"
|
||||
#include "oomd-manager-bus.h"
|
||||
#include "parse-util.h"
|
||||
#include "pretty-print.c"
|
||||
#include "psi-util.h"
|
||||
|
@ -43,25 +46,31 @@ static int help(void) {
|
|||
return log_oom();
|
||||
|
||||
printf("%s [OPTIONS...]\n\n"
|
||||
"Run the userspace out-of-memory (OOM) killer.\n\n"
|
||||
" -h --help Show this help\n"
|
||||
" --dry-run Log write/destructive actions instead of doing them\n"
|
||||
"\nSee the %s for details.\n"
|
||||
, program_invocation_short_name
|
||||
, link
|
||||
);
|
||||
"Run the userspace out-of-memory (OOM) killer.\n\n"
|
||||
" -h --help Show this help\n"
|
||||
" --version Show package version\n"
|
||||
" --dry-run Only print destructive actions instead of doing them\n"
|
||||
" --bus-introspect=PATH Write D-Bus XML introspection data\n"
|
||||
"\nSee the %s for details.\n"
|
||||
, program_invocation_short_name
|
||||
, link
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_argv(int argc, char *argv[]) {
|
||||
enum {
|
||||
ARG_VERSION = 0x100,
|
||||
ARG_DRY_RUN,
|
||||
ARG_BUS_INTROSPECT,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
|
||||
{ "bus-introspect", required_argument, NULL, ARG_BUS_INTROSPECT },
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -74,20 +83,34 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
|
||||
switch (c) {
|
||||
|
||||
case 'h':
|
||||
return help();
|
||||
case 'h':
|
||||
return help();
|
||||
|
||||
case ARG_DRY_RUN:
|
||||
arg_dry_run = true;
|
||||
break;
|
||||
case ARG_VERSION:
|
||||
return version();
|
||||
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
case ARG_DRY_RUN:
|
||||
arg_dry_run = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid option passed.");
|
||||
case ARG_BUS_INTROSPECT:
|
||||
return bus_introspect_implementations(
|
||||
stdout,
|
||||
optarg,
|
||||
BUS_IMPLEMENTATIONS(&manager_object,
|
||||
&log_control_object));
|
||||
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown option code.");
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"This program takes no arguments.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue