Skip to content

Commit 1fccb59

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 0f41e73 commit 1fccb59

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;
@@ -375,13 +377,19 @@ libkrun_exec (void *cookie, libcrun_container_t *container, const char *pathname
375377
{
376378
// need krun_set_exec and krun_set_console_output.
377379
krun_set_console_output = dlsym (handle, "krun_set_console_output");
378-
if (krun_set_console_output == NULL)
379-
error (EXIT_FAILURE, 0, "could not find symbol in `libkrun.so`");
380+
krun_set_exec = dlsym (handle, "krun_set_exec");
381+
if (krun_set_console_output == NULL || krun_set_exec == NULL)
382+
error (EXIT_FAILURE, 0, "could not find symbol in `libkrun-nitro.so`");
380383

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

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

0 commit comments

Comments
 (0)