Skip to content

Add krun_set_rootfs_kernel_args API #346

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ggoodman
Copy link
Contributor

@ggoodman ggoodman commented Jun 5, 2025

This commit introduces a new API function krun_set_rootfs_kernel_args that allows
callers to override kernel arguments related to the root filesystem, replacing the
default "rootfstype=virtiofs rw" parameters in the kernel command line.

New features:

  • Added RootfsConfig struct with builder pattern for type-safe configuration
  • Supports customizing root device, filesystem type, mount flags, and read-only mode
  • Falls back to sensible defaults: /dev/vda1, virtiofs, rw when parameters are NULL
  • Integrates with existing kernel command line construction in get_effective_kernel_cmdline()
  • Follows established patterns used by other config types like BlockDeviceConfig

API signature:

int32_t krun_set_rootfs_kernel_args(uint32_t ctx_id,
                                    const char *device,
                                    const char *fs_type,
                                    const char *mount_flags,
                                    bool read_only);

Fixes #343.

@ggoodman
Copy link
Contributor Author

ggoodman commented Jun 5, 2025

I haven't done manual testing on this. Not ready for merge. Will circle back.

@jakecorrenti
Copy link
Member

Thanks for the contribution @ggoodman! If it's not ready for merge, could you make this a Draft PR and mark it as "Ready for Review" when it's done?

This commit introduces a new API function `krun_set_rootfs_kernel_args` that allows
callers to override kernel arguments related to the root filesystem, replacing the
default "rootfstype=virtiofs rw" parameters in the kernel command line.

New features:
- Added RootfsConfig struct with builder pattern for type-safe configuration
- Supports customizing root device, filesystem type, mount flags, and read-only mode
- Falls back to sensible defaults: /dev/vda1, virtiofs, rw when parameters are NULL
- Integrates with existing kernel command line construction in get_effective_kernel_cmdline()
- Follows established patterns used by other config types like BlockDeviceConfig

API signature:
```c
int32_t krun_set_rootfs_kernel_args(uint32_t ctx_id,
                                    const char *device,
                                    const char *fs_type,
                                    const char *mount_flags,
                                    bool read_only);
```

Signed-off-by: Geoffrey Goodman <[email protected]>
@ggoodman ggoodman force-pushed the custom-kernel-cmdline branch from 3e46947 to d1c5524 Compare June 5, 2025 20:25
@ggoodman
Copy link
Contributor Author

ggoodman commented Jun 5, 2025

@jakecorrenti I'm staring at GitHub and can't find the UI to switch it to draft.

@jakecorrenti
Copy link
Member

@jakecorrenti I'm staring at GitHub and can't find the UI to switch it to draft.

Looks like I was able to do it for you. It should typically be right under the "Reviewers" section on the right

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.

Read-only root filesystem / root filesystem from image
2 participants