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

[virtio][9p] Add VirtIO 9p device driver #399

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

mob5566
Copy link
Contributor

@mob5566 mob5566 commented Dec 26, 2023

Hi @travisg,

As we discussed in #398, I uploaded the commits to support VirtIO 9p devices. I tested it with arm platform and it worked just fine. I let it attach the lk/ directory as the shared dir and read the LICENSE file. Please see the log bellow:

initializing apps
starting app inetsrv
starting internet servers
starting app shell
entering main console loop
] v9p_tests
0x80013c08: 2f 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20 |/*. * Copyright
0x80013c18: 28 63 29 20 32 30 30 38 2d 32 30 31 35 20 54 72 |(c) 2008-2015 Tr
0x80013c28: 61 76 69 73 20 47 65 69 73 65 6c 62 72 65 63 68 |avis Geiselbrech
0x80013c38: 74 0a 20 2a 0a 20 2a 20 50 65 72 6d 69 73 73 69 |t. *. * Permissi
0x80013c48: 6f 6e 20 69 73 20 68 65 72 65 62 79 20 67 72 61 |on is hereby gra
0x80013c58: 6e 74 65 64 2c 20 66 72 65 65 20 6f 66 20 63 68 |nted, free of ch
0x80013c68: 61 72 67 65 2c 20 74 6f 20 61 6e 79 20 70 65 72 |arge, to any per
0x80013c78: 73 6f 6e 20 6f 62 74 61 69 6e 69 6e 67 0a 20 2a |son obtaining. *
0x80013c88: 20 61 20 63 6f 70 79 20 6f 66 20 74 68 69 73 20 | a copy of this
0x80013c98: 73 6f 66 74 77 61 72 65 20 61 6e 64 20 61 73 73 |software and ass
...

I will continue the file system integration with the 9p driver based on lib/fs. Please let me know if you have any questions!

Thank you for your helps.

@mob5566 mob5566 force-pushed the v9p-dev branch 2 times, most recently from e55d0c8 to b18095d Compare December 26, 2023 08:38
This commit adds the VirtIO 9p device driver based on the VirtIO driver
stack in LK, `dev/virtio`. The driver supports a subset of 9P2000.L
protocol (https://github.com/chaos/diod/blob/master/protocol.md), which
is able to perform basic file operations (fread, fwrite, dirread, etc.).
The primary interface for sending and receiving the 9p messages is
`virtio_9p_rpc`, which is handy and scalable.

The driver is limited to communicate to the host with only one
outstanding 9p message per device due to the simplified driver design.
Basically that is enough for embedded environments when there is no
massive file IO.

Signed-off-by: Cody Wong <codycswong@google.com>
@mob5566 mob5566 force-pushed the v9p-dev branch 2 times, most recently from a60edfb to 6f21ef5 Compare December 26, 2023 09:06
Add a simple test to validate basic functionalities of the VirtIO 9p
device driver, `dev/virtio/9p`.

For now the test attaches to the first v9p device and try to read the
file `LICENSE` under the shared folder. Therefore, if you set the shared
folder to the git root of `lk`, it will read the `LICENSE` of the
littlekernel and dump it to the console after running `v9p_tests`.

For example:

```
starting internet servers
starting app shell
entering main console loop
] v9p_tests
0x80013c08: 2f 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20 |/*. * Copyright
0x80013c18: 28 63 29 20 32 30 30 38 2d 32 30 31 35 20 54 72 |(c) 2008-2015 Tr
0x80013c28: 61 76 69 73 20 47 65 69 73 65 6c 62 72 65 63 68 |avis Geiselbrech
0x80013c38: 74 0a 20 2a 0a 20 2a 20 50 65 72 6d 69 73 73 69 |t. *. * Permissi
0x80013c48: 6f 6e 20 69 73 20 68 65 72 65 62 79 20 67 72 61 |on is hereby gra
...
```

Signed-off-by: Cody Wong <codycswong@google.com>
 - Add the v9p support for arm platform.
 - Add an option `-f` to set the shared directory on the host machine to
   `do-qemuarm`.
 - For example, to use the v9p dir sharing, run the script as:
    ```
    # under `lk/` run the follow command will share the current
    # directory `lk/` within LK vm as VirtIO 9p device
    scripts/do-qemuarm -f .
    ```

Signed-off-by: Cody Wong <codycswong@google.com>
@mob5566
Copy link
Contributor Author

mob5566 commented Jan 31, 2024

Hi @travisg,

I just want to make sure that you didn't miss the PRs. Please let me know if you have any ideas.

@travisg
Copy link
Member

travisg commented Feb 3, 2024

KK! will take a look shortly.

Copy link
Member

@travisg travisg left a comment

Choose a reason for hiding this comment

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

looks pretty good. simple, but functional.

@travisg travisg merged commit 64b462c into littlekernel:master Apr 2, 2024
257 checks passed
@travisg
Copy link
Member

travisg commented Apr 2, 2024

sorry for taking a long time, kept putting it off, but it's a good starter. The use of the bio device is a bit fishy, but i think in general moving this to some sort of actual fs, albeit limited, would work well.

@mob5566
Copy link
Contributor Author

mob5566 commented Apr 2, 2024

Really appreciated the effort and time. 🙏

I will keep working on integrating the virtual 9P with the fs library to make it support fs operations.

@travisg
Copy link
Member

travisg commented Apr 4, 2024 via email

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.

None yet

2 participants