Skip to content

Commit df77120

Browse files
committed
krun: Set exec args when running nitro variant
The libkrun nitro variant expects the execution arguments to be provided for forwarding to an enclave. If the nitro variant is configured, set the execution arguments for the nitro enclave. Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
1 parent b78e986 commit df77120

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/libcrun/handlers/krun.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ libkrun_exec (void *cookie, libcrun_container_t *container, const char *pathname
312312
int32_t (*krun_set_root_disk) (uint32_t ctx_id, const char *disk_path);
313313
int32_t (*krun_set_tee_config_file) (uint32_t ctx_id, const char *file_path);
314314
int32_t (*krun_set_console_output) (uint32_t ctx_id, const char *c_filepath);
315+
int32_t (*krun_set_exec) (uint32_t ctx_id, const char *exec_path,
316+
const char *const argv[], const char *const envp[]);
315317
struct krun_config *kconf = (struct krun_config *) cookie;
316318
void *handle;
317319
uint32_t num_vcpus, ram_mib;
@@ -374,13 +376,19 @@ libkrun_exec (void *cookie, libcrun_container_t *container, const char *pathname
374376
if (kconf->nitro)
375377
{
376378
krun_set_console_output = dlsym (handle, "krun_set_console_output");
377-
if (krun_set_console_output == NULL)
378-
error (EXIT_FAILURE, 0, "could not find symbol in `libkrun.so`");
379+
krun_set_exec = dlsym (handle, "krun_set_exec");
380+
if (krun_set_console_output == NULL || krun_set_exec == NULL)
381+
error (EXIT_FAILURE, 0, "could not find symbol in `libkrun-nitro.so`");
379382

380383
// Redirect all enclave output (read from vsock) to stdout.
381384
ret = krun_set_console_output (ctx_id, "/dev/stdout");
382385
if (UNLIKELY (ret < 0))
383386
error (EXIT_FAILURE, -ret, "could not redirect enclave output to stdout");
387+
388+
ret = krun_set_exec (ctx_id, pathname, (const char *const *) argv,
389+
(const char *const *) def->process->env);
390+
if (UNLIKELY (ret < 0))
391+
error (EXIT_FAILURE, -ret, "could not set enclave execution arguments");
384392
}
385393

386394
ret = libkrun_configure_vm (ctx_id, handle, &configured, &config_tree, &err);

0 commit comments

Comments
 (0)