]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/machine/machine.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / machine / machine.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright 2013 Lennart Poettering
6 ***/
7
8 typedef struct Machine Machine;
9 typedef enum KillWho KillWho;
10
11 #include "list.h"
12 #include "machined.h"
13 #include "operation.h"
14
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
23 typedef enum MachineClass {
24 MACHINE_CONTAINER,
25 MACHINE_VM,
26 MACHINE_HOST,
27 _MACHINE_CLASS_MAX,
28 _MACHINE_CLASS_INVALID = -1
29 } MachineClass;
30
31 enum KillWho {
32 KILL_LEADER,
33 KILL_ALL,
34 _KILL_WHO_MAX,
35 _KILL_WHO_INVALID = -1
36 };
37
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;
48 char *root_directory;
49
50 char *unit;
51 char *scope_job;
52
53 pid_t leader;
54
55 dual_timestamp timestamp;
56
57 bool in_gc_queue:1;
58 bool started:1;
59 bool stopping:1;
60
61 sd_bus_message *create_message;
62
63 int *netif;
64 unsigned n_netif;
65
66 LIST_HEAD(Operation, operations);
67
68 LIST_FIELDS(Machine, gc_queue);
69 };
70
71 Machine* machine_new(Manager *manager, MachineClass class, const char *name);
72 void machine_free(Machine *m);
73 bool machine_may_gc(Machine *m, bool drop_not_started);
74 void machine_add_to_gc_queue(Machine *m);
75 int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error);
76 int machine_stop(Machine *m);
77 int machine_finalize(Machine *m);
78 int machine_save(Machine *m);
79 int machine_load(Machine *m);
80 int machine_kill(Machine *m, KillWho who, int signo);
81
82 void machine_release_unit(Machine *m);
83
84 MachineState machine_get_state(Machine *u);
85
86 const char* machine_class_to_string(MachineClass t) _const_;
87 MachineClass machine_class_from_string(const char *s) _pure_;
88
89 const char* machine_state_to_string(MachineState t) _const_;
90 MachineState machine_state_from_string(const char *s) _pure_;
91
92 const char *kill_who_to_string(KillWho k) _const_;
93 KillWho kill_who_from_string(const char *s) _pure_;
94
95 int machine_openpt(Machine *m, int flags);
96 int machine_open_terminal(Machine *m, const char *path, int mode);
97
98 int machine_get_uid_shift(Machine *m, uid_t *ret);