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