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