chiark / gitweb /
cd5174ff9e01e0f0029e9842b66abc968b2bf700
[elogind.git] / src / login / logind-machine.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2013 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 typedef struct Machine Machine;
25
26 #include "list.h"
27 #include "util.h"
28 #include "logind.h"
29 #include "logind-session.h"
30
31 typedef enum MachineClass {
32         MACHINE_CONTAINER,
33         MACHINE_VM,
34         _MACHINE_CLASS_MAX,
35         _MACHINE_CLASS_INVALID = -1
36 } MachineClass;
37
38 struct Machine {
39         Manager *manager;
40
41         char *name;
42         sd_id128_t id;
43
44         MachineClass class;
45
46         char *state_file;
47         char *service;
48         char *cgroup_path;
49         char *slice;
50         char *root_directory;
51
52         pid_t leader;
53
54         dual_timestamp timestamp;
55
56         bool in_gc_queue:1;
57         bool started:1;
58
59         LIST_FIELDS(Machine, gc_queue);
60 };
61
62 Machine* machine_new(Manager *manager, const char *name);
63 void machine_free(Machine *m);
64 int machine_check_gc(Machine *m, bool drop_not_started);
65 void machine_add_to_gc_queue(Machine *m);
66 int machine_start(Machine *m);
67 int machine_stop(Machine *m);
68 int machine_save(Machine *m);
69 int machine_load(Machine *m);
70 int machine_kill(Machine *m, KillWho who, int signo);
71
72 char *machine_bus_path(Machine *s);
73
74 extern const DBusObjectPathVTable bus_machine_vtable;
75
76 int machine_send_signal(Machine *m, bool new_machine);
77 int machine_send_changed(Machine *m, const char *properties);
78
79 const char* machine_class_to_string(MachineClass t) _const_;
80 MachineClass machine_class_from_string(const char *s) _pure_;