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