As per https://github.com/systemd/systemd/pull/41986#pullrequestreview-
4281939586
This also corrects the list of unit types a bit:
1. this removes the mount/automount unit type from the list, since for these types
we do not allow aliases/renaming anyway.
2. this adds socket + swap units to the list, since they can change
name, and for both of them we actually do fork off processes hence
track resources.
Follow-up for: #41986
"Cannot synthesize unit for '%s' (overridden by alias to '%s'): invalid unit type. Skipping stale state.",
original_name, canonical_name);
- /* Only transition units that track external resources, forget internal ones (eg: timers) */
- if (!IN_SET(t, UNIT_SERVICE, UNIT_SCOPE, UNIT_MOUNT, UNIT_AUTOMOUNT))
+ /* Only transition units that track external resources and can be renamed/know aliases, forget internal ones (eg: timers) */
+ if (!unit_vtable[t]->track_orphaned)
return log_warning_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"Cannot synthesize unit for '%s' (overridden by alias to '%s'): unsupported unit type. Skipping stale state.",
original_name, canonical_name);
.can_transient = true,
.can_fail = true,
.exclude_from_switch_root_serialization = true,
+ .notify_plymouth = true,
+ .track_orphaned = true,
.init = mount_init,
.load = mount_load,
},
.test_startable = mount_test_startable,
-
- .notify_plymouth = true,
};
.can_fail = true,
.once_only = true,
.can_set_managed_oom = true,
+ .track_orphaned = true,
.init = scope_init,
.load = scope_load,
.can_delegate = true,
.can_fail = true,
.can_set_managed_oom = true,
+ .notify_plymouth = true,
+ .track_orphaned = true,
.init = service_init,
.done = service_done,
.test_startable = service_test_startable,
- .notify_plymouth = true,
-
.audit_start_message_type = AUDIT_SERVICE_START,
.audit_stop_message_type = AUDIT_SERVICE_STOP,
};
.can_transient = true,
.can_trigger = true,
.can_fail = true,
+ .track_orphaned = true,
.init = socket_init,
.done = socket_done,
.private_section = "Swap",
.can_fail = true,
+ .track_orphaned = true,
.init = swap_init,
.load = swap_load,
/* If true, we'll notify a surrounding VMM/container manager about this unit becoming available */
bool notify_supervisor;
+ /* If true, we'll synthesize an 'orphaned' unit if a unit becomes an alias of another unit during a
+ * reload cycle, but still has resources assigned to it */
+ bool track_orphaned;
+
/* The audit events to generate on start + stop (or 0 if none shall be generated) */
int audit_start_message_type;
int audit_stop_message_type;