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

lib/vfscore: Implement individual volume automounting #979

Closed
wants to merge 2 commits into from

Conversation

mogasergiu
Copy link
Member

@mogasergiu mogasergiu commented Jul 13, 2023

Provide a command-line argument vfs.fstab that is meant to contain a list of whitespace separated strings with the following format:

	vfs.fstab=[
		"<src_dev>:<mntpoint>:<fsdriver>[:<flags>:<opts>]"
		"<src_dev>:<mntpoint>:<fsdriver>[:<flags>:<opts>]"
		...
	]

The core will parse the provided strings as volume information and attempt to mount them accordingly.

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.uk on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): [e.g. x86_64 or N/A]
  • Platform(s): [e.g. kvm, xen or N/A]
  • Application(s): [e.g. app-python3 or N/A]

Additional configuration

Description of changes

@mogasergiu mogasergiu requested a review from a team as a code owner July 13, 2023 06:57
lib/vfscore/Makefile.uk Outdated Show resolved Hide resolved
lib/vfscore/volumes.c Outdated Show resolved Hide resolved
lib/vfscore/volumes.c Outdated Show resolved Hide resolved
@unikraft-bot unikraft-bot added area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ lib/vfscore VFS Core Interface labels Jul 14, 2023
@razvand razvand added this to the v0.14.0 (Prometheus) milestone Jul 14, 2023
Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work fine @mogasergiu, I'll add the tag after you resolve Simon's comments.

Copy link
Contributor

@RaduNichita RaduNichita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @mogasergiu 💪 . I left some minor nitpicks.
I will approve after that!

lib/vfscore/volumes.c Outdated Show resolved Hide resolved
lib/vfscore/volumes.c Outdated Show resolved Hide resolved
@mogasergiu mogasergiu force-pushed the smoga/multi-volume branch 3 times, most recently from 0b15cc1 to 3d1e652 Compare July 14, 2023 13:33
Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I retested this and everything works fine, thanks!
Reviewed-by: Stefan Jumarea stefanjumarea02@gmail.com

@RaduNichita RaduNichita self-requested a review July 14, 2023 15:30
Copy link
Contributor

@RaduNichita RaduNichita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good now. Thanks, @mogasergiu 🥇

Reviewed-by: Radu Nichita radunichita99@gmail.com

lib/vfscore/automount.c Outdated Show resolved Hide resolved
lib/vfscore/Config.uk Outdated Show resolved Hide resolved
nderjung added a commit to nderjung/kraftkit that referenced this pull request Jul 15, 2023
In preparation for individual volume auto-mounting to Unikraft[0],
introduce a helper library to serialize command-line arguments
representing the in-kernel mount path for a device and its options.

[0]: unikraft/unikraft#979

Signed-off-by: Alexander Jung <alex@unikraft.io>
nderjung added a commit to nderjung/kraftkit that referenced this pull request Jul 15, 2023
In preparation for individual volume auto-mounting to Unikraft[0],
introduce a helper library to serialize command-line arguments
representing the in-kernel mount path for a device and its options.

[0]: unikraft/unikraft#979

Signed-off-by: Alexander Jung <alex@unikraft.io>
nderjung added a commit to nderjung/kraftkit that referenced this pull request Jul 17, 2023
In preparation for individual volume auto-mounting to Unikraft[0],
introduce a helper library to serialize command-line arguments
representing the in-kernel mount path for a device and its options.

[0]: unikraft/unikraft#979

Signed-off-by: Alexander Jung <alex@unikraft.io>
@mogasergiu mogasergiu force-pushed the smoga/multi-volume branch 5 times, most recently from 3b76779 to 27e582a Compare July 17, 2023 16:20
nderjung added a commit to nderjung/kraftkit that referenced this pull request Jul 18, 2023
In preparation for individual volume auto-mounting to Unikraft[0],
introduce a helper library to serialize command-line arguments
representing the in-kernel mount path for a device and its options.

[0]: unikraft/unikraft#979

Signed-off-by: Alexander Jung <alex@unikraft.io>
lib/vfscore/automount.c Outdated Show resolved Hide resolved
lib/vfscore/automount.c Outdated Show resolved Hide resolved
lib/vfscore/automount.c Outdated Show resolved Hide resolved
@unikraft-bot
Copy link
Member

Checkpatch passed

Beep boop! I ran Unikraft's checkpatch.pl support script on your pull request and it all looks good!

SHA commit checkpatch
f44ee4b lib/vfscore: Implement individual volume automounting
3a616bc lib/vfscore: Discontinue `vfs.{rootfs, rootdef, rootops, rootflags}`

@razvand razvand requested a review from skuenzer August 9, 2023 06:24
@skuenzer
Copy link
Member

skuenzer commented Aug 9, 2023

I just noticed, that in your second commit that removes the vfs.roofs parameter, etc. you also need to update Config.uk:

 config LIBVFSCORE_AUTOMOUNT_ROOTFS
 bool "Automatically mount a root filesysytem (/)"
 default n
-imply LIBUKLIBPARAM
 help
-	Automatically mounts '/' during boot. If `libuklibparam` is
-	compiled in, the default root filesystem and mount options can
-	be changed with the following library parameters:
-	'vfs.rootfs', 'vfs.rootdev', 'vfs.rootflags', and 'vfs.rootopts'
+	Automatically mounts '/' during boot. The parameters are
+	compiled-in and cannot be changed at runtime.

This is a minor comment: Instead of keeping the parameters set from config options from line 76 to 98, you could directly fill the struct in line 226 with those.

I aslo jsut notice that you are using #ifdef CONFIG_ABC although you can use #if CONFIG_ABC which is slightly more powerful because it catches the case when you manually do #define CONFIG_ABC 0. If you use #if on an undefined pre-processor macro, it will return false.

@nderjung nderjung added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 9, 2023
@mogasergiu
Copy link
Member Author

I aslo jsut notice that you are using #ifdef CONFIG_ABC although you can use #if CONFIG_ABC which is slightly more powerful because it catches the case when you manually do #define CONFIG_ABC 0. If you use #if on an undefined pre-processor macro, it will return false.

Is this just general advice? The problem is if you do #if on a string you are going to be met with a preprocessor error. So I think I will stick to #ifdef's in the CONFIG_LIBVFSCORE_ROOT* macro's 🤔.

Provide a command-line argument `vfs.fstab` that is meant to
contain a list of whitespace separated strings with the following
format:
```
	vfs.fstab=[
		"<src_dev>:<mntpoint>:<fsdriver>[:<flags>:<opts>]"
		"<src_dev>:<mntpoint>:<fsdriver>[:<flags>:<opts>]"
		...
	]
```

The core will parse the provided strings as volume information and
attempt to mount them accordingly, if `CONFIG_LIBVFSCORE_FSTAB` is
provided.

Furthermore, add a configurable `CONFIG_LIBVFSCORE_FSTAB_SIZE`
option that will be used as the maximum amount of automatically mounted
volumes, excluding the `rootfs` and modularize `initrd` extraction and
mounting functionality into a standalone function to be used by both
`fstab` and implicit `rootfs`.

As a last change, since the file's functionality drastically changed,
rename `rootfs.c` to `automount.c`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Now that we can dynamically mount any kind of volume through a more
generic format through the commandline, there is an unnecessary
overlap between `vfs.{rootfs, rootdef, rootops,rootflags}` and
defining `rootfs` related arguments through `vfs.fstab` volumes.

Therefore, deprecate `vfs.{rootfs, rootdef, rootops,rootflags}` in
favor of `vfs.fstab`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Copy link
Member

@skuenzer skuenzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the work!

Reviewed-by: Simon Kuenzer simon@unikraft.io
Approved-by: Simon Kuenzer simon@unikraft.io

unikraft-bot pushed a commit that referenced this pull request Aug 9, 2023
Now that we can dynamically mount any kind of volume through a more
generic format through the commandline, there is an unnecessary
overlap between `vfs.{rootfs, rootdef, rootops,rootflags}` and
defining `rootfs` related arguments through `vfs.fstab` volumes.

Therefore, deprecate `vfs.{rootfs, rootdef, rootops,rootflags}` in
favor of `vfs.fstab`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #979
@unikraft-bot unikraft-bot added the ci/merged Merged by CI label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary ci/merged Merged by CI lang/c Issues or PRs to do with C/C++ lib/vfscore VFS Core Interface release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
Status: Done!
Development

Successfully merging this pull request may close these issues.

None yet

8 participants