mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
unit: don't serialize job state, only unit state across switch-root
This commit is contained in:
parent
5b00c0168b
commit
6b78f9b435
2
TODO
2
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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user