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