Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Add vhost-user-sound crate #8

Closed
wants to merge 85 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
d52a1b9
build(deps): bump proc-macro2 from 1.0.51 to 1.0.55
dependabot[bot] Apr 3, 2023
5f46669
build(deps): bump regex-syntax from 0.6.28 to 0.6.29
dependabot[bot] Apr 3, 2023
fbe982d
build(deps): bump io-lifetimes from 1.0.8 to 1.0.9
dependabot[bot] Apr 3, 2023
e51b410
build(deps): bump rust-vmm-ci from `c2f8c93` to `3640704`
dependabot[bot] Apr 6, 2023
54598ac
build(deps): bump clap from 4.1.8 to 4.1.14
dependabot[bot] Apr 10, 2023
a4fd231
build(deps): bump rustix from 0.36.9 to 0.36.12
dependabot[bot] Apr 10, 2023
00cf8b7
build(deps): bump clang-sys from 1.6.0 to 1.6.1
dependabot[bot] Apr 10, 2023
0df982c
build(deps): bump libc from 0.2.139 to 0.2.141
dependabot[bot] Apr 17, 2023
ad25a16
build(deps): bump proc-macro2 from 1.0.55 to 1.0.56
dependabot[bot] Apr 17, 2023
b42cc0a
build(deps): bump rust-vmm-ci from `3640704` to `8627b37`
dependabot[bot] Apr 17, 2023
6226856
build(deps): bump futures-core from 0.3.26 to 0.3.28
dependabot[bot] Apr 17, 2023
f52cc9c
vsock: Implement VhostUserBackend for VhostUserVsockBackend
techiepriyansh Apr 11, 2023
802a982
build(deps): bump regex from 1.7.1 to 1.8.1
dependabot[bot] Apr 24, 2023
c12f3bf
build(deps): bump windows_x86_64_gnu from 0.42.1 to 0.42.2
dependabot[bot] Apr 24, 2023
46b258c
build(deps): bump clap from 4.1.14 to 4.2.4
dependabot[bot] Apr 24, 2023
69fff75
build(deps): bump getrandom from 0.2.8 to 0.2.9
dependabot[bot] May 1, 2023
0f296e4
build(deps): bump futures-task from 0.3.27 to 0.3.28
dependabot[bot] May 1, 2023
482dd8c
build(deps): bump rustix from 0.36.12 to 0.36.13
dependabot[bot] May 1, 2023
8efaa64
vsock: make TX buffer size configurable
uran0sH Apr 14, 2023
14166a3
build(deps): bump tempfile from 3.4.0 to 3.5.0
dependabot[bot] May 8, 2023
ef238f1
build(deps): bump thiserror from 1.0.38 to 1.0.40
dependabot[bot] May 8, 2023
6edcd04
build(deps): bump anstream from 0.3.0 to 0.3.2
dependabot[bot] May 8, 2023
500f617
vsock: Implement yaml config to support multiple vms setup
ToolmanP May 4, 2023
49d9011
build(deps): bump futures from 0.3.26 to 0.3.28
dependabot[bot] May 15, 2023
0a1e4e2
build(deps): bump cpufeatures from 0.2.6 to 0.2.7
dependabot[bot] May 15, 2023
0d5be1a
build(deps): bump windows_x86_64_msvc from 0.42.1 to 0.42.2
dependabot[bot] May 16, 2023
b2fa8d9
vsock: deal with process_tx error gracefully
slp May 18, 2023
9e8a4ef
vsock: close incoming UDS conns if we aren't ready
slp May 18, 2023
d39e99c
docs: fix the wrong file link in vsock README.md
cutelizebin May 17, 2023
3c33937
build(deps): bump digest from 0.10.6 to 0.10.7
dependabot[bot] May 22, 2023
6292965
build(deps): bump windows_i686_msvc from 0.42.1 to 0.42.2
dependabot[bot] May 22, 2023
a0921b2
Run cargo update
vireshk May 24, 2023
bea6e09
build(deps): bump vhost from 0.6.0 to 0.7.0
dependabot[bot] May 22, 2023
675789e
Update versions of all rust-vmm crates
vireshk May 24, 2023
1872c98
build(deps): bump unicode-ident from 1.0.8 to 1.0.9
dependabot[bot] May 29, 2023
2e425dc
build(deps): bump io-lifetimes from 1.0.10 to 1.0.11
dependabot[bot] May 29, 2023
305bb10
build(deps): bump rust-vmm-ci from `8627b37` to `285971e`
dependabot[bot] May 29, 2023
ef68e50
build(deps): bump regex from 1.8.2 to 1.8.3
dependabot[bot] Jun 5, 2023
08d55d7
build(deps): bump once_cell from 1.17.1 to 1.18.0
dependabot[bot] Jun 5, 2023
7b8ef38
build(deps): bump log from 0.4.17 to 0.4.18
dependabot[bot] Jun 5, 2023
98c99b6
scsi: Initial boilerplate.
Gaelan Jul 20, 2021
a72a0a7
scsi: Add high-level scsi abstraction
Gaelan Jul 20, 2021
be1eaf3
scsi: Add an file-based target implementation
Gaelan Mar 8, 2023
1de6d02
scsi: Add tests for the emulated target
Gaelan Mar 8, 2023
7abcad1
scsi: Add virtio daemon
Gaelan Mar 8, 2023
c07b42b
scsi: Add tests for daemon and virtio code
Ablu May 12, 2023
ad82d45
scsi: Add documentation
Gaelan Jul 20, 2021
4c8a2bc
scsi: Advertise support for CONFIG
Ablu Apr 18, 2023
3adff11
scsi: add support for WRITE(10)
Ablu May 5, 2023
07b103b
scsi: add support for WRITE SAME(16)
Ablu May 5, 2023
a6382dd
scsi: add support for SYNCHRONIZE CACHE(10)
Ablu May 5, 2023
8bb862d
scsi: add some helper scripts for testing
Ablu May 11, 2023
f50e714
scsi: mention out-of-tree fuzzing infrastructure
Ablu May 11, 2023
a4aabb1
vsock: Add support for multiple guests
techiepriyansh Jun 4, 2023
10133d6
build(deps): bump parking_lot_core from 0.9.7 to 0.9.8
dependabot[bot] Jun 12, 2023
7ad0186
build(deps): bump lock_api from 0.4.9 to 0.4.10
dependabot[bot] Jun 12, 2023
393b268
build(deps): bump rust-vmm-ci from `8627b37` to `285971e`
dependabot[bot] Jun 12, 2023
93bdb73
build(deps): bump serial_test from 1.0.0 to 2.0.0
dependabot[bot] Jun 12, 2023
8ac1ce4
gpio: use libgpiod from crates.io
Ablu Jun 13, 2023
1ca98aa
build(deps): bump rust-vmm-ci from `285971e` to `7e9af57`
dependabot[bot] Jun 19, 2023
13b9e2c
build(deps): bump winnow from 0.4.6 to 0.4.7
dependabot[bot] Jun 19, 2023
fa4fbc4
build(deps): bump sha2 from 0.10.6 to 0.10.7
dependabot[bot] Jun 19, 2023
f260959
build(deps): bump getrandom from 0.2.9 to 0.2.10
dependabot[bot] Jun 19, 2023
83bc481
Run cargo update
techiepriyansh Jun 23, 2023
f0be54b
build(deps): bump toml_edit from 0.19.10 to 0.19.11
dependabot[bot] Jun 26, 2023
a893caa
build(deps): bump clap from 4.3.5 to 4.3.8
dependabot[bot] Jun 26, 2023
45e6c6d
build(deps): bump serde_yaml from 0.9.21 to 0.9.22
dependabot[bot] Jun 26, 2023
1e97f7c
build(deps): bump rust-vmm-ci from `7e9af57` to `9dfe5b2`
dependabot[bot] Jul 3, 2023
8ed0c0e
build(deps): bump num_cpus from 1.15.0 to 1.16.0
dependabot[bot] Jul 3, 2023
6d548cd
build(deps): bump itoa from 1.0.6 to 1.0.7
dependabot[bot] Jul 3, 2023
f0b0eee
gpio: update instructions for setting up libgpiod
Ablu Jun 29, 2023
015ccff
vsock: Handle the single VM case same as multiple VMs
techiepriyansh Jun 29, 2023
d6b953e
vsock: Implement sibling VM communication
techiepriyansh Jun 29, 2023
4346438
vsock: Compare packet src_cid with the configured guest CID
techiepriyansh Jun 26, 2023
41f4cb1
build(deps): bump epoll from 4.3.1 to 4.3.2
dependabot[bot] Jul 3, 2023
ad40227
vsock: Fix build error with epoll-4.3.2
vireshk Jul 3, 2023
147c566
build(deps): bump rustix to prevent build error
Ablu Jul 4, 2023
2ebba09
build(deps): switch to released virtio-bindings
Ablu Jul 4, 2023
827921a
build(deps): updated epoll to 4.3.3
Ablu Jul 4, 2023
0bb7836
Symlink license files into crate folders
Ablu Jul 4, 2023
5d9c5e4
Add vhost-user-sound crate
epilys Jul 4, 2023
0d8bea4
sound: add Stream, ControlMessage and other types
epilys Jul 4, 2023
f91c4de
sound: Add CTRL queue handler
epilys Jul 4, 2023
1043755
sound: Add TX queue handler
epilys Jul 4, 2023
81a03fb
sound: add ALSA backend
epilys Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,277 changes: 1,067 additions & 210 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ members = [
"crates/gpio",
"crates/i2c",
"crates/rng",
"crates/scsi",
"crates/sound",
"crates/vsock",
]
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Here is the list of device backends that we support:
- [GPIO](https://github.com/rust-vmm/vhost-device/blob/main/crates/gpio/README.md)
- [I2C](https://github.com/rust-vmm/vhost-device/blob/main/crates/i2c/README.md)
- [RNG](https://github.com/rust-vmm/vhost-device/blob/main/crates/rng/README.md)
- [Sound](https://github.com/rust-vmm/vhost-device/blob/main/crates/sound/README.md)
- [VSOCK](https://github.com/rust-vmm/vhost-device/blob/main/crates/vsock/README.md)

## Testing and Code Coverage
Expand Down Expand Up @@ -45,14 +46,20 @@ logic to service the virtio requests directly in the application.

## Build dependency

The GPIO crate needs a local installation of libgpiod library to be available,
which can be done like:
The GPIO crate needs a local installation of libgpiod library to be available.
If your distro ships libgpiod >= v2.0, then you should be fine.

$ git clone --depth 1 --branch v2.0-rc1 https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/
$ cd libgpiod
$ ./autogen.sh && make
Otherwise, you will need to build libgpiod yourself:

Either you can do a 'make install' now on your system, or provide path to the
locally build library like this while building vhost-device crates:
git clone --depth 1 --branch v2.0.x https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/
cd libgpiod
./autogen.sh --prefix="$PWD/install/"
make install

$ RUSTFLAGS='-L /home/<username>/libgpiod/lib/.libs/' cargo build --release
In order to inform tools about the build location, you can now set:

export PKG_CONFIG_PATH="<PATH-TO-LIBGPIOD>/install/lib/pkgconfig/"

To prevent setting this in every terminal session, you can also configure
cargo to
[set it automatically](https://doc.rust-lang.org/cargo/reference/config.html#env).
2 changes: 1 addition & 1 deletion coverage_config_x86_64.json
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": ""
}
18 changes: 9 additions & 9 deletions crates/gpio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.1", features = ["derive"] }
clap = { version = "4.3", features = ["derive"] }
env_logger = "0.10"
libc = "0.2"
log = "0.4"
thiserror = "1.0"
vhost = { version = "0.6", features = ["vhost-user-slave"] }
vhost-user-backend = "0.8"
virtio-bindings = "0.2"
virtio-queue = "0.7"
vm-memory = "0.10"
vhost = { version = "0.7", features = ["vhost-user-slave"] }
vhost-user-backend = "0.9"
virtio-bindings = "0.2.1"
virtio-queue = "0.8"
vm-memory = "0.11"
vmm-sys-util = "0.11"

[target.'cfg(target_env = "gnu")'.dependencies]
libgpiod = { git = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/", rev = "d8d3a84b2ddf" }
libgpiod = { version = "0.1" }

[dev-dependencies]
virtio-queue = { version = "0.7", features = ["test-utils"] }
vm-memory = { version = "0.10", features = ["backend-mmap", "backend-atomic"] }
virtio-queue = { version = "0.8", features = ["test-utils"] }
vm-memory = { version = "0.11", features = ["backend-mmap", "backend-atomic"] }
1 change: 1 addition & 0 deletions crates/gpio/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/gpio/LICENSE-BSD-3-Clause
16 changes: 8 additions & 8 deletions crates/i2c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.1", features = ["derive"] }
clap = { version = "4.3", features = ["derive"] }
env_logger = "0.10"
libc = "0.2"
log = "0.4"
thiserror = "1.0"
vhost = { version = "0.6", features = ["vhost-user-slave"] }
vhost-user-backend = "0.8"
virtio-bindings = "0.2"
virtio-queue = "0.7"
vm-memory = "0.10"
vhost = { version = "0.7", features = ["vhost-user-slave"] }
vhost-user-backend = "0.9"
virtio-bindings = "0.2.1"
virtio-queue = "0.8"
vm-memory = "0.11"
vmm-sys-util = "0.11"

[dev-dependencies]
virtio-queue = { version = "0.7", features = ["test-utils"] }
vm-memory = { version = "0.10", features = ["backend-mmap", "backend-atomic"] }
virtio-queue = { version = "0.8", features = ["test-utils"] }
vm-memory = { version = "0.11", features = ["backend-mmap", "backend-atomic"] }
1 change: 1 addition & 0 deletions crates/i2c/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/i2c/LICENSE-BSD-3-Clause
18 changes: 9 additions & 9 deletions crates/rng/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ license = "Apache-2.0 OR BSD-3-Clause"
edition = "2021"

[dependencies]
clap = { version = "4.1", features = ["derive"] }
clap = { version = "4.3", features = ["derive"] }
env_logger = "0.10"
epoll = "4.3"
libc = "0.2"
log = "0.4"
rand = "0.8.5"
tempfile = "3.4"
tempfile = "3.5"
thiserror = "1.0"
vhost = { version = "0.6", features = ["vhost-user-slave"] }
vhost-user-backend = "0.8"
virtio-bindings = "0.2"
virtio-queue = "0.7"
vm-memory = "0.10"
vhost = { version = "0.7", features = ["vhost-user-slave"] }
vhost-user-backend = "0.9"
virtio-bindings = "0.2.1"
virtio-queue = "0.8"
vm-memory = "0.11"
vmm-sys-util = "0.11"

[dev-dependencies]
virtio-queue = { version = "0.7", features = ["test-utils"] }
vm-memory = { version = "0.10", features = ["backend-mmap", "backend-atomic"] }
virtio-queue = { version = "0.8", features = ["test-utils"] }
vm-memory = { version = "0.11", features = ["backend-mmap", "backend-atomic"] }
1 change: 1 addition & 0 deletions crates/rng/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/rng/LICENSE-BSD-3-Clause
39 changes: 39 additions & 0 deletions crates/scsi/ARCHITECTURE.md
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.
3 changes: 3 additions & 0 deletions crates/scsi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Upcoming Release

- First initial daemon implementation.
30 changes: 30 additions & 0 deletions crates/scsi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[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.3", 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"
virtio-bindings = "0.2.1"
virtio-queue = "0.8"
vm-memory = "0.11"
vmm-sys-util = "0.11"

[dev-dependencies]
tempfile = "3.2.0"

1 change: 1 addition & 0 deletions crates/scsi/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/scsi/LICENSE-BSD-3-Clause
48 changes: 48 additions & 0 deletions crates/scsi/README.md
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.
Loading