]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/machine/machine.h
terminal-util: introduce openpt_allocate()
[thirdparty/systemd.git] / src / machine / machine.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 typedef struct Machine Machine;
5 typedef enum KillWho KillWho;
6
7 #include "list.h"
8 #include "machined.h"
9 #include "operation.h"
10 #include "time-util.h"
11
12 typedef enum MachineState {
13 MACHINE_OPENING, /* Machine is being registered */
14 MACHINE_RUNNING, /* Machine is running */
15 MACHINE_CLOSING, /* Machine is terminating */
16 _MACHINE_STATE_MAX,
17 _MACHINE_STATE_INVALID = -1
18 } MachineState;
19
20 typedef enum MachineClass {
21 MACHINE_CONTAINER,
22 MACHINE_VM,
23 MACHINE_HOST,
24 _MACHINE_CLASS_MAX,
25 _MACHINE_CLASS_INVALID = -1
26 } MachineClass;
27
28 enum KillWho {
29 KILL_LEADER,
30 KILL_ALL,
31 _KILL_WHO_MAX,
32 _KILL_WHO_INVALID = -1
33 };
34
35 struct Machine {
36 Manager *manager;
37
38 char *name;
39 sd_id128_t id;
40
41 MachineClass class;
42
43 char *state_file;
44 char *service;
45 char *root_directory;
46
47 char *unit;
48 char *scope_job;
49
50 pid_t leader;
51
52 dual_timestamp timestamp;
53
54 bool in_gc_queue:1;
55 bool started:1;
56 bool stopping:1;
57
58 sd_bus_message *create_message;
59
60 int *netif;
61 size_t n_netif;
62
63 LIST_HEAD(Operation, operations);
64
65 LIST_FIELDS(Machine, gc_queue);
66 };
67
68 Machine* machine_new(Manager *manager, MachineClass class, const char *name);
69 Machine* machine_free(Machine *m);
70 bool machine_may_gc(Machine *m, bool drop_not_started);
71 void machine_add_to_gc_queue(Machine *m);
72 int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error);
73 int machine_stop(Machine *m);
74 int machine_finalize(Machine *m);
75 int machine_save(Machine *m);
76 int machine_load(Machine *m);
77 int machine_kill(Machine *m, KillWho who, int signo);
78
79 void machine_release_unit(Machine *m);
80
81 MachineState machine_get_state(Machine *u);
82
83 const char* machine_class_to_string(MachineClass t) _const_;
84 MachineClass machine_class_from_string(const char *s) _pure_;
85
86 const char* machine_state_to_string(MachineState t) _const_;
87 MachineState machine_state_from_string(const char *s) _pure_;
88
89 const char *kill_who_to_string(KillWho k) _const_;
90 KillWho kill_who_from_string(const char *s) _pure_;
91
92 int machine_openpt(Machine *m, int flags, char **ret_slave);
93 int machine_open_terminal(Machine *m, const char *path, int mode);
94
95 int machine_get_uid_shift(Machine *m, uid_t *ret);