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),
+};
/* 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;
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)
#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"
" -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
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 },
{}
};
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;