]> git.proxmox.com Git - systemd.git/blame - src/machine/machine.h
Merge tag 'upstream/229'
[systemd.git] / src / machine / machine.h
CommitLineData
14228c0d
MB
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;
e3bff60a 23typedef struct MachineOperation MachineOperation;
14228c0d
MB
24typedef enum KillWho KillWho;
25
26#include "list.h"
14228c0d
MB
27#include "machined.h"
28
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
37typedef enum MachineClass {
38 MACHINE_CONTAINER,
39 MACHINE_VM,
13d276d0 40 MACHINE_HOST,
14228c0d
MB
41 _MACHINE_CLASS_MAX,
42 _MACHINE_CLASS_INVALID = -1
43} MachineClass;
44
45enum KillWho {
46 KILL_LEADER,
47 KILL_ALL,
48 _KILL_WHO_MAX,
49 _KILL_WHO_INVALID = -1
50};
51
e3bff60a
MP
52#define MACHINE_OPERATIONS_MAX 64
53
54struct MachineOperation {
55 Machine *machine;
56 pid_t pid;
57 sd_bus_message *message;
58 int errno_fd;
59 sd_event_source *event_source;
60 LIST_FIELDS(MachineOperation, operations);
61};
62
14228c0d
MB
63struct Machine {
64 Manager *manager;
65
66 char *name;
67 sd_id128_t id;
68
14228c0d
MB
69 MachineClass class;
70
71 char *state_file;
72 char *service;
73 char *root_directory;
74
60f067b4 75 char *unit;
14228c0d
MB
76 char *scope_job;
77
78 pid_t leader;
79
80 dual_timestamp timestamp;
81
82 bool in_gc_queue:1;
83 bool started:1;
13d276d0 84 bool stopping:1;
14228c0d 85
60f067b4 86 sd_bus_message *create_message;
14228c0d 87
5eef597e
MP
88 int *netif;
89 unsigned n_netif;
90
14228c0d 91 LIST_FIELDS(Machine, gc_queue);
e3bff60a
MP
92
93 MachineOperation *operations;
94 unsigned n_operations;
14228c0d
MB
95};
96
13d276d0 97Machine* machine_new(Manager *manager, MachineClass class, const char *name);
14228c0d 98void machine_free(Machine *m);
60f067b4 99bool machine_check_gc(Machine *m, bool drop_not_started);
14228c0d 100void machine_add_to_gc_queue(Machine *m);
60f067b4 101int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error);
14228c0d 102int machine_stop(Machine *m);
13d276d0 103int machine_finalize(Machine *m);
14228c0d
MB
104int machine_save(Machine *m);
105int machine_load(Machine *m);
106int machine_kill(Machine *m, KillWho who, int signo);
107
e3bff60a
MP
108void machine_release_unit(Machine *m);
109
14228c0d
MB
110MachineState machine_get_state(Machine *u);
111
e3bff60a
MP
112MachineOperation *machine_operation_unref(MachineOperation *o);
113
14228c0d
MB
114const char* machine_class_to_string(MachineClass t) _const_;
115MachineClass machine_class_from_string(const char *s) _pure_;
116
117const char* machine_state_to_string(MachineState t) _const_;
118MachineState machine_state_from_string(const char *s) _pure_;
119
120const char *kill_who_to_string(KillWho k) _const_;
121KillWho kill_who_from_string(const char *s) _pure_;
13d276d0
MP
122
123int machine_openpt(Machine *m, int flags);
db2df898 124int machine_open_terminal(Machine *m, const char *path, int mode);