Re: [PATCH] rust: virtio: add virtio support

From: FUJITA Tomonori
Date: Tue Mar 07 2023 - 19:55:55 EST


On Tue, 07 Mar 2023 17:09:27 +0000
Björn Roy Baron <bjorn3_gh@xxxxxxxxxxxxxx> wrote:

> On Tuesday, March 7th, 2023 at 14:03, Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx> wrote:
>
>> This patch adds virtIO support to the rust crate. This includes the
>> capability to create a virtIO driver (through the module_virtio_driver
>> macro and the respective Driver trait) as well as initial virtqueue
>> support.
>>
>> A sample virtIO module is included for conveninence.
>>
>> Signed-off-by: Daniel Almeida daniel.almeida@xxxxxxxxxxxxx
>>
>> ---
>>
>> Ok so this is my first Rust contribution here. It's part of a virtIO
>> driver I was originally writing. Both the probing and the virtqueue
>> support in here were confirmed as working in said prototype driver, and
>> the pieces were picked separately into this patch.
>>
>> Feel free to point me to the best practices around Rust patch
>> submission, as the C stuff like checkpatch etc probably does not apply
>> yet. I did take care to run clippy though.
>>
>
> Great to see Rust support for the driver side of VirtIO! I've got a couple of review comments, but I don't see any big issues. Maybe you could write an actual driver which uses add_sgs though? It doesn't have to be complicated, but just something to show how it will work. That may help with checking if the api is usable. You might try something like virtio-console or virtio-entropy I think.

There was an attempt to implement virtio-net, which might be useful:

https://github.com/Rust-for-Linux/linux/pull/886

C versions of virtio-console, virtio-rng, and virtio-net exists. Both
C and Rust versions in mainline?

Are there guidelines on pushing a Rust driver in mainline?