Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI options to opt-out of socket injection #283

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines +155 to +162
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

driver_opts needs to be freed since it might get allocated as part of this str_join() call

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;
Comment on lines +75 to +82
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

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