From ed08066f4ae7e1858259599253acfe7e71860cc9 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 16 Sep 2024 10:44:44 +0200 Subject: [PATCH] Add no-persistenced option This change adds a no-persistenced option to the configure and list commands to allow users to opt-out of detecting and injecting the nvidia-persistenced socket into a container. Signed-off-by: Evan Lezar --- src/cli/cli.h | 1 + src/cli/configure.c | 7 ++++++- src/cli/list.c | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cli/cli.h b/src/cli/cli.h index f9c35f10..1be42bb3 100644 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -55,6 +55,7 @@ struct context { char *mig_config; char *mig_monitor; char *imex_channels; + char *driver_opts; }; bool matches_pci_format(const char *gpu, char *buf, size_t bufsize); diff --git a/src/cli/configure.c b/src/cli/configure.c index 8890b4ea..52fee5a4 100644 --- a/src/cli/configure.c +++ b/src/cli/configure.c @@ -33,6 +33,7 @@ const struct argp configure_usage = { {"imex-channel", 0x83, "CHANNEL", 0, "IMEX channel ID(s) to inject", -1}, {"no-cgroups", 0x84, NULL, 0, "Don't use cgroup enforcement", -1}, {"no-devbind", 0x85, NULL, 0, "Don't bind mount devices", -1}, + {"no-persistenced", 0x86, NULL, 0, "Don't include the NVIDIA persistenced socket", -1}, {0}, }, configure_parser, @@ -150,6 +151,10 @@ configure_parser(int key, char *arg, struct argp_state *state) if (str_join(&err, &ctx->container_flags, "no-devbind", " ") < 0) goto fatal; break; + case 0x86: + if (str_join(&err, &ctx->driver_opts, "no-persistencd", " ") < 0) + goto fatal; + break case ARGP_KEY_ARG: if (state->arg_num > 0) argp_usage(state); @@ -290,7 +295,7 @@ configure_command(const struct context *ctx) warnx("permission error: %s", err.msg); goto fail; } - if ((drv = libnvc.driver_info_new(nvc, NULL)) == NULL || + if ((drv = libnvc.driver_info_new(nvc, ctx->driver_opts)) == NULL || (dev = libnvc.device_info_new(nvc, NULL)) == NULL) { warnx("detection error: %s", libnvc.error(nvc)); goto fail; diff --git a/src/cli/list.c b/src/cli/list.c index 8574a0c9..b2644ff6 100644 --- a/src/cli/list.c +++ b/src/cli/list.c @@ -22,6 +22,7 @@ const struct argp list_usage = { {"mig-config", 0x81, "ID", 0, "MIG devices to list config capabilities files for", -1}, {"mig-monitor", 0x82, "ID", 0, "MIG devices to list monitor capabilities files for", -1}, {"imex-channel", 0x83, "CHANNEL", 0, "IMEX channel ID(s) to inject", -1}, + {"no-persistenced", 0x84, NULL, 0, "Don't include the NVIDIA persistenced socket", -1}, {0}, }, list_parser, @@ -70,6 +71,10 @@ list_parser(int key, char *arg, struct argp_state *state) if (str_join(&err, &ctx->imex_channels, arg, ",") < 0) goto fatal; break; + case 0x84: + if (str_join(&err, &ctx->driver_opts, "no-persistencd", " ") < 0) + goto fatal; + break case ARGP_KEY_END: if (state->argc == 1 || (state->argc == 2 && ctx->imex_channels != NULL)) { if ((ctx->devices = xstrdup(&err, "all")) == NULL) @@ -146,7 +151,7 @@ list_command(const struct context *ctx) warnx("permission error: %s", err.msg); goto fail; } - if ((drv = libnvc.driver_info_new(nvc, NULL)) == NULL || + if ((drv = libnvc.driver_info_new(nvc, ctx->driver_opts)) == NULL || (dev = libnvc.device_info_new(nvc, NULL)) == NULL) { warnx("detection error: %s", libnvc.error(nvc)); goto fail;