]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
9444b1f2 LP |
2 | #pragma once |
3 | ||
9444b1f2 | 4 | typedef struct Machine Machine; |
1ee306e1 | 5 | typedef enum KillWho KillWho; |
9444b1f2 LP |
6 | |
7 | #include "list.h" | |
1ee306e1 | 8 | #include "machined.h" |
795c5d31 | 9 | #include "operation.h" |
ca78ad1d | 10 | #include "time-util.h" |
9444b1f2 | 11 | |
fb6becb4 LP |
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, | |
2d93c20e | 17 | _MACHINE_STATE_INVALID = -EINVAL, |
fb6becb4 LP |
18 | } MachineState; |
19 | ||
9444b1f2 LP |
20 | typedef enum MachineClass { |
21 | MACHINE_CONTAINER, | |
22 | MACHINE_VM, | |
fbe55073 | 23 | MACHINE_HOST, |
9444b1f2 | 24 | _MACHINE_CLASS_MAX, |
2d93c20e | 25 | _MACHINE_CLASS_INVALID = -EINVAL, |
9444b1f2 LP |
26 | } MachineClass; |
27 | ||
1ee306e1 LP |
28 | enum KillWho { |
29 | KILL_LEADER, | |
30 | KILL_ALL, | |
31 | _KILL_WHO_MAX, | |
2d93c20e | 32 | _KILL_WHO_INVALID = -EINVAL, |
1ee306e1 LP |
33 | }; |
34 | ||
9444b1f2 LP |
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; | |
9444b1f2 LP |
45 | char *root_directory; |
46 | ||
89f7c846 | 47 | char *unit; |
fb6becb4 LP |
48 | char *scope_job; |
49 | ||
9444b1f2 LP |
50 | pid_t leader; |
51 | ||
52 | dual_timestamp timestamp; | |
53 | ||
54 | bool in_gc_queue:1; | |
55 | bool started:1; | |
49f3fffd | 56 | bool stopping:1; |
2798430e | 57 | bool referenced:1; |
9444b1f2 | 58 | |
c3350683 | 59 | sd_bus_message *create_message; |
fb6becb4 | 60 | |
9b5ed6fe | 61 | int *netif; |
68e16e9c | 62 | size_t n_netif; |
9b5ed6fe | 63 | |
795c5d31 | 64 | LIST_HEAD(Operation, operations); |
0370612e | 65 | |
795c5d31 | 66 | LIST_FIELDS(Machine, gc_queue); |
9444b1f2 LP |
67 | }; |
68 | ||
359e8d76 | 69 | int machine_new(Manager *manager, MachineClass class, const char *name, Machine **ret); |
bb1a05d6 | 70 | Machine* machine_free(Machine *m); |
554ce41f | 71 | bool machine_may_gc(Machine *m, bool drop_not_started); |
9444b1f2 | 72 | void machine_add_to_gc_queue(Machine *m); |
c3350683 | 73 | int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error); |
9444b1f2 | 74 | int machine_stop(Machine *m); |
49f3fffd | 75 | int machine_finalize(Machine *m); |
9444b1f2 LP |
76 | int machine_save(Machine *m); |
77 | int machine_load(Machine *m); | |
78 | int machine_kill(Machine *m, KillWho who, int signo); | |
79 | ||
9b420b3c LP |
80 | void machine_release_unit(Machine *m); |
81 | ||
fb6becb4 LP |
82 | MachineState machine_get_state(Machine *u); |
83 | ||
9444b1f2 LP |
84 | const char* machine_class_to_string(MachineClass t) _const_; |
85 | MachineClass machine_class_from_string(const char *s) _pure_; | |
fb6becb4 LP |
86 | |
87 | const char* machine_state_to_string(MachineState t) _const_; | |
88 | MachineState machine_state_from_string(const char *s) _pure_; | |
1ee306e1 LP |
89 | |
90 | const char *kill_who_to_string(KillWho k) _const_; | |
91 | KillWho kill_who_from_string(const char *s) _pure_; | |
fbe55073 | 92 | |
ae1d13db | 93 | int machine_openpt(Machine *m, int flags, char **ret_slave); |
40e1f4ea | 94 | int machine_open_terminal(Machine *m, const char *path, int mode); |
3401419b LP |
95 | |
96 | int machine_get_uid_shift(Machine *m, uid_t *ret); | |
74d1b7d2 LP |
97 | |
98 | int machine_owns_uid(Machine *m, uid_t host_uid, uid_t *ret_internal_uid); | |
99 | int machine_owns_gid(Machine *m, gid_t host_gid, gid_t *ret_internal_gid); | |
100 | ||
101 | int machine_translate_uid(Machine *m, uid_t internal_uid, uid_t *ret_host_uid); | |
102 | int machine_translate_gid(Machine *m, gid_t internal_gid, gid_t *ret_host_gid); |