2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2013-07-02 03:47:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2013-10-30 02:06:55 +01:00
|
|
|
#include "sd-bus.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "sd-event.h"
|
|
|
|
|
2013-07-02 03:47:23 +02:00
|
|
|
typedef struct Manager Manager;
|
|
|
|
|
2020-07-07 11:58:06 +02:00
|
|
|
#include "hashmap.h"
|
2014-12-27 01:57:03 +01:00
|
|
|
#include "image-dbus.h"
|
2020-07-07 11:58:06 +02:00
|
|
|
#include "list.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "machine-dbus.h"
|
|
|
|
#include "machine.h"
|
2016-04-29 19:14:52 +02:00
|
|
|
#include "operation.h"
|
2020-07-07 11:59:10 +02:00
|
|
|
#include "varlink.h"
|
2013-07-02 03:47:23 +02:00
|
|
|
|
|
|
|
struct Manager {
|
2013-10-30 02:06:55 +01:00
|
|
|
sd_event *event;
|
|
|
|
sd_bus *bus;
|
2013-07-02 03:47:23 +02:00
|
|
|
|
|
|
|
Hashmap *machines;
|
|
|
|
Hashmap *machine_units;
|
2013-11-06 02:03:04 +01:00
|
|
|
Hashmap *machine_leaders;
|
2013-07-02 03:47:23 +02:00
|
|
|
|
2014-12-23 21:28:22 +01:00
|
|
|
Hashmap *polkit_registry;
|
|
|
|
|
2014-12-28 02:44:37 +01:00
|
|
|
Hashmap *image_cache;
|
|
|
|
sd_event_source *image_cache_defer_event;
|
|
|
|
|
2013-07-02 03:47:23 +02:00
|
|
|
LIST_HEAD(Machine, machine_gc_queue);
|
2015-08-24 21:05:09 +02:00
|
|
|
|
|
|
|
Machine *host_machine;
|
2016-04-29 19:14:52 +02:00
|
|
|
|
|
|
|
LIST_HEAD(Operation, operations);
|
|
|
|
unsigned n_operations;
|
2018-12-07 16:49:52 +01:00
|
|
|
|
2020-12-07 08:45:15 +01:00
|
|
|
#if ENABLE_NSCD
|
2018-12-07 16:49:52 +01:00
|
|
|
sd_event_source *nscd_cache_flush_event;
|
2020-12-07 08:45:15 +01:00
|
|
|
#endif
|
2020-07-07 11:59:10 +02:00
|
|
|
|
|
|
|
VarlinkServer *varlink_server;
|
2013-07-02 03:47:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
int manager_add_machine(Manager *m, const char *name, Machine **_machine);
|
|
|
|
int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine);
|
|
|
|
|
2020-04-23 14:21:46 +02:00
|
|
|
extern const BusObjectImplementation manager_object;
|
2013-10-30 02:06:55 +01:00
|
|
|
|
2015-04-29 18:35:10 +02:00
|
|
|
int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error);
|
|
|
|
int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
|
|
|
|
int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error);
|
|
|
|
int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
|
2013-07-02 03:47:23 +02:00
|
|
|
|
2013-10-30 02:06:55 +01:00
|
|
|
int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
|
2014-03-18 04:43:08 +01:00
|
|
|
int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_error *error);
|
2018-10-07 14:50:11 +02:00
|
|
|
int manager_unref_unit(Manager *m, const char *unit, sd_bus_error *error);
|
2013-07-02 03:47:23 +02:00
|
|
|
int manager_unit_is_active(Manager *manager, const char *unit);
|
2013-10-30 02:06:55 +01:00
|
|
|
int manager_job_is_active(Manager *manager, const char *path);
|
2018-12-07 16:49:52 +01:00
|
|
|
|
2020-12-07 08:45:15 +01:00
|
|
|
#if ENABLE_NSCD
|
2018-12-07 16:49:52 +01:00
|
|
|
int manager_enqueue_nscd_cache_flush(Manager *m);
|
2020-12-07 08:45:15 +01:00
|
|
|
#else
|
|
|
|
static inline void manager_enqueue_nscd_cache_flush(Manager *m) {}
|
|
|
|
#endif
|
2020-07-07 11:58:06 +02:00
|
|
|
|
|
|
|
int manager_find_machine_for_uid(Manager *m, uid_t host_uid, Machine **ret_machine, uid_t *ret_internal_uid);
|
|
|
|
int manager_find_machine_for_gid(Manager *m, gid_t host_gid, Machine **ret_machine, gid_t *ret_internal_gid);
|