summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-07-02 17:17:35 +0200
committerLennart Poettering <lennart@poettering.net>2013-07-02 17:18:41 +0200
commitd0af76e68a5bab2e4fd9674b1c64a9f38d7afe97 (patch)
treea45e3254f7b2737fb24c142c4a41f5f0e98f0108 /src/machine
parent8b6fe8243d6a46d7435fb6789481489c44549cfb (diff)
logind: after deserializatio readd systemd units to unit-to-object hashmap correctly
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machine.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c
index 7d64abe5d..8e03ff2ec 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -228,34 +228,36 @@ static int machine_start_scope(Machine *m) {
dbus_error_init(&error);
if (!m->scope) {
- char *escaped = NULL;
+ _cleanup_free_ char *escaped = NULL;
+ char *scope;
escaped = unit_name_escape(m->name);
if (!escaped)
return log_oom();
- m->scope = strjoin("machine-", escaped, ".scope", NULL);
- free(escaped);
-
- if (!m->scope)
+ scope = strjoin("machine-", escaped, ".scope", NULL);
+ if (scope)
return log_oom();
- r = hashmap_put(m->manager->machine_units, m->scope, m);
- if (r < 0)
- log_warning("Failed to create mapping between unit and machine");
- }
+ description = strappend(m->class == MACHINE_VM ? "Virtual Machine " : "Container ", m->name);
- description = strappend(m->class == MACHINE_VM ? "Virtual Machine " : "Container ", m->name);
+ r = manager_start_scope(m->manager, m->scope, m->leader, SPECIAL_MACHINE_SLICE, description, &error, &job);
+ if (r < 0) {
+ log_error("Failed to start machine scope: %s", bus_error(&error, r));
+ dbus_error_free(&error);
- r = manager_start_scope(m->manager, m->scope, m->leader, SPECIAL_MACHINE_SLICE, description, &error, &job);
- if (r < 0) {
- log_error("Failed to start machine scope: %s", bus_error(&error, r));
- dbus_error_free(&error);
- } else {
- free(m->scope_job);
- m->scope_job = job;
+ free(scope);
+ } else {
+ m->scope = scope;
+
+ free(m->scope_job);
+ m->scope_job = job;
+ }
}
+ if (m->scope)
+ hashmap_put(m->manager->machine_units, m->scope, m);
+
return r;
}