machine.c revision 90b2de37b80603168f4e9c9c81cff7eea4efa21a
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering This file is part of systemd.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Copyright 2011 Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering (at your option) any later version.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is distributed in the hope that it will be useful, but
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Lesser General Public License for more details.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart PoetteringMachine* machine_new(Manager *manager, const char *name) {
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek m->state_file = strappend("/run/systemd/machines/", m->name);
875c6e1b48f37a07dfbb80d6653c73f205e94260Lennart Poettering if (hashmap_put(manager->machines, m->name, m) < 0)
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering LIST_REMOVE(gc_queue, m->manager->machine_gc_queue, m);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering hashmap_remove(m->manager->machine_units, m->scope);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering hashmap_remove(m->manager->machines, m->name);
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek hashmap_remove_value(m->manager->machine_leaders, UINT_TO_PTR(m->leader), m);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering r = mkdir_safe_label("/run/systemd/machines", 0755, 0, 0);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering r = fopen_temporary(m->state_file, &f, &temp_path);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering "# This is private data. Do not parse.\n"
m->name);
if (m->scope)
if (m->scope_job)
if (m->service)
if (m->root_directory)
if (m->leader != 0)
fprintf(f,
fflush(f);
r = -errno;
assert(m);
NULL);
if (r == -ENOENT)
if (id)
if (leader)
if (class) {
MachineClass c;
m->class = c;
if (realtime) {
if (monotonic) {
assert(m);
if (!m->scope) {
if (!escaped)
return log_oom();
if (!scope)
return log_oom();
r = manager_start_scope(m->manager, scope, m->leader, SPECIAL_MACHINE_SLICE, description, properties, error, &job);
if (m->scope)
assert(m);
if (m->started)
NULL);
m->started = true;
machine_save(m);
machine_send_signal(m, true);
char *job;
assert(m);
if (!m->scope)
assert(m);
if (m->started)
NULL);
k = machine_stop_scope(m);
if (m->started)
machine_send_signal(m, false);
m->started = false;
assert(m);
assert(m);
if (m->in_gc_queue)
m->in_gc_queue = true;
assert(s);
if (s->scope_job)
return MACHINE_RUNNING;
assert(m);
if (!m->scope)
return -ESRCH;