free(m->state_file);
free(m->service);
free(m->root_directory);
+ free(m->netif);
free(m);
}
m->timestamp.realtime,
m->timestamp.monotonic);
+ if (m->n_netif > 0) {
+ unsigned i;
+
+ fputs("NETIF=", f);
+
+ for (i = 0; i < m->n_netif; i++) {
+ if (i != 0)
+ fputc(' ', f);
+
+ fprintf(f, "%i", m->netif[i]);
+ }
+
+ fputc('\n', f);
+ }
+
r = fflush_and_check(f);
if (r < 0)
goto finish;
}
int machine_load(Machine *m) {
- _cleanup_free_ char *realtime = NULL, *monotonic = NULL, *id = NULL, *leader = NULL, *class = NULL;
+ _cleanup_free_ char *realtime = NULL, *monotonic = NULL, *id = NULL, *leader = NULL, *class = NULL, *netif = NULL;
int r;
assert(m);
"CLASS", &class,
"REALTIME", &realtime,
"MONOTONIC", &monotonic,
+ "NETIF", &netif,
NULL);
if (r < 0) {
if (r == -ENOENT)
m->timestamp.monotonic = l;
}
+ if (netif) {
+ size_t l, allocated = 0, nr = 0;
+ const char *word, *state;
+ int *ni = NULL;
+
+ FOREACH_WORD(word, l, netif, state) {
+ char buf[l+1];
+ int ifi;
+
+ *(char*) (mempcpy(buf, word, l)) = 0;
+
+ if (safe_atoi(buf, &ifi) < 0)
+ continue;
+ if (ifi <= 0)
+ continue;
+
+ if (!GREEDY_REALLOC(ni, allocated, nr+1)) {
+ free(ni);
+ return log_oom();
+ }
+
+ ni[nr++] = ifi;
+ }
+
+ free(m->netif);
+ m->netif = ni;
+ m->n_netif = nr;
+ }
+
return r;
}
if (!m->unit)
return 0;
- r = manager_stop_unit(m->manager, m->unit, &error, &job);
- if (r < 0) {
- log_error("Failed to stop machine scope: %s", bus_error_message(&error, r));
- return r;
+ if (!m->registered) {
+ r = manager_stop_unit(m->manager, m->unit, &error, &job);
+ if (r < 0) {
+ log_error("Failed to stop machine scope: %s", bus_error_message(&error, r));
+ return r;
+ }
}
free(m->scope_job);
m->scope_job = job;
- return r;
+ return 0;
}
int machine_stop(Machine *m) {
if (kill(m->leader, signo) < 0)
return -errno;
+
+ return 0;
}
/* Otherwise make PID 1 do it for us, for the entire cgroup */