Skip to content

Commit

Permalink
Merge pull request #283 from elezar/allow-socket-opt-out
Browse files Browse the repository at this point in the history
Add CLI options to opt-out of socket injection
  • Loading branch information
elezar authored Sep 17, 2024
2 parents d7dc76b + 13f2046 commit 6b8b8e4
Show file tree
Hide file tree
Showing 3 changed files with 23 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
12 changes: 11 additions & 1 deletion src/cli/configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ 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},
{"no-fabricmanager", 0x87, NULL, 0, "Don't include the NVIDIA fabricmanager socket", -1},
{0},
},
configure_parser,
Expand Down Expand Up @@ -150,6 +152,14 @@ 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-persistenced", " ") < 0)
goto fatal;
break;
case 0x87:
if (str_join(&err, &ctx->driver_opts, "no-fabricmanager", " ") < 0)
goto fatal;
break;
case ARGP_KEY_ARG:
if (state->arg_num > 0)
argp_usage(state);
Expand Down Expand Up @@ -290,7 +300,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
12 changes: 11 additions & 1 deletion src/cli/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ 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},
{"no-fabricmanager", 0x85, NULL, 0, "Don't include the NVIDIA fabricmanager socket", -1},
{0},
},
list_parser,
Expand Down Expand Up @@ -70,6 +72,14 @@ 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-persistenced", " ") < 0)
goto fatal;
break;
case 0x85:
if (str_join(&err, &ctx->driver_opts, "no-fabricmanager", " ") < 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 +156,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 6b8b8e4

Please sign in to comment.