]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
9444b1f2 LP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2013 Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
23 | typedef struct Machine Machine; | |
1ee306e1 | 24 | typedef enum KillWho KillWho; |
9444b1f2 LP |
25 | |
26 | #include "list.h" | |
1ee306e1 | 27 | #include "machined.h" |
795c5d31 | 28 | #include "operation.h" |
9444b1f2 | 29 | |
fb6becb4 LP |
30 | typedef enum MachineState { |
31 | MACHINE_OPENING, /* Machine is being registered */ | |
32 | MACHINE_RUNNING, /* Machine is running */ | |
33 | MACHINE_CLOSING, /* Machine is terminating */ | |
34 | _MACHINE_STATE_MAX, | |
35 | _MACHINE_STATE_INVALID = -1 | |
36 | } MachineState; | |
37 | ||
9444b1f2 LP |
38 | typedef enum MachineClass { |
39 | MACHINE_CONTAINER, | |
40 | MACHINE_VM, | |
fbe55073 | 41 | MACHINE_HOST, |
9444b1f2 LP |
42 | _MACHINE_CLASS_MAX, |
43 | _MACHINE_CLASS_INVALID = -1 | |
44 | } MachineClass; | |
45 | ||
1ee306e1 LP |
46 | enum KillWho { |
47 | KILL_LEADER, | |
48 | KILL_ALL, | |
49 | _KILL_WHO_MAX, | |
50 | _KILL_WHO_INVALID = -1 | |
51 | }; | |
52 | ||
9444b1f2 LP |
53 | struct Machine { |
54 | Manager *manager; | |
55 | ||
56 | char *name; | |
57 | sd_id128_t id; | |
58 | ||
59 | MachineClass class; | |
60 | ||
61 | char *state_file; | |
62 | char *service; | |
9444b1f2 LP |
63 | char *root_directory; |
64 | ||
89f7c846 | 65 | char *unit; |
fb6becb4 LP |
66 | char *scope_job; |
67 | ||
9444b1f2 LP |
68 | pid_t leader; |
69 | ||
70 | dual_timestamp timestamp; | |
71 | ||
72 | bool in_gc_queue:1; | |
73 | bool started:1; | |
49f3fffd | 74 | bool stopping:1; |
9444b1f2 | 75 | |
c3350683 | 76 | sd_bus_message *create_message; |
fb6becb4 | 77 | |
9b5ed6fe LP |
78 | int *netif; |
79 | unsigned n_netif; | |
80 | ||
795c5d31 | 81 | LIST_HEAD(Operation, operations); |
0370612e | 82 | |
795c5d31 | 83 | LIST_FIELDS(Machine, gc_queue); |
9444b1f2 LP |
84 | }; |
85 | ||
fbe55073 | 86 | Machine* machine_new(Manager *manager, MachineClass class, const char *name); |
9444b1f2 | 87 | void machine_free(Machine *m); |
554ce41f | 88 | bool machine_may_gc(Machine *m, bool drop_not_started); |
9444b1f2 | 89 | void machine_add_to_gc_queue(Machine *m); |
c3350683 | 90 | int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error); |
9444b1f2 | 91 | int machine_stop(Machine *m); |
49f3fffd | 92 | int machine_finalize(Machine *m); |
9444b1f2 LP |
93 | int machine_save(Machine *m); |
94 | int machine_load(Machine *m); | |
95 | int machine_kill(Machine *m, KillWho who, int signo); | |
96 | ||
9b420b3c LP |
97 | void machine_release_unit(Machine *m); |
98 | ||
fb6becb4 LP |
99 | MachineState machine_get_state(Machine *u); |
100 | ||
9444b1f2 LP |
101 | const char* machine_class_to_string(MachineClass t) _const_; |
102 | MachineClass machine_class_from_string(const char *s) _pure_; | |
fb6becb4 LP |
103 | |
104 | const char* machine_state_to_string(MachineState t) _const_; | |
105 | MachineState machine_state_from_string(const char *s) _pure_; | |
1ee306e1 LP |
106 | |
107 | const char *kill_who_to_string(KillWho k) _const_; | |
108 | KillWho kill_who_from_string(const char *s) _pure_; | |
fbe55073 LP |
109 | |
110 | int machine_openpt(Machine *m, int flags); | |
40e1f4ea | 111 | int machine_open_terminal(Machine *m, const char *path, int mode); |
3401419b LP |
112 | |
113 | int machine_get_uid_shift(Machine *m, uid_t *ret); |