]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn-oci: match the spec-correct "swappiness" memory field key
authorhanjinpeng <hanjinpeng@kylinos.cn>
Wed, 8 Jul 2026 07:07:01 +0000 (03:07 -0400)
committerLennart Poettering <lennart@poettering.net>
Fri, 10 Jul 2026 08:34:10 +0000 (10:34 +0200)
The OCI runtime specification names the memory swappiness knob
"swappiness" (memory.swappiness), but the dispatch table
in oci_cgroup_memory() registered it as "swapiness".

Since sd_json_dispatch_full() matches object keys by exact string
comparison, a spec-correct config carrying "swappiness" never hit the
intended oci_unsupported() handler and was instead routed to the
bad-field callback oci_unexpected(), which returns -EINVAL and thus
fails the whole memory cgroup section.

Register the correct key so that real OCI bundles parse, keep the
misspelt one around for compatibility, mark both as such, and drop the
now-resolved reminder from the file header TODO list.

src/nspawn/nspawn-oci.c

index 0f206bd7067c6d85abd71d1f871b69bf8de8bba6..941732c706b8ba29eb9ae92d5fc4c70d92f652b8 100644 (file)
@@ -56,7 +56,6 @@
  * /bin/mount regarding NFS and FUSE required?
  * what does terminal=false mean?
  * sysctl inside or outside? allow-listing?
- * swapiness typo -> swappiness
  *
  * Unsupported:
  *
@@ -1124,7 +1123,8 @@ static int oci_cgroup_memory(const char *name, sd_json_variant *v, sd_json_dispa
                 { "swap",             SD_JSON_VARIANT_NUMBER,  oci_cgroup_memory_limit, offsetof(struct memory_data, swap),        0                  },
                 { "kernel",           SD_JSON_VARIANT_NUMBER,  oci_unsupported,         0,                                         SD_JSON_PERMISSIVE },
                 { "kernelTCP",        SD_JSON_VARIANT_NUMBER,  oci_unsupported,         0,                                         SD_JSON_PERMISSIVE },
-                { "swapiness",        SD_JSON_VARIANT_NUMBER,  oci_unsupported,         0,                                         SD_JSON_PERMISSIVE },
+                { "swapiness",        SD_JSON_VARIANT_NUMBER,  oci_unsupported,         0,                                         SD_JSON_PERMISSIVE }, /* compat name, misspelt */
+                { "swappiness",       SD_JSON_VARIANT_NUMBER,  oci_unsupported,         0,                                         SD_JSON_PERMISSIVE }, /* spec-correct name */
                 { "disableOOMKiller", SD_JSON_VARIANT_BOOLEAN, oci_unsupported,         0,                                         SD_JSON_PERMISSIVE },
                 {}
         };