Skip to content

Conversation

@slp
Copy link
Collaborator

@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 <slp@redhat.com>
} 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 <slp@redhat.com>
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 <slp@redhat.com>
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 <slp@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
@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
@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 <slp@redhat.com>
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 <slp@redhat.com>
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