-
Notifications
You must be signed in to change notification settings - Fork 79
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
init: support other locations for krun_config #220
Conversation
When using "krun_set_exec", the arguments and environment variables are passed to the guest using the kernel command line. In addition to being limited in length, this is also only compatible with ASCII strings. libkrun is also capable or reading both arguments and environment variables from a JSON config file, which doesn't suffer from any of those limitations, so switch to using this approach instead. Depends on containers/libkrun#220 Signed-off-by: Sergio Lopez <[email protected]>
} else { | ||
fd = open(CONFIG_FILE_PATH, O_RDONLY); | ||
} | ||
|
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.
A bit cleaner, maybe:
config_file = getenv("KRUN_CONFIG");
if (!config_file) {
config_file = CONFIG_FILE_PATH;
}
fd = open(config_file, O_RDONLY);
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.
Or if you don't care about MSVC, open(getenv("KRUN_CONFIG") ?: CONFIG_FILE_PATH, O_RDONLY)
is a one-liner with the elvis operator 🕺
When using "krun_set_exec", the arguments and environment variables are passed to the guest using the kernel command line. In addition to being limited in length, this is also only compatible with ASCII strings. libkrun is also capable or reading both arguments and environment variables from a JSON config file, which doesn't suffer from any of those limitations, so switch to using this approach instead. Depends on containers/libkrun#220 Signed-off-by: Sergio Lopez <[email protected]>
When using "krun_set_exec", the arguments and environment variables are passed to the guest using the kernel command line. In addition to being limited in length, this is also only compatible with ASCII strings. libkrun is also capable or reading both arguments and environment variables from a JSON config file, which doesn't suffer from any of those limitations, so switch to using this approach instead. Depends on containers/libkrun#220 Signed-off-by: Sergio Lopez <[email protected]>
So far, the configuration was always expected to be in "/.krun_config.json". To support it to be located elsewhere, use the path stored in KRUN_CONFIG, falling back to the original location if not found there. Signed-off-by: Sergio Lopez <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]>
66f5bc1
to
33a1f3d
Compare
When using "krun_set_exec", the arguments and environment variables are passed to the guest using the kernel command line. In addition to being limited in length, this is also only compatible with ASCII strings. libkrun is also capable or reading both arguments and environment variables from a JSON config file, which doesn't suffer from any of those limitations, so switch to using this approach instead. Depends on containers/libkrun#220 Signed-off-by: Sergio Lopez <[email protected]>
When using "krun_set_exec", the arguments and environment variables are passed to the guest using the kernel command line. In addition to being limited in length, this is also only compatible with ASCII strings. libkrun is also capable or reading both arguments and environment variables from a JSON config file, which doesn't suffer from any of those limitations, so switch to using this approach instead. Depends on containers/libkrun#220 Signed-off-by: Sergio Lopez <[email protected]>
So far, the configuration was always expected to be in "/.krun_config.json". To support it to be located elsewhere, use the path stored in KRUN_CONFIG, falling back to the original location if not found there.