Skip to content

Commit

Permalink
Add no-persistenced option
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
elezar committed Sep 16, 2024
1 parent 4c2494f commit ed08066
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/cli/configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/cli/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ed08066

Please sign in to comment.