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