From f17f7cc35e2147729ed3fef2e5641eb448ff6240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 18 Aug 2026 01:29:34 +0200 Subject: [PATCH] imdsd: convert to VERB_COMMAND and add --introspect-cli The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. --- src/imds/imdsd.c | 47 +++++-------------- .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/imds/imdsd.c b/src/imds/imdsd.c index aecc2feac7..4324864aa5 100644 --- a/src/imds/imdsd.c +++ b/src/imds/imdsd.c @@ -29,10 +29,8 @@ #include "fd-util.h" #include "fileio.h" #include "format-ifname.h" -#include "format-table.h" #include "hash-funcs.h" #include "hashmap.h" -#include "help-util.h" #include "imds-util.h" #include "in-addr-util.h" #include "io-util.h" @@ -41,7 +39,6 @@ #include "log.h" #include "main-func.h" #include "netlink-util.h" -#include "options.h" #include "parse-argument.h" #include "parse-util.h" #include "path-util.h" @@ -54,6 +51,7 @@ #include "utf8.h" #include "varlink-io.systemd.InstanceMetadata.h" #include "varlink-util.h" +#include "verbs.h" #include "web-util.h" #include "xattr-util.h" @@ -141,6 +139,13 @@ STATIC_DESTRUCTOR_REGISTER(arg_token_header_name, freep); STATIC_DESTRUCTOR_REGISTER(arg_extra_header, strv_freep); STATIC_DESTRUCTOR_REGISTER(arg_well_known_key, imds_well_known_key_free); +COMMAND( + "systemd-imdsd\0", + "Low-level IMDS data acquisition.", + .argspec = "KEY\0", + .man_pages = "systemd-imdsd@.service.8\0", +); + typedef struct Context Context; typedef struct ChildData { @@ -2192,37 +2197,6 @@ static int vl_server(void) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL, *endpoint_options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - r = option_parser_get_help_table_group("Manual Endpoint Configuration", &endpoint_options); - if (r < 0) - return r; - - (void) table_sync_column_widths(0, options, endpoint_options); - - help_cmdline("[OPTIONS...] KEY"); - help_abstract("Low-level IMDS data acquisition."); - - help_section("Options"); - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_section("Manual Endpoint Configuration"); - r = table_print_or_warn(endpoint_options); - if (r < 0) - return r; - - help_man_page_reference("systemd-imdsd@.service", "8"); - return 0; -} - static bool http_header_name_valid(const char *a) { return a && ascii_is_valid(a) && !string_has_cc(a, /* ok= */ NULL) && !strchr(a, ':'); } @@ -2239,7 +2213,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-imdsd"); OPTION_COMMON_VERSION: return version(); @@ -2484,6 +2458,9 @@ static int parse_argv(int argc, char *argv[]) { return r; break; } + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (arg_vendor || arg_token_url || arg_refresh_header_name || arg_data_url || arg_data_url_suffix || arg_token_header_name || arg_extra_header) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index 14c8a4b5f9..c8084a43b0 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -49,6 +49,7 @@ INTROSPECTABLE=( systemd-hwdb systemd-id128 systemd-imds + systemd-imdsd systemd-inhibit systemd-journal-gatewayd systemd-journal-remote