'varlink-metrics.c',
'varlink-mount.c',
'varlink-path.c',
+ 'varlink-scope.c',
'varlink-unit.c',
)
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "sd-json.h"
+
+#include "json-util.h"
+#include "scope.h"
+#include "varlink-scope.h"
+
+int scope_context_build_json(sd_json_variant **ret, const char *name, void *userdata) {
+ Scope *s = ASSERT_PTR(SCOPE(userdata));
+
+ return sd_json_buildo(
+ ASSERT_PTR(ret),
+ JSON_BUILD_PAIR_ENUM("OOMPolicy", oom_policy_to_string(s->oom_policy)),
+ JSON_BUILD_PAIR_FINITE_USEC("RuntimeMaxUSec", s->runtime_max_usec),
+ JSON_BUILD_PAIR_FINITE_USEC("RuntimeRandomizedExtraUSec", s->runtime_rand_extra_usec),
+ JSON_BUILD_PAIR_FINITE_USEC("TimeoutStopUSec", s->timeout_stop_usec));
+}
+
+int scope_runtime_build_json(sd_json_variant **ret, const char *name, void *userdata) {
+ Scope *s = ASSERT_PTR(SCOPE(userdata));
+
+ return sd_json_buildo(
+ ASSERT_PTR(ret),
+ JSON_BUILD_PAIR_ENUM("Result", scope_result_to_string(s->result)));
+}
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "core-forward.h"
+
+int scope_context_build_json(sd_json_variant **ret, const char *name, void *userdata);
+int scope_runtime_build_json(sd_json_variant **ret, const char *name, void *userdata);
#include "varlink-kill.h"
#include "varlink-mount.h"
#include "varlink-path.h"
+#include "varlink-scope.h"
#include "varlink-unit.h"
#include "varlink-util.h"
[UNIT_AUTOMOUNT] = automount_context_build_json,
[UNIT_MOUNT] = mount_context_build_json,
[UNIT_PATH] = path_context_build_json,
+ [UNIT_SCOPE] = scope_context_build_json,
[UNIT_SERVICE] = service_context_build_json,
};
[UNIT_AUTOMOUNT] = automount_runtime_build_json,
[UNIT_MOUNT] = mount_runtime_build_json,
[UNIT_PATH] = path_runtime_build_json,
+ [UNIT_SCOPE] = scope_runtime_build_json,
};
return sd_json_buildo(
SD_VARLINK_FIELD_COMMENT("Result of path operation"),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(Result, PathResult, 0));
+/* ScopeContext
+ * https://www.freedesktop.org/software/systemd/man/latest/systemd.scope.html */
+static SD_VARLINK_DEFINE_STRUCT_TYPE(
+ ScopeContext,
+ SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd.scope.html#OOMPolicy="),
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(OOMPolicy, OOMPolicy, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd.scope.html#RuntimeMaxSec="),
+ SD_VARLINK_DEFINE_FIELD(RuntimeMaxUSec, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd.scope.html#RuntimeRandomizedExtraSec="),
+ SD_VARLINK_DEFINE_FIELD(RuntimeRandomizedExtraUSec, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("https://www.freedesktop.org/software/systemd/man/"PROJECT_VERSION_STR"/systemd.scope.html#TimeoutStopSec="),
+ SD_VARLINK_DEFINE_FIELD(TimeoutStopUSec, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
+
+SD_VARLINK_DEFINE_ENUM_TYPE(
+ ScopeResult,
+ SD_VARLINK_DEFINE_ENUM_VALUE(success),
+ SD_VARLINK_DEFINE_ENUM_VALUE(resources),
+ SD_VARLINK_DEFINE_ENUM_VALUE(timeout),
+ SD_VARLINK_DEFINE_ENUM_VALUE(oom_kill));
+
+static SD_VARLINK_DEFINE_STRUCT_TYPE(
+ ScopeRuntime,
+ SD_VARLINK_FIELD_COMMENT("Result of scope operation"),
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(Result, ScopeResult, 0));
+
/* Service-specific types */
/* Keep in sync with service_type_table[] in src/core/service.c */
SD_VARLINK_FIELD_COMMENT("The mount context of the unit"),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(Mount, MountContext, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The path context of the unit"),
- SD_VARLINK_DEFINE_FIELD_BY_TYPE(Path, PathContext, SD_VARLINK_NULLABLE));
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(Path, PathContext, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("The scope context of the unit"),
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(Scope, ScopeContext, SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ActivationDetails,
SD_VARLINK_FIELD_COMMENT("The mount runtime of the unit"),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(Mount, MountRuntime, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The path runtime of the unit"),
- SD_VARLINK_DEFINE_FIELD_BY_TYPE(Path, PathRuntime, SD_VARLINK_NULLABLE));
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(Path, PathRuntime, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("The scope runtime of the unit"),
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(Scope, ScopeRuntime, SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_METHOD_FULL(
List,
&vl_type_PathContext,
&vl_type_PathResult,
&vl_type_PathRuntime,
+ &vl_type_OOMPolicy,
+ &vl_type_ScopeContext,
+ &vl_type_ScopeResult,
+ &vl_type_ScopeRuntime,
/* UnitContext enums */
&vl_type_CollectMode,
extern const sd_varlink_symbol vl_type_MountResult;
extern const sd_varlink_symbol vl_type_PathType;
extern const sd_varlink_symbol vl_type_PathResult;
+extern const sd_varlink_symbol vl_type_ScopeResult;
extern const sd_varlink_symbol vl_type_CollectMode;
extern const sd_varlink_symbol vl_type_JobMode;
extern const sd_varlink_symbol vl_type_ServiceType;
#include "numa-util.h"
#include "path.h"
#include "process-util.h"
+#include "scope.h"
#include "service.h"
+#include "swap.h"
#include "tests.h"
#include "test-varlink-idl-util.h"
#include "unit.h"
/* PathRuntime enums */
TEST_IDL_ENUM(PathResult, path_result, vl_type_PathResult);
+ /* ScopeRuntime enums */
+ TEST_IDL_ENUM(ScopeResult, scope_result, vl_type_ScopeResult);
+
/* UnitContext enums */
TEST_IDL_ENUM(CollectMode, collect_mode, vl_type_CollectMode);
TEST_IDL_ENUM(EmergencyAction, emergency_action, vl_type_EmergencyAction);
path_params=$(jq -cn --arg name "$path_id" '{name: $name}')
varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List "$path_params" | jq -e '.context.Path'
varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List "$path_params" | jq -e '.runtime.Path'
+# test for ScopeContext/Runtime
+scope_id=$(varlinkctl call --collect /run/systemd/io.systemd.Manager io.systemd.Unit.List '{}' | jq -r '.[] | select(.context.Type == "scope" and .runtime.LoadState == "loaded") .context.ID' | grep -v null | tail -n 1)
+test -n "$scope_id"
+scope_params=$(jq -cn --arg name "$scope_id" '{name: $name}')
+varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List "$scope_params" | jq -e '.context.Scope'
+varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Unit.List "$scope_params" | jq -e '.runtime.Scope'
# test io.systemd.Metrics
varlinkctl info /run/systemd/report/io.systemd.Manager