summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-07-18 01:46:52 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-18 01:46:52 +0200
commit6b78f9b4354010f8af2fe48c783ffd52b2db8f57 (patch)
treefc867017eb6a4fef2822264161ce4fefd444152a
parent5b00c0168be6e7b11db7b26fc1712cd6cda3c2e3 (diff)
unit: don't serialize job state, only unit state across switch-root
-rw-r--r--TODO2
-rw-r--r--src/core/main.c21
-rw-r--r--src/core/manager.c6
-rw-r--r--src/core/manager.h2
-rw-r--r--src/core/unit.c19
-rw-r--r--src/core/unit.h2
6 files changed, 31 insertions, 21 deletions
diff --git a/TODO b/TODO
index d1fbed5c58..86a2463cc3 100644
--- a/TODO
+++ b/TODO
@@ -34,6 +34,8 @@ Bugfixes:
Features:
+* syscall filter: add knowledge about compat syscalls
+
* flush jobs when switching root
* autorestart of journald after switch-root is broken
diff --git a/src/core/main.c b/src/core/main.c
index 022d05a31b..c7a7a87e7a 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1058,7 +1058,7 @@ static int version(void) {
return 0;
}
-static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) {
+static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool serialize_jobs) {
FILE *f = NULL;
FDSet *fds = NULL;
int r;
@@ -1070,18 +1070,21 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) {
/* Make sure nothing is really destructed when we shut down */
m->n_reloading ++;
- if ((r = manager_open_serialization(m, &f)) < 0) {
+ r = manager_open_serialization(m, &f);
+ if (r < 0) {
log_error("Failed to create serialization file: %s", strerror(-r));
goto fail;
}
- if (!(fds = fdset_new())) {
+ fds = fdset_new();
+ if (!fds) {
r = -ENOMEM;
log_error("Failed to allocate fd set: %s", strerror(-r));
goto fail;
}
- if ((r = manager_serialize(m, f, fds)) < 0) {
+ r = manager_serialize(m, f, fds, serialize_jobs);
+ if (r < 0) {
log_error("Failed to serialize state: %s", strerror(-r));
goto fail;
}
@@ -1091,12 +1094,14 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) {
goto fail;
}
- if ((r = fd_cloexec(fileno(f), false)) < 0) {
+ r = fd_cloexec(fileno(f), false);
+ if (r < 0) {
log_error("Failed to disable O_CLOEXEC for serialization: %s", strerror(-r));
goto fail;
}
- if ((r = fdset_cloexec(fds, false)) < 0) {
+ r = fdset_cloexec(fds, false);
+ if (r < 0) {
log_error("Failed to disable O_CLOEXEC for serialization fds: %s", strerror(-r));
goto fail;
}
@@ -1624,7 +1629,7 @@ int main(int argc, char *argv[]) {
case MANAGER_REEXECUTE:
- if (prepare_reexecute(m, &serialization, &fds) < 0)
+ if (prepare_reexecute(m, &serialization, &fds, true) < 0)
goto finish;
reexecute = true;
@@ -1638,7 +1643,7 @@ int main(int argc, char *argv[]) {
m->switch_root = m->switch_root_init = NULL;
if (!switch_root_init)
- if (prepare_reexecute(m, &serialization, &fds) < 0)
+ if (prepare_reexecute(m, &serialization, &fds, false) < 0)
goto finish;
reexecute = true;
diff --git a/src/core/manager.c b/src/core/manager.c
index 8f2635051e..27dc9f38e0 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1722,7 +1722,7 @@ int manager_open_serialization(Manager *m, FILE **_f) {
return 0;
}
-int manager_serialize(Manager *m, FILE *f, FDSet *fds) {
+int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs) {
Iterator i;
Unit *u;
const char *t;
@@ -1759,7 +1759,7 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds) {
fputs(u->id, f);
fputc('\n', f);
- if ((r = unit_serialize(u, f, fds)) < 0) {
+ if ((r = unit_serialize(u, f, fds, serialize_jobs)) < 0) {
m->n_reloading --;
return r;
}
@@ -1899,7 +1899,7 @@ int manager_reload(Manager *m) {
goto finish;
}
- r = manager_serialize(m, f, fds);
+ r = manager_serialize(m, f, fds, true);
if (r < 0) {
m->n_reloading --;
goto finish;
diff --git a/src/core/manager.h b/src/core/manager.h
index be2780bafe..6c81f92d63 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -278,7 +278,7 @@ void manager_dispatch_bus_query_pid_done(Manager *m, const char *name, pid_t pid
int manager_open_serialization(Manager *m, FILE **_f);
-int manager_serialize(Manager *m, FILE *f, FDSet *fds);
+int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs);
int manager_deserialize(Manager *m, FILE *f, FDSet *fds);
int manager_reload(Manager *m);
diff --git a/src/core/unit.c b/src/core/unit.c
index 7994f7038e..ae6f69183d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2401,7 +2401,7 @@ bool unit_can_serialize(Unit *u) {
return UNIT_VTABLE(u)->serialize && UNIT_VTABLE(u)->deserialize_item;
}
-int unit_serialize(Unit *u, FILE *f, FDSet *fds) {
+int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
int r;
assert(u);
@@ -2414,14 +2414,17 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds) {
if ((r = UNIT_VTABLE(u)->serialize(u, f, fds)) < 0)
return r;
- if (u->job) {
- fprintf(f, "job\n");
- job_serialize(u->job, f, fds);
- }
- if (u->nop_job) {
- fprintf(f, "job\n");
- job_serialize(u->nop_job, f, fds);
+ if (serialize_jobs) {
+ if (u->job) {
+ fprintf(f, "job\n");
+ job_serialize(u->job, f, fds);
+ }
+
+ if (u->nop_job) {
+ fprintf(f, "job\n");
+ job_serialize(u->nop_job, f, fds);
+ }
}
dual_timestamp_serialize(f, "inactive-exit-timestamp", &u->inactive_exit_timestamp);
diff --git a/src/core/unit.h b/src/core/unit.h
index 2483e4ea9d..d0a5d641d0 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -499,7 +499,7 @@ char *unit_full_printf(Unit *u, const char *text);
char **unit_full_printf_strv(Unit *u, char **l);
bool unit_can_serialize(Unit *u);
-int unit_serialize(Unit *u, FILE *f, FDSet *fds);
+int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs);
void unit_serialize_item_format(Unit *u, FILE *f, const char *key, const char *value, ...) _printf_attr_(4,5);
void unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value);
int unit_deserialize(Unit *u, FILE *f, FDSet *fds);