generated from rust-vmm/crate-template
-
Notifications
You must be signed in to change notification settings - Fork 59
scsi rebase #301
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
Merged
Merged
scsi rebase #301
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eb26a8c
scsi: Initial boilerplate.
Gaelan fb0eb41
scsi: Add high-level scsi abstraction
Gaelan 5e2a37a
scsi: Add an file-based target implementation
Gaelan 2127d49
scsi: Add tests for the emulated target
Gaelan 2d99ccf
scsi: Add virtio daemon
Gaelan 5947a41
scsi: Add tests for daemon and virtio code
d0e26b1
scsi: Add documentation
Gaelan 6a7a3aa
scsi: Advertise support for CONFIG
7aea10c
scsi: add support for WRITE(10)
7869e4a
scsi: add support for WRITE SAME(16)
8bad5fa
scsi: add support for SYNCHRONIZE CACHE(10)
418c0a9
scsi: add some helper scripts for testing
81fd2f6
scsi: mention out-of-tree fuzzing infrastructure
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ members = [ | |
"crates/gpio", | ||
"crates/i2c", | ||
"crates/rng", | ||
"crates/scsi", | ||
"crates/vsock", | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"coverage_score": 67.6, | ||
"coverage_score": 69.6, | ||
"exclude_path": "", | ||
"crate_features": "" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# vhost-user-scsi architecture | ||
|
||
Rough outline of the different pieces and how they fit together: | ||
|
||
## `scsi/mod.rs` | ||
|
||
This defines the `Target` trait, which represents a SCSI target. The code in | ||
this file is independent from: | ||
|
||
- A particular SCSI implementation: Currently, we have one implementation of | ||
`Target`, which emulates the SCSI commands itself; but future implementations | ||
could provide pass-through to an iSCSI target or SCSI devices attached to the | ||
host. | ||
- A particular SCSI transport: Nothing in `src/scsi/*` knows anything about | ||
virtio; this is helpful for maintainability, and also allows our SCSI | ||
emulation code to be reusable as, for example, an iSCSI target. To this end, | ||
the `Target` trait is generic over a `Read` and `Write` that it uses for SCSI | ||
data transfer. This makes testing easy: we can just provide a `Vec<u8>` to | ||
write into. | ||
|
||
## `scsi/emulation/*.rs` | ||
|
||
This is the SCSI emulation code, which forms the bulk of the crate. It provides | ||
`EmulatedTarget`, an implementation of `Target`. `EmulatedTarget`, in turn, | ||
looks at the LUN and delegates commands to an implementation of `LogicalUnit`. | ||
In most cases, this will be `BlockDevice`; there's also `MissingLun`, which is | ||
used for responding to commands to invalid LUNs. | ||
|
||
Currently, there is no separation between commands defined in the SPC standard | ||
(commands shared by all device types) and the SBC standard (block-device | ||
specific commands). If we ever implemented another device type (CD/DVD seems | ||
most likely), we'd want to separate those out. | ||
|
||
As noted above, the emulation code knows nothing about virtio. | ||
|
||
## `src/{main,virtio}.rs` | ||
|
||
This code handles vhost-user, virtio, and virtio-scsi; it's the only part of | ||
the crate that knows about these protocols. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Upcoming Release | ||
|
||
- First initial daemon implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[package] | ||
name = "vhost-device-scsi" | ||
version = "0.1.0" | ||
authors = ["Gaelan Steele <[email protected]>", "Erik Schilling <[email protected]>"] | ||
description = "vhost scsi backend device" | ||
repository = "https://github.com/rust-vmm/vhost-device" | ||
readme = "README.md" | ||
keywords = ["scsi", "vhost", "virt", "backend"] | ||
license = "Apache-2.0 OR BSD-3-Clause" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { version = "4.2", features = ["derive"] } | ||
env_logger = "0.10" | ||
epoll = "4.3" | ||
log = "0.4" | ||
num_enum = "0.5" | ||
thiserror = "1.0" | ||
vhost = { version = "0.7", features = ["vhost-user-slave"] } | ||
vhost-user-backend = "0.9" | ||
# until the scsi bindings hit a release, we have to use the commit that adds them as rev. | ||
virtio-bindings = { git = "https://github.com/rust-vmm/vm-virtio", rev = "467c8ec99375a5f4e08b85b18257cd7e0bac1dc0" } | ||
virtio-queue = "0.8" | ||
vm-memory = "0.11" | ||
vmm-sys-util = "0.11" | ||
|
||
[dev-dependencies] | ||
tempfile = "3.2.0" | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# vhost-user-scsi | ||
|
||
This is a Rust implementation of a vhost-user-scsi daemon. | ||
|
||
## Usage | ||
|
||
Run the vhost-user-scsi daemon: | ||
|
||
``` | ||
vhost-user-scsi -r --socket-path /tmp/vhost-user-scsi.sock /path/to/image.raw /path/to/second-image.raw ... | ||
``` | ||
|
||
Run QEMU: | ||
|
||
``` | ||
qemu-system-x86_64 ... \ | ||
-device vhost-user-scsi-pci,num_queues=1,param_change=off,chardev=vus \ | ||
-chardev socket,id=vus,path=/tmp/vhost-user-scsi.sock \ | ||
# must match total guest meory | ||
-object memory-backend-memfd,id=mem,size=384M,share=on \ | ||
-numa node,memdev=mem | ||
``` | ||
|
||
## Limitations | ||
|
||
We are currently only supporting a single request queue and do not support | ||
dynamic reconfiguration of LUN parameters (VIRTIO_SCSI_F_CHANGE). | ||
|
||
## Features | ||
|
||
This crate is a work-in-progress. Currently, it's possible to mount and read | ||
up to 256 read-only raw disk images. Some features we might like to add | ||
at some point, roughly ordered from sooner to later: | ||
|
||
- Write support. This should just be a matter of implementing the WRITE | ||
command, but there's a bit of complexity around writeback caching we | ||
need to make sure we get right. | ||
- Support more LUNs. virtio-scsi supports up to 16384 LUNs per target. | ||
After 256, the LUN encoding format is different; it's nothing too | ||
complicated, but I haven't gotten around to implementing it. | ||
- Concurrency. Currently, we process SCSI commands one at a time. Eventually, | ||
it'd be a good idea to use threads or some fancy async/io_uring stuff to | ||
concurrently handle multiple commands. virtio-scsi also allows for multiple | ||
request queues, allowing the guest to submit requests from multiple cores | ||
in parallel; we should support that. | ||
- iSCSI passthrough. This shouldn't be too bad, but it might be a good idea | ||
to decide on a concurrency model (threads or async) before we spend too much | ||
time here. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.