shared/condition: add ConditionControlGroupController=v1|v2

Before, we only allowed conditionalizing on controllers, not the hierarchy.
This commit extends this to allow a simple check for v1 (i.e. classic or hybrid),
and v2 (full unified).

An alternative approach would be to add a separate Condition for this, but I'm
not too keen on that, considering that v1 is already being deprecrecated
(c.f. 82f3063218).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-02-23 01:11:18 +01:00
parent 6c3f7ca036
commit 8ebfd50aaf
3 changed files with 47 additions and 10 deletions
+9
View File
@@ -354,6 +354,15 @@ static int condition_test_control_group_controller(Condition *c, char **env) {
assert(c->parameter);
assert(c->type == CONDITION_CONTROL_GROUP_CONTROLLER);
if (streq(c->parameter, "v2"))
return cg_all_unified();
if (streq(c->parameter, "v1")) {
r = cg_all_unified();
if (r < 0)
return r;
return !r;
}
r = cg_mask_supported(&system_mask);
if (r < 0)
return log_debug_errno(r, "Failed to determine supported controllers: %m");