1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2013 Lennart Poettering
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.
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.
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/>.
24 typedef struct Machine Machine
;
25 typedef struct MachineOperation MachineOperation
;
26 typedef enum KillWho KillWho
;
31 typedef enum MachineState
{
32 MACHINE_OPENING
, /* Machine is being registered */
33 MACHINE_RUNNING
, /* Machine is running */
34 MACHINE_CLOSING
, /* Machine is terminating */
36 _MACHINE_STATE_INVALID
= -1
39 typedef enum MachineClass
{
44 _MACHINE_CLASS_INVALID
= -1
51 _KILL_WHO_INVALID
= -1
54 #define MACHINE_OPERATIONS_MAX 64
56 struct MachineOperation
{
59 sd_bus_message
*message
;
61 sd_event_source
*event_source
;
62 LIST_FIELDS(MachineOperation
, operations
);
82 dual_timestamp timestamp
;
88 sd_bus_message
*create_message
;
93 LIST_FIELDS(Machine
, gc_queue
);
95 MachineOperation
*operations
;
96 unsigned n_operations
;
99 Machine
* machine_new(Manager
*manager
, MachineClass
class, const char *name
);
100 void machine_free(Machine
*m
);
101 bool machine_check_gc(Machine
*m
, bool drop_not_started
);
102 void machine_add_to_gc_queue(Machine
*m
);
103 int machine_start(Machine
*m
, sd_bus_message
*properties
, sd_bus_error
*error
);
104 int machine_stop(Machine
*m
);
105 int machine_finalize(Machine
*m
);
106 int machine_save(Machine
*m
);
107 int machine_load(Machine
*m
);
108 int machine_kill(Machine
*m
, KillWho who
, int signo
);
110 void machine_release_unit(Machine
*m
);
112 MachineState
machine_get_state(Machine
*u
);
114 MachineOperation
*machine_operation_unref(MachineOperation
*o
);
116 const char* machine_class_to_string(MachineClass t
) _const_
;
117 MachineClass
machine_class_from_string(const char *s
) _pure_
;
119 const char* machine_state_to_string(MachineState t
) _const_
;
120 MachineState
machine_state_from_string(const char *s
) _pure_
;
122 const char *kill_who_to_string(KillWho k
) _const_
;
123 KillWho
kill_who_from_string(const char *s
) _pure_
;
125 int machine_openpt(Machine
*m
, int flags
);
126 int machine_open_terminal(Machine
*m
, const char *path
, int mode
);