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