Commit Graph

761 Commits

Author SHA1 Message Date
Milan Zamazal
cbb0449d43 scmi: Refactor unit handling
Make unit handling better SCMI compliant.  Let's distinguish between
scalar sensors and axis sensors and report the units in the
appropriate SCMI commands.  Also, let's change the unit type to u8 to
correspond to the number of unit bits in SCMI.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
58ddb26d5b scmi: Use separate modules for device implementations
For a better readability once we start adding more devices.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
ca8f181bcd scmi: Refactor device specification and creation
Making the device configuration polymorphic requires the device struct
to exist before the device parameters are checked and assigned to the
struct fields.  Which means wrapping the struct fields by Option
unnecessarily or introducing other data confusion.

Let's extract the device configuration from traits to plain functions
in order to keep the device struct's unencumbered.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
73c536df2e scmi: Provide help for devices
Writing `--device help' on the command line will list all the
available devices and their parameters.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
4014a6366f scmi: Kernel instructions and changes for IIO added
Followup patches will allow connecting vhost-user-scmi to industrial
I/O devices.  On host without IIO devices, it’s possible to use
emulated devices for testing.  This patch documents how to use them
and also provides a slightly customized IIO dummy kernel module.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
e0fdfa4c38 scmi: Refactor devices.rs for sensor code reuse
Different sensors will have similar handling.  Let’s extract generic
parts from FakeSensor implementation into a reusable code, within the
limits of Rust.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
3d1cc5b370 scmi: Add a command line option for defining devices
The code already contains support for creating devices that can serve
as SCMI-accessible sensors and a sample fake devices.  But to actually
use the device, the code must be modified.

This patch adds a command line option to define the devices on start.
The format of the option value is in the QEMU style:
DEVICE,PROPERTY=VALUE,…

For example:

  --device fake,name=fake1 fake,name=fake2

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
bc7faf7685 scmi: Add sensor management protocol
This patch implements the necessary parts of the SCMI sensor
management protocol, required either by the SCMI standard or by Linux
VIRTIO SCMI drivers to function correctly.  A part of this
implementation is a fake sensor device, which is useful for both unit
testing here and a testing with a real guest OS.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
5b0b8c3753 scmi: Implement SCMI base protocol
Implementation of the mandatory parts of the SCMI base protocol.  This
allows the daemon to communicate with the guest SCMI VIRTIO device,
although not yet providing any useful functionality.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
Milan Zamazal
9513ed841c scmi: Initial skeleton
This patch adds support for a SCMI vhost-user device.  It implements
the basic skeleton of the vhost-user daemon and of SCMI processing.
It doesn’t provide any real functionality yet, adding it will be the
subject of followup patches.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
2023-09-04 16:15:33 +01:00
dependabot[bot]
e7d0e80282 build(deps): bump regex-syntax from 0.7.4 to 0.7.5
Bumps [regex-syntax](https://github.com/rust-lang/regex) from 0.7.4 to 0.7.5.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/commits)

---
updated-dependencies:
- dependency-name: regex-syntax
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-31 08:22:51 +05:30
dependabot[bot]
9926e75c41 build(deps): bump winnow from 0.5.14 to 0.5.15
Bumps [winnow](https://github.com/winnow-rs/winnow) from 0.5.14 to 0.5.15.
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v0.5.14...v0.5.15)

---
updated-dependencies:
- dependency-name: winnow
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-30 08:32:54 -06:00
Bilal Elmoussaoui
2fa80555d2 misc: Update dependencies lockfile
Following up the update num_enum dependency

Signed-off-by: Bilal Elmoussaoui <belmouss@redhat.com>
2023-08-24 15:42:44 +05:30
Bilal Elmoussaoui
ee2abe6df0 scsi: Bump num_enum
Signed-off-by: Bilal Elmoussaoui <belmouss@redhat.com>
2023-08-24 15:42:44 +05:30
Bilal Elmoussaoui
fad00d3e3c vsock: Set edition to 2021
Similar to other crates

Signed-off-by: Bilal Elmoussaoui <belmouss@redhat.com>
2023-08-24 15:42:44 +05:30
Bilal Elmoussaoui
38624410db misc: Set workspace resolver to 2
cargo complains with the following otherwise:
some crates are on edition 2021 which defaults to resolver = 2,
but virtual workspaces default to resolver = 1

Signed-off-by: Bilal Elmoussaoui <belmouss@redhat.com>
2023-08-24 15:42:44 +05:30
Bilal Elmoussaoui
05cfece5f8 i2c: Don't take a mut ref for reqs
Fixing a nightly clippy warning

Signed-off-by: Bilal Elmoussaoui <belmouss@redhat.com>
2023-08-24 15:42:44 +05:30
Stefano Garzarella
8da7657df0 Update vhost-user-backend package dependency
vhost-user-backend v0.10.0 introduced an issue that affects
all vhost-user backends. I easily reproduced the problem with
vhost-device-vsock: just restart the guest kernel and the
device no longer works.

vhost-user-backend v0.10.1 includes the fix [1] for that issue.

[1] https://github.com/rust-vmm/vhost/pull/180

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-08-22 16:12:31 +05:30
dependabot[bot]
4718ef80ad build(deps): bump log from 0.4.19 to 0.4.20
Bumps [log](https://github.com/rust-lang/log) from 0.4.19 to 0.4.20.
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.19...0.4.20)

---
updated-dependencies:
- dependency-name: log
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 11:19:23 +05:30
dependabot[bot]
a9770822f9 build(deps): bump serde from 1.0.183 to 1.0.184
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.183 to 1.0.184.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.183...v1.0.184)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 11:19:18 +05:30
dependabot[bot]
4fa44ea06c build(deps): bump serde_json from 1.0.104 to 1.0.105
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.104 to 1.0.105.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.104...v1.0.105)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 11:19:11 +05:30
Viresh Kumar
033a0ed614 Update cargo dependencies
The main target of this update is vm-memory to a newer stable version,
but lets update everything anyway.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-08-14 11:55:44 +05:30
dependabot[bot]
6754ca091f build(deps): bump aho-corasick from 1.0.2 to 1.0.3
Bumps [aho-corasick](https://github.com/BurntSushi/aho-corasick) from 1.0.2 to 1.0.3.
- [Commits](https://github.com/BurntSushi/aho-corasick/compare/1.0.2...1.0.3)

---
updated-dependencies:
- dependency-name: aho-corasick
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 11:47:29 +05:30
dependabot[bot]
89362cf3b5 build(deps): bump either from 1.8.1 to 1.9.0
Bumps [either](https://github.com/bluss/either) from 1.8.1 to 1.9.0.
- [Commits](https://github.com/bluss/either/compare/1.8.1...1.9.0)

---
updated-dependencies:
- dependency-name: either
  dependency-type: indirect
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 11:47:21 +05:30
dependabot[bot]
d8fdbb79cd build(deps): bump serde_json from 1.0.100 to 1.0.104
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.100 to 1.0.104.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.100...v1.0.104)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 11:47:13 +05:30
dependabot[bot]
ace68f6722 build(deps): bump pest_generator from 2.7.0 to 2.7.1
Bumps [pest_generator](https://github.com/pest-parser/pest) from 2.7.0 to 2.7.1.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.0...v2.7.1)

---
updated-dependencies:
- dependency-name: pest_generator
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 16:39:10 +05:30
dependabot[bot]
87e51d55f0 build(deps): bump pest_meta from 2.7.0 to 2.7.1
Bumps [pest_meta](https://github.com/pest-parser/pest) from 2.7.0 to 2.7.1.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.0...v2.7.1)

---
updated-dependencies:
- dependency-name: pest_meta
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 16:39:02 +05:30
dependabot[bot]
eea36eefa5 build(deps): bump equivalent from 1.0.0 to 1.0.1
Bumps [equivalent](https://github.com/cuviper/equivalent) from 1.0.0 to 1.0.1.
- [Commits](https://github.com/cuviper/equivalent/compare/v1.0.0...v1.0.1)

---
updated-dependencies:
- dependency-name: equivalent
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 16:38:57 +05:30
Priyansh Rathi
decfd8bd73 vsock: Add VM groups in sibling communication
Restrict the VMs a given VM can communicate with by introducing VM groups.
A group is simply a list of names assigned to the device in the
configuration. A VM can communicate with another VM only if the list of
group names assigned to their devices have atleast one group name in
common.

Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
2023-08-07 16:38:10 +05:30
Priyansh Rathi
bd59ff2462 vsock: Allow optional fields in config file
Currently need to provide all the fields in the yaml config file,
otherwise the application panics. Modify this behaviour to allow not
specifying the optional fields to make it consistent with specifying the
configuration using only CLI arguments.

Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
2023-08-07 16:38:10 +05:30
dependabot[bot]
1da9705549 build(deps): bump thiserror from 1.0.41 to 1.0.44
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.41 to 1.0.44.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.41...1.0.44)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 10:37:32 +05:30
dependabot[bot]
005bdfa17a build(deps): bump num_enum from 0.5.11 to 0.6.1
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.5.11 to 0.6.1.
- [Commits](https://github.com/illicitonion/num_enum/compare/0.5.11...0.6.1)

---
updated-dependencies:
- dependency-name: num_enum
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 10:37:24 +05:30
dependabot[bot]
2c3786084d build(deps): bump proc-macro2 from 1.0.63 to 1.0.66
Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.63 to 1.0.66.
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.63...1.0.66)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 10:37:13 +05:30
Jeongik Cha
637969d0e7 vsock: Increase NUM_QUEUES to 3
In virtio standard, vsock uses 3 vqs. crosvm expects 3 vqs from
vhost-user-vsock impl, but this vhost-user-vsock device sets up
only 2 vqs because event vq isn't handled. And it causes crash in
crosvm. To avoid crash in crosvm, I increase NUM_QUEUES to 3

Signed-off-by: Jeongik Cha <jeongik@google.com>
2023-07-28 09:58:36 +05:30
Jeongik Cha
c2ba07dc06 vsock: add warning message for EVT_QUEUE_EVENT
EVT_QUEUE_EVENT is an unexpected message from current impl, so add
warning for that

Signed-off-by: Jeongik Cha <jeongik@google.com>
2023-07-28 09:58:36 +05:30
Jeongik Cha
f2acb05c33 vsock: Set BACKEND_EVENT based on NUM_QUEUES
BACKEND_EVENT value depends on NUM_QUEUES, because it is the next value
of NUM_QUEUES, so set it based on NUM_QUEUES

Signed-off-by: Jeongik Cha <jeongik@google.com>
2023-07-28 09:58:36 +05:30
Jeongik Cha
9f10349f99 vsock: always epoll_register with cloned stream fd
VsockConnection::stream which is cloned is always used for
epoll_register, except add_new_guest_conn. Only in add_new_guest_conn,
the original stream is used.

Because a stream's raw fd is used for the key of listener_map, it cannot
find proper listener after the first packet.

Signed-off-by: Jeongik Cha <jeongik@google.com>
2023-07-27 16:40:40 +05:30
Stefano Garzarella
6305c66f22 scsi: replaced some leftover of vhost-user-scsi
There was some reference left in the documentation and sources to
"vhost-user-scsi" that we had changed during the rebase.
Let's change them to "vhost-device-scsi".

Everything should be safe.

We leave "vhost-user-scsi" in
crates/scsi/src/scsi/emulation/response_data.rs because it looks like
an identifier with some constant size. We will fix in the future.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-07-24 12:15:23 +05:30
Stefano Garzarella
df9094d94d vsock: rename the package to vhost-device-vsock
All other devices follow the "vhost-device-*" pattern, while for
vsock we used "vhost-user-vsock". Let's rename this as well to be
consistent.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-07-24 12:15:23 +05:30
Stefano Garzarella
540cc8758c vsock: add myself as an author
Harsha did most of the work, but I helped arrange the final
pieces and maintain it.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-07-24 12:15:23 +05:30
Stefano Garzarella
66e1173d6d rng: fix clippy warning
`timer` variable does not need to be mutable as clippy reported:

    warning: variable does not need to be mutable
       --> crates/rng/src/vhu_rng.rs:127:17
        |
    127 |             let mut timer = &mut self.timer;

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-07-24 12:15:23 +05:30
dependabot[bot]
9f5a3a3147 build(deps): bump pest from 2.7.0 to 2.7.1
Bumps [pest](https://github.com/pest-parser/pest) from 2.7.0 to 2.7.1.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.0...v2.7.1)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 12:08:26 +05:30
dependabot[bot]
74f8152846 build(deps): bump clap from 4.3.11 to 4.3.19
Bumps [clap](https://github.com/clap-rs/clap) from 4.3.11 to 4.3.19.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.3.11...v4.3.19)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 12:08:17 +05:30
dependabot[bot]
7f1994a40e build(deps): bump regex-syntax from 0.7.3 to 0.7.4
Bumps [regex-syntax](https://github.com/rust-lang/regex) from 0.7.3 to 0.7.4.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/regex-syntax-0.7.3...regex-syntax-0.7.4)

---
updated-dependencies:
- dependency-name: regex-syntax
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 12:08:12 +05:30
Stefano Garzarella
a4857f122d README: add reference to the scsi device
When we merged the SCSI device, we forgot to put it in the
workspace README.md and put the link to the device README.md.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-07-20 20:55:16 +05:30
Priyansh Rathi
6feb938c50 vsock: Try processing raw packets on other events too
Currently, the `raw_pkts_queue` is processed only when a
`SIBLING_VM_EVENT` is received. But it may happen that the
`raw_pkts_queue` could not be processed completely due to insufficient
space in the RX virtqueue at that time. So, try to process raw packets on
other events too similar to what happens in the RX of standard packets.

Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
2023-07-20 13:29:13 +05:30
Priyansh Rathi
e55b520cb2 vsock: Resolve deadlock in sibling VM communication
The deadlock occurs when two sibling VMs simultaneously try to send each
other packets. The `VhostUserVsockThread`s corresponding to both the VMs
hold their own locks while executing `thread_backend.send_pkt` and then
try to lock each other to access their counterpart's `raw_pkts_queue`.
This ultimately results in a deadlock.

Resolved by separating the mutex over `raw_pkts_queue` from the mutex over
`VhostUserVsockThread`.

Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
2023-07-20 13:29:13 +05:30
Viresh Kumar
bf75205478 crates: Don't warn for vhost_user::Error::Disconnected
The vhost_user::Error::Disconnected error code is returned by the
daemon if the VM is shutting down. Don't Warn the user in this case but
just point out that VM may be shutting down.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-07-20 13:06:31 +05:30
dependabot[bot]
6f81802c22 build(deps): bump unicode-ident from 1.0.10 to 1.0.11
Bumps [unicode-ident](https://github.com/dtolnay/unicode-ident) from 1.0.10 to 1.0.11.
- [Release notes](https://github.com/dtolnay/unicode-ident/releases)
- [Commits](https://github.com/dtolnay/unicode-ident/compare/1.0.10...1.0.11)

---
updated-dependencies:
- dependency-name: unicode-ident
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 15:43:30 +02:00
dependabot[bot]
5c2c04ce4a build(deps): bump is-terminal from 0.4.8 to 0.4.9
Bumps [is-terminal](https://github.com/sunfishcode/is-terminal) from 0.4.8 to 0.4.9.
- [Commits](https://github.com/sunfishcode/is-terminal/compare/v0.4.8...v0.4.9)

---
updated-dependencies:
- dependency-name: is-terminal
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 15:37:11 +02:00