mirror of
https://github.com/systemd/systemd.git
synced 2025-03-14 04:58:28 +03:00
oomd: add names to dbus parameters and implement --bus-introspection
This commit is contained in:
parent
ddc543bed8
commit
c9a00f5a3b
@ -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"
|
||||
@ -47,6 +50,7 @@ static int help(void) {
|
||||
" -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
|
||||
@ -59,12 +63,14 @@ 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' },
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
|
||||
{ "bus-introspect", required_argument, NULL, ARG_BUS_INTROSPECT },
|
||||
{}
|
||||
};
|
||||
|
||||
@ -87,6 +93,13 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
arg_dry_run = true;
|
||||
break;
|
||||
|
||||
case ARG_BUS_INTROSPECT:
|
||||
return bus_introspect_implementations(
|
||||
stdout,
|
||||
optarg,
|
||||
BUS_IMPLEMENTATIONS(&manager_object,
|
||||
&log_control_object));
|
||||
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user