mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
unit: make ignoring in snapshots a per unit property, instead of a per unit type property
This commit is contained in:
parent
a96257af78
commit
7a6000a682
@ -470,6 +470,18 @@
|
|||||||
<option>false</option>.</para></listitem>
|
<option>false</option>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>IgnoreOnSnapshot=</varname></term>
|
||||||
|
|
||||||
|
<listitem><para>Takes a boolean
|
||||||
|
argument. If <option>true</option>
|
||||||
|
this unit will not be included in
|
||||||
|
snapshots. Defaults to
|
||||||
|
<option>false</option> for device and
|
||||||
|
snapshot units, <option>true</option>
|
||||||
|
for the others.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>StopWhenUnneeded=</varname></term>
|
<term><varname>StopWhenUnneeded=</varname></term>
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@
|
|||||||
" <property name=\"DefaultDependencies\" type=\"b\" access=\"read\"/>\n" \
|
" <property name=\"DefaultDependencies\" type=\"b\" access=\"read\"/>\n" \
|
||||||
" <property name=\"OnFailureIsolate\" type=\"b\" access=\"read\"/>\n" \
|
" <property name=\"OnFailureIsolate\" type=\"b\" access=\"read\"/>\n" \
|
||||||
" <property name=\"IgnoreOnIsolate\" type=\"b\" access=\"read\"/>\n" \
|
" <property name=\"IgnoreOnIsolate\" type=\"b\" access=\"read\"/>\n" \
|
||||||
|
" <property name=\"IgnoreOnSnapshot\" type=\"b\" access=\"read\"/>\n" \
|
||||||
" <property name=\"DefaultControlGroup\" type=\"s\" access=\"read\"/>\n" \
|
" <property name=\"DefaultControlGroup\" type=\"s\" access=\"read\"/>\n" \
|
||||||
" <property name=\"ControlGroup\" type=\"as\" access=\"read\"/>\n" \
|
" <property name=\"ControlGroup\" type=\"as\" access=\"read\"/>\n" \
|
||||||
" <property name=\"NeedDaemonReload\" type=\"b\" access=\"read\"/>\n" \
|
" <property name=\"NeedDaemonReload\" type=\"b\" access=\"read\"/>\n" \
|
||||||
@ -162,6 +163,7 @@
|
|||||||
{ "org.freedesktop.systemd1.Unit", "DefaultDependencies", bus_property_append_bool, "b", &u->meta.default_dependencies }, \
|
{ "org.freedesktop.systemd1.Unit", "DefaultDependencies", bus_property_append_bool, "b", &u->meta.default_dependencies }, \
|
||||||
{ "org.freedesktop.systemd1.Unit", "OnFailureIsolate", bus_property_append_bool, "b", &u->meta.on_failure_isolate }, \
|
{ "org.freedesktop.systemd1.Unit", "OnFailureIsolate", bus_property_append_bool, "b", &u->meta.on_failure_isolate }, \
|
||||||
{ "org.freedesktop.systemd1.Unit", "IgnoreOnIsolate", bus_property_append_bool, "b", &u->meta.ignore_on_isolate }, \
|
{ "org.freedesktop.systemd1.Unit", "IgnoreOnIsolate", bus_property_append_bool, "b", &u->meta.ignore_on_isolate }, \
|
||||||
|
{ "org.freedesktop.systemd1.Unit", "IgnoreOnSnapshot", bus_property_append_bool, "b", &u->meta.ignore_on_snapshot }, \
|
||||||
{ "org.freedesktop.systemd1.Unit", "DefaultControlGroup", bus_unit_append_default_cgroup, "s", u }, \
|
{ "org.freedesktop.systemd1.Unit", "DefaultControlGroup", bus_unit_append_default_cgroup, "s", u }, \
|
||||||
{ "org.freedesktop.systemd1.Unit", "ControlGroup", bus_unit_append_cgroups, "as", u }, \
|
{ "org.freedesktop.systemd1.Unit", "ControlGroup", bus_unit_append_cgroups, "as", u }, \
|
||||||
{ "org.freedesktop.systemd1.Unit", "NeedDaemonReload", bus_unit_append_need_daemon_reload, "b", u }, \
|
{ "org.freedesktop.systemd1.Unit", "NeedDaemonReload", bus_unit_append_need_daemon_reload, "b", u }, \
|
||||||
|
@ -72,6 +72,7 @@ static void device_init(Unit *u) {
|
|||||||
d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
|
d->meta.job_timeout = DEFAULT_TIMEOUT_USEC;
|
||||||
|
|
||||||
d->meta.ignore_on_isolate = true;
|
d->meta.ignore_on_isolate = true;
|
||||||
|
d->meta.ignore_on_snapshot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_done(Unit *u) {
|
static void device_done(Unit *u) {
|
||||||
@ -584,7 +585,6 @@ const UnitVTable device_vtable = {
|
|||||||
.suffix = ".device",
|
.suffix = ".device",
|
||||||
|
|
||||||
.no_instances = true,
|
.no_instances = true,
|
||||||
.no_snapshots = true,
|
|
||||||
|
|
||||||
.init = device_init,
|
.init = device_init,
|
||||||
|
|
||||||
|
@ -1878,6 +1878,7 @@ static int load_from_path(Unit *u, const char *path) {
|
|||||||
{ "DefaultDependencies", config_parse_bool, 0, &u->meta.default_dependencies, "Unit" },
|
{ "DefaultDependencies", config_parse_bool, 0, &u->meta.default_dependencies, "Unit" },
|
||||||
{ "OnFailureIsolate", config_parse_bool, 0, &u->meta.on_failure_isolate, "Unit" },
|
{ "OnFailureIsolate", config_parse_bool, 0, &u->meta.on_failure_isolate, "Unit" },
|
||||||
{ "IgnoreOnIsolate", config_parse_bool, 0, &u->meta.ignore_on_isolate, "Unit" },
|
{ "IgnoreOnIsolate", config_parse_bool, 0, &u->meta.ignore_on_isolate, "Unit" },
|
||||||
|
{ "IgnoreOnSnapshot", config_parse_bool, 0, &u->meta.ignore_on_snapshot, "Unit" },
|
||||||
{ "JobTimeoutSec", config_parse_usec, 0, &u->meta.job_timeout, "Unit" },
|
{ "JobTimeoutSec", config_parse_usec, 0, &u->meta.job_timeout, "Unit" },
|
||||||
{ "ConditionPathExists", config_parse_condition_path, CONDITION_PATH_EXISTS, u, "Unit" },
|
{ "ConditionPathExists", config_parse_condition_path, CONDITION_PATH_EXISTS, u, "Unit" },
|
||||||
{ "ConditionPathIsDirectory", config_parse_condition_path, CONDITION_PATH_IS_DIRECTORY, u, "Unit" },
|
{ "ConditionPathIsDirectory", config_parse_condition_path, CONDITION_PATH_IS_DIRECTORY, u, "Unit" },
|
||||||
|
@ -32,6 +32,16 @@ static const UnitActiveState state_translation_table[_SNAPSHOT_STATE_MAX] = {
|
|||||||
[SNAPSHOT_ACTIVE] = UNIT_ACTIVE
|
[SNAPSHOT_ACTIVE] = UNIT_ACTIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void snapshot_init(Unit *u) {
|
||||||
|
Snapshot *s = SNAPSHOT(u);
|
||||||
|
|
||||||
|
assert(s);
|
||||||
|
assert(s->meta.load_state == UNIT_STUB);
|
||||||
|
|
||||||
|
s->meta.ignore_on_isolate = true;
|
||||||
|
s->meta.ignore_on_snapshot = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void snapshot_set_state(Snapshot *s, SnapshotState state) {
|
static void snapshot_set_state(Snapshot *s, SnapshotState state) {
|
||||||
SnapshotState old_state;
|
SnapshotState old_state;
|
||||||
assert(s);
|
assert(s);
|
||||||
@ -228,7 +238,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Sn
|
|||||||
|
|
||||||
HASHMAP_FOREACH_KEY(other, k, m->units, i) {
|
HASHMAP_FOREACH_KEY(other, k, m->units, i) {
|
||||||
|
|
||||||
if (UNIT_VTABLE(other)->no_snapshots)
|
if (other->meta.ignore_on_snapshot)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (k != other->meta.id)
|
if (k != other->meta.id)
|
||||||
@ -275,9 +285,10 @@ const UnitVTable snapshot_vtable = {
|
|||||||
|
|
||||||
.no_alias = true,
|
.no_alias = true,
|
||||||
.no_instances = true,
|
.no_instances = true,
|
||||||
.no_snapshots = true,
|
|
||||||
.no_gc = true,
|
.no_gc = true,
|
||||||
|
|
||||||
|
.init = snapshot_init,
|
||||||
|
|
||||||
.load = snapshot_load,
|
.load = snapshot_load,
|
||||||
.coldplug = snapshot_coldplug,
|
.coldplug = snapshot_coldplug,
|
||||||
|
|
||||||
|
@ -667,13 +667,15 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
|
|||||||
"%s\tRefuseManualStop: %s\n"
|
"%s\tRefuseManualStop: %s\n"
|
||||||
"%s\tDefaultDependencies: %s\n"
|
"%s\tDefaultDependencies: %s\n"
|
||||||
"%s\tOnFailureIsolate: %s\n"
|
"%s\tOnFailureIsolate: %s\n"
|
||||||
"%s\tIgnoreOnIsolate: %s\n",
|
"%s\tIgnoreOnIsolate: %s\n"
|
||||||
|
"%s\tIgnoreOnSnapshot: %s\n",
|
||||||
prefix, yes_no(u->meta.stop_when_unneeded),
|
prefix, yes_no(u->meta.stop_when_unneeded),
|
||||||
prefix, yes_no(u->meta.refuse_manual_start),
|
prefix, yes_no(u->meta.refuse_manual_start),
|
||||||
prefix, yes_no(u->meta.refuse_manual_stop),
|
prefix, yes_no(u->meta.refuse_manual_stop),
|
||||||
prefix, yes_no(u->meta.default_dependencies),
|
prefix, yes_no(u->meta.default_dependencies),
|
||||||
prefix, yes_no(u->meta.on_failure_isolate),
|
prefix, yes_no(u->meta.on_failure_isolate),
|
||||||
prefix, yes_no(u->meta.ignore_on_isolate));
|
prefix, yes_no(u->meta.ignore_on_isolate),
|
||||||
|
prefix, yes_no(u->meta.ignore_on_snapshot));
|
||||||
|
|
||||||
LIST_FOREACH(by_unit, b, u->meta.cgroup_bondings)
|
LIST_FOREACH(by_unit, b, u->meta.cgroup_bondings)
|
||||||
fprintf(f, "%s\tControlGroup: %s:%s\n",
|
fprintf(f, "%s\tControlGroup: %s:%s\n",
|
||||||
|
@ -213,6 +213,9 @@ struct Meta {
|
|||||||
/* Ignore this unit when isolating */
|
/* Ignore this unit when isolating */
|
||||||
bool ignore_on_isolate;
|
bool ignore_on_isolate;
|
||||||
|
|
||||||
|
/* Ignore this unit when snapshotting */
|
||||||
|
bool ignore_on_snapshot;
|
||||||
|
|
||||||
/* Did the last condition check suceed? */
|
/* Did the last condition check suceed? */
|
||||||
bool condition_result;
|
bool condition_result;
|
||||||
|
|
||||||
@ -364,9 +367,6 @@ struct UnitVTable {
|
|||||||
/* Instances make no sense for this type */
|
/* Instances make no sense for this type */
|
||||||
bool no_instances:1;
|
bool no_instances:1;
|
||||||
|
|
||||||
/* Exclude this type from snapshots */
|
|
||||||
bool no_snapshots:1;
|
|
||||||
|
|
||||||
/* Exclude from automatic gc */
|
/* Exclude from automatic gc */
|
||||||
bool no_gc:1;
|
bool no_gc:1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user