-
Notifications
You must be signed in to change notification settings - Fork 349
krun: Parse libkrun flavor indicated in KRUN_VM_FILE
#1754
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
Conversation
Reviewer's GuideThis PR refactors VM configuration handling in krun to support multiple libkrun flavors by splitting VM config parsing from flavor selection and wiring the new steps into the execution path. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @tylerfanelli - I've reviewed your changes - here's some feedback:
- Ensure that the parsed YAJL tree (config_tree) is freed (e.g., via yajl_tree_free) after use to avoid memory leaks.
- Avoid calling exit() in libkrun_configure_flavor—return an error code instead to keep error handling consistent and non-terminating within library functions.
- Extract the literal "sev" into a named constant (or enum) to avoid magic strings and make adding future flavors easier.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
57ee8cc
to
ad3fbc9
Compare
Ephemeral COPR build failed. @containers/packit-build please check. |
e7876e8
to
0a4c757
Compare
@@ -206,23 +262,18 @@ libkrun_exec (void *cookie, libcrun_container_t *container, const char *pathname | |||
cpu_set_t set; | |||
libcrun_error_t err; | |||
bool configured = false; | |||
yajl_val config_tree = NULL; |
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.
when do we clean it up (yajl_tree_free (...)
)?
We exit early on errors so we don't really care in this case, but could we release it before krun_start_enter
?
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.
Thanks for pointing that out, I never did free config_tree
. I've modified 13fcca9 to free config_tree
before krun_start_enter
.
To determine the libkrun handle to use, the container may embed a field "flavor" in the KRUN_VM_FILE. To prepare for this, pre-parse the krun VM config when exec'ing. Signed-off-by: Tyler Fanelli <[email protected]>
The krun VM config was parsed before the VM was configured. Use the pre-parsed config tree already available instead of parsing it once more. Signed-off-by: Tyler Fanelli <[email protected]>
3f716cc
to
5ca3fa7
Compare
To support other krun flavors in the future, parse which flavor (and by extension, which handle) should be used before making any libkrun API calls past libkrun_create_ctx. The correct handle to be used can be determined before any other subsequent API calls. Signed-off-by: Tyler Fanelli <[email protected]>
5ca3fa7
to
379524f
Compare
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.
LGTM
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.
LGTM
To support other libkrun flavors in the future, parse which flavor (and by extension, which handle) should be used before making any libkrun API calls past
libkrun_create_ctx
. The correct handle to be used can be determined before any other subsequent API calls.cc @slp
Summary by Sourcery
Parse the
KRUN_VM_FILE
early to detect the requested libkrun flavor and select the appropriate handle before making further libkrun calls.Enhancements:
libkrun_read_vm_config
to separate JSON parsing of the VM configuration file.libkrun_configure_flavor
to switch between standard and SEV libkrun based on the config file or presence ofKRUN_SEV_FILE
.libkrun_exec
to invoke the new config parsing and flavor-selection steps prior to VM configuration.