Skip to content

Commit 5214e61

Browse files
committed
intelrdt: honor default closID
implement the change specified here: opencontainers/runtime-spec#1289 Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent 989292a commit 5214e61

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/libcrun/intelrdt.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,19 @@ compare_rdt_configurations (const char *a, const char *b)
167167
return 0;
168168
}
169169

170+
static bool
171+
is_default_clos (const char *name)
172+
{
173+
return strcmp (name, "/") == 0;
174+
}
175+
170176
static int
171177
get_resctrl_path (char **path, const char *file, const char *name, libcrun_error_t *err)
172178
{
173-
if (file)
174-
return append_paths (path, err, INTEL_RDT_MOUNT_POINT, name, file, NULL);
175-
else
176-
return append_paths (path, err, INTEL_RDT_MOUNT_POINT, name, NULL);
179+
if (is_default_clos (name))
180+
return append_paths (path, err, INTEL_RDT_MOUNT_POINT, file, NULL);
181+
182+
return append_paths (path, err, INTEL_RDT_MOUNT_POINT, name, file, NULL);
177183
}
178184

179185
static int
@@ -282,7 +288,7 @@ resctl_create (const char *name, bool explicit_clos_id, bool *created, const cha
282288
must exist. */
283289
if (explicit_clos_id && l3_cache_schema == NULL && mem_bw_schema == NULL)
284290
{
285-
if (exist)
291+
if (exist || is_default_clos (name))
286292
return 0;
287293

288294
return crun_make_error (err, 0, "the resctl group `%s` does not exist", name);
@@ -292,6 +298,9 @@ resctl_create (const char *name, bool explicit_clos_id, bool *created, const cha
292298
if (exist && (l3_cache_schema != NULL || mem_bw_schema != NULL))
293299
return validate_rdt_configuration (name, l3_cache_schema, mem_bw_schema, err);
294300

301+
if (is_default_clos (name))
302+
return 0;
303+
295304
/* At this point, assume it was created. */
296305
ret = crun_ensure_directory (path, 0755, true, err);
297306
if (UNLIKELY (ret < 0))
@@ -357,6 +366,9 @@ resctl_destroy (const char *name, libcrun_error_t *err)
357366
cleanup_free char *path = NULL;
358367
int ret;
359368

369+
if (is_default_clos (name))
370+
return 0;
371+
360372
ret = get_resctrl_path (&path, NULL, name, err);
361373
if (UNLIKELY (ret < 0))
362374
return ret;

0 commit comments

Comments
 (0)