-
Notifications
You must be signed in to change notification settings - Fork 403
krun: allow configuring the virtiofs device #2076
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -409,7 +409,7 @@ libkrun_exec (void *cookie, libcrun_container_t *container, const char *pathname | |
| runtime_spec_schema_config_schema *def = container->container_def; | ||
| int32_t (*krun_set_log_level) (uint32_t level); | ||
| int (*krun_start_enter) (uint32_t ctx_id); | ||
| int32_t (*krun_set_root) (uint32_t ctx_id, const char *root_path); | ||
| int32_t (*krun_add_virtiofs2) (uint32_t ctx_id, const char *c_tag, const char *c_path, uint64_t shm_size); | ||
| int32_t (*krun_set_root_disk) (uint32_t ctx_id, const char *disk_path); | ||
| int32_t (*krun_set_tee_config_file) (uint32_t ctx_id, const char *file_path); | ||
| int32_t (*krun_set_console_output) (uint32_t ctx_id, const char *c_filepath); | ||
|
|
@@ -471,14 +471,36 @@ libkrun_exec (void *cookie, libcrun_container_t *container, const char *pathname | |
| } | ||
| else | ||
| { | ||
| krun_set_root = dlsym (handle, "krun_set_root"); | ||
| const char *path_virtiofs_tag[] = { "virtiofs_tag", (const char *) 0 }; | ||
| const char *path_virtiofs_shm_size[] = { "virtiofs_shm_size", (const char *) 0 }; | ||
| yajl_val val_virtiofs_tag = NULL; | ||
| yajl_val val_virtiofs_shm_size = NULL; | ||
| const char *virtiofs_tag = NULL; | ||
| // Default to a conservative DAX size of 512MB, just like krun_set_root() does. | ||
| uint64_t virtiofs_shm_size = 512 * 1024 * 1024ULL; | ||
|
|
||
| if (krun_set_root == NULL) | ||
| error (EXIT_FAILURE, 0, "could not find symbol in `libkrun.so`"); | ||
| if (kconf->config_tree != NULL) | ||
| { | ||
| val_virtiofs_tag = yajl_tree_get (kconf->config_tree, path_virtiofs_tag, yajl_t_string); | ||
| if (val_virtiofs_tag != NULL && YAJL_IS_STRING (val_virtiofs_tag)) | ||
| virtiofs_tag = YAJL_GET_STRING (val_virtiofs_tag); | ||
|
|
||
| val_virtiofs_shm_size = yajl_tree_get (kconf->config_tree, path_virtiofs_shm_size, yajl_t_number); | ||
| if (val_virtiofs_shm_size != NULL && YAJL_IS_INTEGER (val_virtiofs_shm_size)) | ||
| virtiofs_shm_size = (uint64_t) YAJL_GET_INTEGER (val_virtiofs_shm_size); | ||
|
Comment on lines
+488
to
+490
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The val_virtiofs_shm_size = yajl_tree_get (kconf->config_tree, path_virtiofs_shm_size, yajl_t_number);
if (val_virtiofs_shm_size != NULL && YAJL_IS_INTEGER (val_virtiofs_shm_size))
{
long long val = YAJL_GET_INTEGER (val_virtiofs_shm_size);
if (UNLIKELY (val < 0))
error (EXIT_FAILURE, 0, "virtiofs_shm_size must be a non-negative integer");
virtiofs_shm_size = (uint64_t) val;
}
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's ignore json stuff for now, I am working on a port to yyjson |
||
| } | ||
|
|
||
| if (virtiofs_tag == NULL) | ||
| virtiofs_tag = "/dev/root"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the default virtiofs tag from virtiofs_tag = "krunroot";
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dear AI overlord. The default virtiofs tag in libkrun has never, ever been
Comment on lines
+493
to
+494
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default tag is changed to |
||
|
|
||
| krun_add_virtiofs2 = dlsym (handle, "krun_add_virtiofs2"); | ||
|
|
||
| if (krun_add_virtiofs2 == NULL) | ||
| error (EXIT_FAILURE, 0, "could not find symbol `krun_add_virtiofs2` in `libkrun.so`"); | ||
|
Comment on lines
+496
to
+499
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code now has a hard dependency on the
Comment on lines
+496
to
+499
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change replaces the use of |
||
|
|
||
| ret = krun_set_root (ctx_id, "/"); | ||
| ret = krun_add_virtiofs2 (ctx_id, virtiofs_tag, "/", virtiofs_shm_size); | ||
| if (UNLIKELY (ret < 0)) | ||
| error (EXIT_FAILURE, -ret, "could not set krun root"); | ||
| error (EXIT_FAILURE, -ret, "could not add virtiofs root with tag `%s`", virtiofs_tag); | ||
| } | ||
|
|
||
| if (kconf->awsnitro) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other
krunconfiguration parameters (such ascpus,ram_mib, andgpu_flags), it would be beneficial to allow configuringvirtiofs_tagandvirtiofs_shm_sizevia OCI annotations (e.g.,krun.virtiofs_tagandkrun.virtiofs_shm_size). This would allow users to override these settings directly from the container engine (like Podman) without needing to provide a.krun_vm.jsonfile inside the container image.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is in a static property of the workload, I don't think it'd make sense overriding it via an annotation. That said, I want to consolidate the whole way in which configuration parameters are parsed to make it more consistent. Possibly after the yyjson transition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, we can do that later