-
Notifications
You must be signed in to change notification settings - Fork 7.6k
virtio: add virtiofs #86768
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
base: main
Are you sure you want to change the base?
virtio: add virtiofs #86768
Conversation
ba271da
to
d24c129
Compare
Looks very good so far. Is it possible to separate the virtiofs and fuse contributions into separate commits? I think they can be used independently - e.g. network based FUSE. I was initially searching for the separation between host and device roles under Maybe slightly different naming would make it easier to differentiate which is the host driver and which is the device between e.g. with virtiofs.c and virtiofs_zvfs.c, maybe virtiofs_host.c and virtiofs_device.c. Naming things is hard though, so it's maybe good to discuss. Additionally, different subsystems have different naming conventions for things, but it would be nice to have some cross-subsystem naming. Given that it might be hard to identify all of the different virtio drivers that will eventually be scattered throughout Zephyr, and which might do the host side vs device side, I would also like to see a new section in the documentation.
Happy to help move this along any way I can. |
05ddf1c
to
59c7537
Compare
Hey @cfriedt, thanks for your comment! I believe all of your remarks have been addressed in the recent push (here and in the VIRTIO PCI API PR). |
9049399
to
1a0b654
Compare
include/zephyr/fs/fuse.h
Outdated
/* | ||
* Copyright (c) 2025 Antmicro <www.antmicro.com> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 |
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.
The original header seems to be BSD licensed,
https://github.com/torvalds/linux/blob/master/include/uapi/linux/fuse.h
shouldn't this reflect the original copyright and license?
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.
We moved the code that was based on thi sheader to a separate file (fuse_abi.h
), with the original BSD license
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.
Shouldn't it be possible to install this header with a kernel headers package of some kind?
Why are we even duplicating it inside of the Zephyr repo?
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.
Unfortunately, there are some issues with including externally supplied headers:
- Layout of FUSE structures is not stable and was changing in the past (e.g. struct sizes were changed regularly and in some early commits even struct names and field names were sometimes altered) and presumably will also change in the future. This may cause all sorts of problems if a subset of this header used by Zephyr is modified. The virtiofsd itself doesn't use this header, instead it uses its own definitions (https://gitlab.com/virtio-fs/virtiofsd/-/blob/main/src/fuse.rs) and as of now its already a few versions behind the
fuse.h
from Linux - Zephyr allows building on platforms different than Linux and this header won't be present on those. For example, up until recently (QEMU 8.0), virtiofsd was supporting macOS hosts (in QEMU 8.0 implementation was changed to rust based one and non-linux support was dropped), so including header from Linux would artificially limit this use case.
include/zephyr/fs/fuse.h
Outdated
#include <stdint.h> | ||
#include <zephyr/kernel.h> | ||
|
||
/* adapted from Linux: include/uapi/linux/fuse.h */ |
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.
Doesn't this require some license/copyrights from the original file? @kartben
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.
We moved the code that was based on thi sheader to a separate file (fuse_abi.h
), with the original BSD license
include/zephyr/fs/fuse.h
Outdated
|
||
struct fuse_out_header { | ||
uint32_t len; | ||
int32_t error; |
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.
Spaces
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.
Fixed
subsys/fs/virtiofs/virtiofs_zfs.c
Outdated
#ifdef CONFIG_VIRTIOFS_VIRTIOFSD_UNLINK_QUIRK | ||
struct fuse_entry_out lookup_ret; | ||
/* | ||
* Even if unlink doesn't take nodeid as a param it still fails with EIO if the node |
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.
-EIO?
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.
We've reworked this function a bit, but yes - it was -EIO
; changed to that.
1a0b654
to
59c7537
Compare
@de-nordic right. I've tagged this PR with the In the meantime, could you please revisit this PR and let me know if there's anything else that still needs to be addressed here? |
is this about bsd licensed files? |
Yes, it's about this single BSD-licensed header file, which specifies the FUSE ABI: https://github.com/zephyrproject-rtos/zephyr/blob/b6cb351e5418d635341b72606e45c73c4a3aa851/subsys/fs/fuse_client/fuse_abi.h. |
isnt this targeting native simulator only? |
We’re using this with QEMU. We’re showcasing this in the |
ok, thanks. |
subsys/fs/fuse_client/fuse_abi.h
Outdated
@@ -0,0 +1,269 @@ | |||
/* SPDX-License-Identifier: BSD-2-Clause */ |
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.
originally in Linux this file is licensed:
SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)
looks like you are picking BSD-2 here, the question if this is something we can actually do, because here you are basically changing the license and dropping GPL and only the copyright holder should be able to do that. Need to check if we should keep the original license as is and add some clarification.
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.
for example, mbed-tls is SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
and we are fine with that, we do not modify the SPDX and do not remove GPL-2.0....
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.
Right. I've changed the fuse_abi.h
license so that the original identifier is preserved.
3807ec3
b6cb351
to
3807ec3
Compare
3807ec3
to
0a828f7
Compare
The following changes were made:
|
This commit adds fuse structures, requests and functions to fill them Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
This commit adds virtiofs functions implementing fuse operations required to enable zephyr filesystem support Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
This commit implements zephyr filesystem operations for virtiofs Signed-off-by: Jakub Michalski <jmichalski@antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit adds virtiofs sample that presents use of this filesystem Signed-off-by: Jakub Michalski <jmichalski@antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit adds sections to the virtio docs with the currently supported transfer methods, drivers and samples Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
0a828f7
to
d535276
Compare
Rebased due to conflicts after #92682 was merged. |
|
This PR:
Note that this draft PR uses the VIRTIO PCI driver implemented in #83892, and is meant to showcase how the VIRTIO PCI driver can be used with Zephyr.