vmspawn-varlink: treat empty event subscription filter as catch-all

A client supplying "filter": [] previously matched no events at all,
because filter is checked with strv_contains() — an unintuitive corner
case. Treat an empty filter strv identically to a NULL filter (deliver
all events) by freeing the empty strv before it lands in the
subscription map. Brings the API closer to least-surprise.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Christian Brauner
2026-04-24 14:39:25 +02:00
parent 5b3a9f20a6
commit 9ed1af2bd1
+4
View File
@@ -159,6 +159,10 @@ static int vl_method_subscribe_events(sd_varlink *link, sd_json_variant *paramet
if (r != 0)
return r;
/* Treat [] identically to null: deliver all events. */
if (strv_isempty(filter))
filter = strv_free(filter);
sd_varlink_ref(link);
r = hashmap_ensure_put(&ctx->subscribed, &varlink_subscriber_hash_ops, link, filter);