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