chiark / gitweb /
Revert "socket: add support for TCP fast Open"
[elogind.git] / src / machine / 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 typedef enum KillWho KillWho;
26
27 #include "list.h"
28 #include "util.h"
29 #include "machined.h"
30
31 typedef enum MachineState {
32         MACHINE_OPENING,    /* Machine is being registered */
33         MACHINE_RUNNING,    /* Machine is running */
34         MACHINE_CLOSING,    /* Machine is terminating */
35         _MACHINE_STATE_MAX,
36         _MACHINE_STATE_INVALID = -1
37 } MachineState;
38
39 typedef enum MachineClass {
40         MACHINE_CONTAINER,
41         MACHINE_VM,
42         _MACHINE_CLASS_MAX,
43         _MACHINE_CLASS_INVALID = -1
44 } MachineClass;
45
46 enum KillWho {
47         KILL_LEADER,
48         KILL_ALL,
49         _KILL_WHO_MAX,
50         _KILL_WHO_INVALID = -1
51 };
52
53 struct Machine {
54         Manager *manager;
55
56         char *name;
57         sd_id128_t id;
58
59         MachineState state;
60         MachineClass class;
61
62         char *state_file;
63         char *service;
64         char *root_directory;
65
66         char *unit;
67         char *scope_job;
68
69         pid_t leader;
70
71         dual_timestamp timestamp;
72
73         bool in_gc_queue:1;
74         bool started:1;
75         bool registered:1;
76
77         sd_bus_message *create_message;
78
79         int *netif;
80         unsigned n_netif;
81
82         LIST_FIELDS(Machine, gc_queue);
83 };
84
85 Machine* machine_new(Manager *manager, const char *name);
86 void machine_free(Machine *m);
87 bool machine_check_gc(Machine *m, bool drop_not_started);
88 void machine_add_to_gc_queue(Machine *m);
89 int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error);
90 int machine_stop(Machine *m);
91 int machine_save(Machine *m);
92 int machine_load(Machine *m);
93 int machine_kill(Machine *m, KillWho who, int signo);
94
95 MachineState machine_get_state(Machine *u);
96
97 extern const sd_bus_vtable machine_vtable[];
98
99 char *machine_bus_path(Machine *s);
100 int machine_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
101 int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
102
103 int bus_machine_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
104 int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
105 int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
106 int bus_machine_method_get_os_release(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error);
107
108 int machine_send_signal(Machine *m, bool new_machine);
109 int machine_send_create_reply(Machine *m, sd_bus_error *error);
110
111 const char* machine_class_to_string(MachineClass t) _const_;
112 MachineClass machine_class_from_string(const char *s) _pure_;
113
114 const char* machine_state_to_string(MachineState t) _const_;
115 MachineState machine_state_from_string(const char *s) _pure_;
116
117 const char *kill_who_to_string(KillWho k) _const_;
118 KillWho kill_who_from_string(const char *s) _pure_;