Skip to content

Commit c7b1df0

Browse files
authored
Merge branch 'main' into lizebin/move-iter-out
2 parents dc7148c + c0a5c39 commit c7b1df0

29 files changed

+5566
-184
lines changed

Cargo.lock

Lines changed: 139 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[workspace]
2+
resolver = "2"
23

34
members = [
45
"crates/gpio",
56
"crates/i2c",
67
"crates/rng",
78
"crates/scsi",
9+
"crates/scmi",
810
"crates/vsock",
911
]

coverage_config_x86_64.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"coverage_score": 68.2,
2+
"coverage_score": 71.0,
33
"exclude_path": "",
44
"crate_features": ""
55
}

crates/i2c/src/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl SmbusMsg {
183183
///
184184
/// These smbus related functions try to reverse what Linux does, only
185185
/// support basic modes (up to word transfer).
186-
fn new(reqs: &mut [I2cReq]) -> Result<SmbusMsg> {
186+
fn new(reqs: &[I2cReq]) -> Result<SmbusMsg> {
187187
let mut data = I2cSmbusData {
188188
block: [0; I2C_SMBUS_BLOCK_MAX + 2],
189189
};

crates/scmi/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
## [Unreleased]
3+
4+
### Added
5+
6+
### Changed
7+
8+
### Fixed
9+
10+
### Deprecated
11+
12+
## [0.1.0]
13+
14+
First release
15+

crates/scmi/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "vhost-device-scmi"
3+
version = "0.1.0"
4+
authors = ["Milan Zamazal <[email protected]>"]
5+
description = "vhost-user SCMI backend device"
6+
repository = "https://github.com/rust-vmm/vhost-device"
7+
readme = "README.md"
8+
keywords = ["scmi", "vhost", "virt", "backend"]
9+
license = "Apache-2.0 OR BSD-3-Clause"
10+
edition = "2021"
11+
12+
[dependencies]
13+
clap = { version = "4.3", features = ["derive"] }
14+
env_logger = "0.10"
15+
itertools = "0.10"
16+
log = "0.4"
17+
thiserror = "1.0"
18+
vhost = { version = "0.8", features = ["vhost-user-slave"] }
19+
vhost-user-backend = "0.10"
20+
virtio-bindings = "0.2"
21+
virtio-queue = "0.9"
22+
vm-memory = "0.12"
23+
vmm-sys-util = "0.11"
24+
25+
[dev-dependencies]
26+
assert_matches = "1.5"
27+
virtio-queue = { version = "0.9", features = ["test-utils"] }

crates/scmi/LICENSE-APACHE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE-APACHE

crates/scmi/LICENSE-BSD-3-Clause

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE-BSD-3-Clause

crates/scmi/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# vhost-device-scmi
2+
3+
This program is a vhost-user backend for a VirtIO SCMI device.
4+
It provides SCMI access to various entities on the host; not
5+
necessarily only those providing an SCMI interface themselves.
6+
7+
It is tested with QEMU's `-device vhost-user-scmi-pci` but should work
8+
with any virtual machine monitor (VMM) that supports vhost-user. See
9+
the Examples section below.
10+
11+
## Synopsis
12+
13+
**vhost-device-scmi** [*OPTIONS*]
14+
15+
## Options
16+
17+
.. program:: vhost-device-scmi
18+
19+
.. option:: -h, --help
20+
21+
Print help.
22+
23+
.. option:: -s, --socket-path=PATH
24+
25+
Location of the vhost-user Unix domain sockets.
26+
27+
.. option:: -d, --device=SPEC
28+
29+
SCMI device specification in the format `ID,PROPERTY=VALUE,...`.
30+
For example: `-d iio,path=/sys/bus/iio/devices/iio:device0,channel=in_accel`.
31+
Can be used multiple times for multiple exposed devices.
32+
If no device is specified then no device will be provided to the
33+
guest OS but VirtIO SCMI will be still available there.
34+
Use `--help-devices` to list help on all the available devices.
35+
36+
You can set `RUST_LOG` environment variable to `debug` to get maximum
37+
messages on the standard error output.
38+
39+
## Examples
40+
41+
The daemon should be started first:
42+
43+
::
44+
45+
host# vhost-device-scmi --socket-path=scmi.sock --device fake,name=foo
46+
47+
The QEMU invocation needs to create a chardev socket the device can
48+
use to communicate as well as share the guests memory over a memfd:
49+
50+
::
51+
52+
host# qemu-system \
53+
-chardev socket,path=scmi.sock,id=scmi \
54+
-device vhost-user-scmi-pci,chardev=vscmi,id=scmi \
55+
-machine YOUR-MACHINE-OPTIONS,memory-backend=mem \
56+
-m 4096 \
57+
-object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \
58+
...
59+
60+
## Supported SCMI protocols
61+
62+
The currently supported SCMI protocols are:
63+
64+
- base
65+
- sensor management
66+
67+
Basically only the mandatory and necessary parts of the protocols are
68+
implemented.
69+
70+
See source code (`scmi` crate) documentation for details and how to
71+
add more protocols, host device bindings or other functionality.
72+
73+
## Testing
74+
75+
SCMI is supported only on Arm in Linux. This restriction doesn't
76+
apply to the host, which can be any architecture as long as the guest
77+
is Arm.
78+
79+
The easiest way to test it on the guest side is using the Linux SCMI
80+
Industrial I/O driver there. If an 3-axes accelerometer or gyroscope
81+
VirtIO SCMI device is present and the guest kernel is compiled with
82+
`CONFIG_IIO_SCMI` enabled then the device should be available in
83+
`/sys/bus/iio/devices/`. The vhost-device-scmi fake device is
84+
suitable for this.
85+
86+
Of course, other means of accessing SCMI devices can be used too. The
87+
following Linux kernel command line can be useful to obtain SCMI trace
88+
information, in addition to SCMI related messages in dmesg:
89+
`trace_event=scmi:* ftrace=function ftrace_filter=scmi*`.
90+
91+
### Kernel support for testing
92+
93+
`kernel` subdirectory contains
94+
[instructions](kernel/iio-dummy/README.md) how to create emulated
95+
industrial I/O devices for testing.
96+
97+
## License
98+
99+
This project is licensed under either of
100+
101+
- [Apache License](http://www.apache.org/licenses/LICENSE-2.0), Version 2.0
102+
- [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
103+
104+
unless specified in particular files otherwise.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.cmd
2+
*.ko
3+
*.mod
4+
*.mod.[co]
5+
*.o
6+
Module.symvers
7+
modules.order

0 commit comments

Comments
 (0)