]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
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" |
9444b1f2 | 10 | |
fb6becb4 LP |
11 | typedef enum MachineState { |
12 | MACHINE_OPENING, /* Machine is being registered */ | |
13 | MACHINE_RUNNING, /* Machine is running */ | |
14 | MACHINE_CLOSING, /* Machine is terminating */ | |
15 | _MACHINE_STATE_MAX, | |
16 | _MACHINE_STATE_INVALID = -1 | |
17 | } MachineState; | |
18 | ||
9444b1f2 LP |
19 | typedef enum MachineClass { |
20 | MACHINE_CONTAINER, | |
21 | MACHINE_VM, | |
fbe55073 | 22 | MACHINE_HOST, |
9444b1f2 LP |
23 | _MACHINE_CLASS_MAX, |
24 | _MACHINE_CLASS_INVALID = -1 | |
25 | } MachineClass; | |
26 | ||
1ee306e1 LP |
27 | enum KillWho { |
28 | KILL_LEADER, | |
29 | KILL_ALL, | |
30 | _KILL_WHO_MAX, | |
31 | _KILL_WHO_INVALID = -1 | |
32 | }; | |
33 | ||
9444b1f2 LP |
34 | struct Machine { |
35 | Manager *manager; | |
36 | ||
37 | char *name; | |
38 | sd_id128_t id; | |
39 | ||
40 | MachineClass class; | |
41 | ||
42 | char *state_file; | |
43 | char *service; | |
9444b1f2 LP |
44 | char *root_directory; |
45 | ||
89f7c846 | 46 | char *unit; |
fb6becb4 LP |
47 | char *scope_job; |
48 | ||
9444b1f2 LP |
49 | pid_t leader; |
50 | ||
51 | dual_timestamp timestamp; | |
52 | ||
53 | bool in_gc_queue:1; | |
54 | bool started:1; | |
49f3fffd | 55 | bool stopping:1; |
9444b1f2 | 56 | |
c3350683 | 57 | sd_bus_message *create_message; |
fb6becb4 | 58 | |
9b5ed6fe | 59 | int *netif; |
68e16e9c | 60 | size_t n_netif; |
9b5ed6fe | 61 | |
795c5d31 | 62 | LIST_HEAD(Operation, operations); |
0370612e | 63 | |
795c5d31 | 64 | LIST_FIELDS(Machine, gc_queue); |
9444b1f2 LP |
65 | }; |
66 | ||
fbe55073 | 67 | Machine* machine_new(Manager *manager, MachineClass class, const char *name); |
bb1a05d6 | 68 | Machine* machine_free(Machine *m); |
554ce41f | 69 | bool machine_may_gc(Machine *m, bool drop_not_started); |
9444b1f2 | 70 | void machine_add_to_gc_queue(Machine *m); |
c3350683 | 71 | int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error); |
9444b1f2 | 72 | int machine_stop(Machine *m); |
49f3fffd | 73 | int machine_finalize(Machine *m); |
9444b1f2 LP |
74 | int machine_save(Machine *m); |
75 | int machine_load(Machine *m); | |
76 | int machine_kill(Machine *m, KillWho who, int signo); | |
77 | ||
9b420b3c LP |
78 | void machine_release_unit(Machine *m); |
79 | ||
fb6becb4 LP |
80 | MachineState machine_get_state(Machine *u); |
81 | ||
9444b1f2 LP |
82 | const char* machine_class_to_string(MachineClass t) _const_; |
83 | MachineClass machine_class_from_string(const char *s) _pure_; | |
fb6becb4 LP |
84 | |
85 | const char* machine_state_to_string(MachineState t) _const_; | |
86 | MachineState machine_state_from_string(const char *s) _pure_; | |
1ee306e1 LP |
87 | |
88 | const char *kill_who_to_string(KillWho k) _const_; | |
89 | KillWho kill_who_from_string(const char *s) _pure_; | |
fbe55073 LP |
90 | |
91 | int machine_openpt(Machine *m, int flags); | |
40e1f4ea | 92 | int machine_open_terminal(Machine *m, const char *path, int mode); |
3401419b LP |
93 | |
94 | int machine_get_uid_shift(Machine *m, uid_t *ret); |