]>
Commit | Line | Data |
---|---|---|
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 | ||
24 | typedef struct Machine Machine; | |
25 | ||
26 | #include "list.h" | |
27 | #include "util.h" | |
28 | #include "logind.h" | |
29 | #include "logind-session.h" | |
30 | ||
fb6becb4 LP |
31 | typedef 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 |
39 | typedef enum MachineClass { |
40 | MACHINE_CONTAINER, | |
41 | MACHINE_VM, | |
42 | _MACHINE_CLASS_MAX, | |
43 | _MACHINE_CLASS_INVALID = -1 | |
44 | } MachineClass; | |
45 | ||
46 | struct Machine { | |
47 | Manager *manager; | |
48 | ||
49 | char *name; | |
50 | sd_id128_t id; | |
51 | ||
fb6becb4 | 52 | MachineState state; |
9444b1f2 LP |
53 | MachineClass class; |
54 | ||
55 | char *state_file; | |
56 | char *service; | |
9444b1f2 LP |
57 | char *root_directory; |
58 | ||
fb6becb4 LP |
59 | char *scope; |
60 | char *scope_job; | |
61 | ||
9444b1f2 LP |
62 | pid_t leader; |
63 | ||
64 | dual_timestamp timestamp; | |
65 | ||
66 | bool in_gc_queue:1; | |
67 | bool started:1; | |
68 | ||
fb6becb4 LP |
69 | DBusMessage *create_message; |
70 | ||
9444b1f2 LP |
71 | LIST_FIELDS(Machine, gc_queue); |
72 | }; | |
73 | ||
74 | Machine* machine_new(Manager *manager, const char *name); | |
75 | void machine_free(Machine *m); | |
76 | int machine_check_gc(Machine *m, bool drop_not_started); | |
77 | void machine_add_to_gc_queue(Machine *m); | |
78 | int machine_start(Machine *m); | |
79 | int machine_stop(Machine *m); | |
80 | int machine_save(Machine *m); | |
81 | int machine_load(Machine *m); | |
82 | int machine_kill(Machine *m, KillWho who, int signo); | |
83 | ||
84 | char *machine_bus_path(Machine *s); | |
85 | ||
fb6becb4 LP |
86 | MachineState machine_get_state(Machine *u); |
87 | ||
9444b1f2 LP |
88 | extern const DBusObjectPathVTable bus_machine_vtable; |
89 | ||
90 | int machine_send_signal(Machine *m, bool new_machine); | |
91 | int machine_send_changed(Machine *m, const char *properties); | |
92 | ||
fb6becb4 LP |
93 | int machine_send_create_reply(Machine *m, DBusError *error); |
94 | ||
9444b1f2 LP |
95 | const char* machine_class_to_string(MachineClass t) _const_; |
96 | MachineClass machine_class_from_string(const char *s) _pure_; | |
fb6becb4 LP |
97 | |
98 | const char* machine_state_to_string(MachineState t) _const_; | |
99 | MachineState machine_state_from_string(const char *s) _pure_; |