krun: Parse libkrun flavor indicated in KRUN_VM_FILE#1754
krun: Parse libkrun flavor indicated in KRUN_VM_FILE#1754giuseppe merged 3 commits intocontainers:mainfrom
KRUN_VM_FILE#1754Conversation
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.
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
| cpu_set_t set; | ||
| libcrun_error_t err; | ||
| bool configured = false; | ||
| yajl_val config_tree = NULL; |
There was a problem hiding this comment.
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.
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 <tfanelli@redhat.com>
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 <tfanelli@redhat.com>
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 <tfanelli@redhat.com>
5ca3fa7 to
379524f
Compare
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_FILEearly to detect the requested libkrun flavor and select the appropriate handle before making further libkrun calls.Enhancements:
libkrun_read_vm_configto separate JSON parsing of the VM configuration file.libkrun_configure_flavorto switch between standard and SEV libkrun based on the config file or presence ofKRUN_SEV_FILE.libkrun_execto invoke the new config parsing and flavor-selection steps prior to VM configuration.