From deeef6475c946529efe8f0860430593fdadac05e Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 27 Jun 2023 10:55:18 +0200 Subject: [PATCH] features: add wasm annotation Signed-off-by: Giuseppe Scrivano --- src/libcrun/container.c | 5 ++++- src/libcrun/container.h | 1 + src/oci_features.c | 2 ++ tests/test_oci_features.py | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libcrun/container.c b/src/libcrun/container.c index 79686445e0..b9f2afd010 100644 --- a/src/libcrun/container.c +++ b/src/libcrun/container.c @@ -3855,7 +3855,7 @@ retrieve_mount_options (struct features_info_s **info) } int -libcrun_container_get_features (libcrun_context_t *context arg_unused, struct features_info_s **info, libcrun_error_t *err arg_unused) +libcrun_container_get_features (libcrun_context_t *context, struct features_info_s **info, libcrun_error_t *err arg_unused) { // Allocate memory for the features_info_s structure size_t num_namspaces = sizeof (namespaces) / sizeof (namespaces[0]); @@ -3920,6 +3920,9 @@ libcrun_container_get_features (libcrun_context_t *context arg_unused, struct fe } #endif + if (context->handler_manager && handler_by_name (context->handler_manager, "wasm")) + (*info)->annotations.run_oci_crun_wasm = true; + #if HAVE_CRIU (*info)->annotations.run_oci_crun_checkpoint_enabled = true; #endif diff --git a/src/libcrun/container.h b/src/libcrun/container.h index a45b2a4062..2511d0a0f0 100644 --- a/src/libcrun/container.h +++ b/src/libcrun/container.h @@ -137,6 +137,7 @@ struct annotations_info_s bool run_oci_crun_checkpoint_enabled; char *run_oci_crun_commit; char *run_oci_crun_version; + bool run_oci_crun_wasm; }; struct features_info_s diff --git a/src/oci_features.c b/src/oci_features.c index 98bd430bac..1283932e94 100644 --- a/src/oci_features.c +++ b/src/oci_features.c @@ -183,6 +183,8 @@ crun_features_add_annotations_info (yajl_gen json_gen, const struct annotations_ add_string_to_json (json_gen, "run.oci.crun.commit", annotation->run_oci_crun_commit); add_string_to_json (json_gen, "run.oci.crun.version", annotation->run_oci_crun_version); + add_bool_to_json (json_gen, "run.oci.crun.wasm", annotation->run_oci_crun_wasm); + yajl_gen_map_close (json_gen); } diff --git a/tests/test_oci_features.py b/tests/test_oci_features.py index 9664dc8eb1..de23740d54 100644 --- a/tests/test_oci_features.py +++ b/tests/test_oci_features.py @@ -193,6 +193,11 @@ def test_crun_features(): sys.stderr.write("wrong value for run.oci.crun.commit, expected=%s got=%s\n" % (get_crun_commit(), annotations.get("run.oci.crun.commit"))) return -1 + if ('WASM' in get_crun_feature_string() + and annotations.get("run.oci.crun.wasm") is not True): + sys.stderr.write("wrong value for run.oci.crun.wasm\n") + return -1 + if 'CRIU' in get_crun_feature_string(): if annotations.get("org.opencontainers.runc.checkpoint.enabled") is not True: sys.stderr.write("wrong value for org.opencontainers.runc.checkpoint.enabled\n")