chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup: run PID 1 in the root cgroup
[elogind.git]
/
src
/
core
/
snapshot.c
diff --git
a/src/core/snapshot.c
b/src/core/snapshot.c
index 5bb3c4a8fd1548c598331f62d7d9310969d50130..d11239dff395995b1234ba90af75bda815b584b0 100644
(file)
--- a/
src/core/snapshot.c
+++ b/
src/core/snapshot.c
@@
-40,6
+40,7
@@
static void snapshot_init(Unit *u) {
UNIT(s)->ignore_on_isolate = true;
UNIT(s)->ignore_on_snapshot = true;
UNIT(s)->ignore_on_isolate = true;
UNIT(s)->ignore_on_snapshot = true;
+ UNIT(s)->allow_isolate = true;
}
static void snapshot_set_state(Snapshot *s, SnapshotState state) {
}
static void snapshot_set_state(Snapshot *s, SnapshotState state) {
@@
-66,7
+67,7
@@
static int snapshot_load(Unit *u) {
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
/* Make sure that only snapshots created via snapshot_create()
* can be loaded */
- if (!
s->by_snapshot_create
&& UNIT(s)->manager->n_reloading <= 0)
+ if (!
u->transient
&& UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
u->load_state = UNIT_LOADED;
return -ENOENT;
u->load_state = UNIT_LOADED;
@@
-151,21
+152,24
@@
static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
if (streq(key, "state")) {
SnapshotState state;
if (streq(key, "state")) {
SnapshotState state;
- if ((state = snapshot_state_from_string(value)) < 0)
+ state = snapshot_state_from_string(value);
+ if (state < 0)
log_debug("Failed to parse state value %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "cleanup")) {
log_debug("Failed to parse state value %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "cleanup")) {
- if ((r = parse_boolean(value)) < 0)
+ r = parse_boolean(value);
+ if (r < 0)
log_debug("Failed to parse cleanup value %s", value);
else
s->cleanup = r;
} else if (streq(key, "wants")) {
log_debug("Failed to parse cleanup value %s", value);
else
s->cleanup = r;
} else if (streq(key, "wants")) {
- if ((r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_WANTS, value, NULL, true)) < 0)
+ r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_WANTS, value, NULL, true);
+ if (r < 0)
return r;
} else
log_debug("Unknown serialization key '%s'", key);
return r;
} else
log_debug("Unknown serialization key '%s'", key);
@@
-173,22
+177,22
@@
static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
return 0;
}
return 0;
}
-static UnitActiveState snapshot_active_state(Unit *u) {
+
_pure_
static UnitActiveState snapshot_active_state(Unit *u) {
assert(u);
return state_translation_table[SNAPSHOT(u)->state];
}
assert(u);
return state_translation_table[SNAPSHOT(u)->state];
}
-static const char *snapshot_sub_state_to_string(Unit *u) {
+
_pure_
static const char *snapshot_sub_state_to_string(Unit *u) {
assert(u);
return snapshot_state_to_string(SNAPSHOT(u)->state);
}
int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Snapshot **_s) {
assert(u);
return snapshot_state_to_string(SNAPSHOT(u)->state);
}
int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Snapshot **_s) {
-
Iterator i
;
+
_cleanup_free_ char *n = NULL
;
Unit *other, *u = NULL;
Unit *other, *u = NULL;
-
char *n = NULL
;
+
Iterator i
;
int r;
const char *k;
int r;
const char *k;
@@
-217,28
+221,28
@@
int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Sn
if (asprintf(&n, "snapshot-%u.snapshot", ++ m->n_snapshots) < 0)
return -ENOMEM;
if (asprintf(&n, "snapshot-%u.snapshot", ++ m->n_snapshots) < 0)
return -ENOMEM;
- if (!manager_get_unit(m, n))
+ if (!manager_get_unit(m, n)) {
+ name = n;
break;
break;
+ }
free(n);
free(n);
+ n = NULL;
}
}
-
- name = n;
}
r = manager_load_unit_prepare(m, name, NULL, e, &u);
}
r = manager_load_unit_prepare(m, name, NULL, e, &u);
- free(n);
-
if (r < 0)
goto fail;
if (r < 0)
goto fail;
-
SNAPSHOT(u)->by_snapshot_create
= true;
+
u->transient
= true;
manager_dispatch_load_queue(m);
assert(u->load_state == UNIT_LOADED);
HASHMAP_FOREACH_KEY(other, k, m->units, i) {
manager_dispatch_load_queue(m);
assert(u->load_state == UNIT_LOADED);
HASHMAP_FOREACH_KEY(other, k, m->units, i) {
- if (other->ignore_on_snapshot)
+ if (other->ignore_on_snapshot ||
+ other->transient)
continue;
if (k != other->id)
continue;
if (k != other->id)
@@
-251,7
+255,8
@@
int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Sn
if (!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
continue;
if (!UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(other)))
continue;
- if ((r = unit_add_two_dependencies(u, UNIT_AFTER, UNIT_WANTS, other, true)) < 0)
+ r = unit_add_two_dependencies(u, UNIT_AFTER, UNIT_WANTS, other, true);
+ if (r < 0)
goto fail;
}
goto fail;
}
@@
-281,7
+286,6
@@
static const char* const snapshot_state_table[_SNAPSHOT_STATE_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(snapshot_state, SnapshotState);
const UnitVTable snapshot_vtable = {
DEFINE_STRING_TABLE_LOOKUP(snapshot_state, SnapshotState);
const UnitVTable snapshot_vtable = {
- .suffix = ".snapshot",
.object_size = sizeof(Snapshot),
.no_alias = true,
.object_size = sizeof(Snapshot),
.no_alias = true,