Skip to content
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

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

slp
Copy link
Contributor

@slp slp commented Sep 26, 2024

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.

slp added a commit to slp/krun that referenced this pull request Sep 26, 2024
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);
}

Copy link
Contributor

@alyssarosenzweig alyssarosenzweig Sep 26, 2024

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);

Copy link
Contributor

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 🕺

slp added a commit to slp/krun that referenced this pull request Sep 26, 2024
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]>
slp added a commit to slp/krun that referenced this pull request Sep 26, 2024
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]>
@slp slp force-pushed the flexible_krun_config branch from 66f5bc1 to 33a1f3d Compare September 27, 2024 09:37
@slp slp merged commit c7213f4 into containers:main Sep 27, 2024
5 checks passed
@slp slp deleted the flexible_krun_config branch September 27, 2024 09:52
slp added a commit to slp/krun that referenced this pull request Sep 27, 2024
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]>
alyssarosenzweig pushed a commit to AsahiLinux/muvm that referenced this pull request Sep 27, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants