Skip to content

Add support for VirtIO 9p devices, including the implementation of drivers and related functionalities.#216

Open
luodeb wants to merge 3 commits intorcore-os:masterfrom
luodeb:master
Open

Add support for VirtIO 9p devices, including the implementation of drivers and related functionalities.#216
luodeb wants to merge 3 commits intorcore-os:masterfrom
luodeb:master

Conversation

@luodeb
Copy link

@luodeb luodeb commented Feb 9, 2026

No description provided.

@qwandor qwandor self-requested a review February 15, 2026 20:52
mod embedded_io;
mod hal;
mod queue;
/// Virtqueue implementation and helpers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move the doc comment to an inner doc comment (i.e. //!) in the module file.

@@ -1,5 +1,6 @@
#![deny(unsafe_op_in_unsafe_fn)]

/// Owning variants of virtqueue helpers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this to an inner doc comment in the module file.

mod hal;
mod queue;
/// Virtqueue implementation and helpers.
pub mod queue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this need to be public now?

}

fn read_mount_tag<T: Transport>(transport: &T) -> Option<String> {
let tag_len: u16 = transport.read_config_space(0).ok()?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If read_config_space returns an error it should be propagated to the caller so that it can be reported properly, not just treated as there being no mount tag.

bytes.push(b);
}

String::from_utf8(bytes).ok()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Invalid UTF-8 should probably also be reported as an error rather than just ignored.

let version = core::str::from_utf8(&resp[13..name_end]).ok()?;
info!("virtio-9p rversion: msize={}, version={}", msize, version);
Some(())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are these functions to construct and parse 9p requests and responses here in the example rather than in the driver?

Also, it might be possible to use repr(C) structs with zerocopy and the zerocopy::byteorder types rather than manually slicing up byte buffers.

.queue
.add_notify_wait_pop(&[req], &mut [resp], &mut self.transport)?;

let size = u32::from_le_bytes([resp[0], resp[1], resp[2], resp[3]]) as usize;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this size always the same as used_len?

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.

2 participants