Commit Graph

8 Commits

Author SHA1 Message Date
Stefano Garzarella
65140bff6a Use Vec::first() instead of Vec::get(0)
Fix the following clippy warning:

    warning: accessing first element with `configs.get(0)`
       --> vhost-device-vsock/src/main.rs:410:22
        |
    410 |         let config = configs.get(0).unwrap();
        |                      ^^^^^^^^^^^^^^ help: try: `configs.first()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
        = note: `#[warn(clippy::get_first)]` on by default

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-01-15 13:13:37 +02:00
Manos Pitsidianakis
ddc25ecf34 scmi: revert to previous --help-devices behavior
Commit b37e7e5709 changed how
the --help-deices text output was used inadvertently by including it by
default in the help output. Restore the --help-devices argument and make
it exclusive: you cannot combine it with other arguments. This way,
socket_path does not have to be an Option<PathBuf>.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-06 16:32:50 +05:30
Manos Pitsidianakis
b37e7e5709 scmi: make socket_path required
Use clap's derive attributes to print device help instead of doing it
manually with the parsed arguments.

Previous output
===============

```text
Usage: vhost-device-scmi [OPTIONS]

Options:
  -s, --socket-path <SOCKET_PATH>  vhost-user socket to use (required)
  -d, --device <DEVICE>...         Devices to expose
      --help-devices               Print help on available devices
  -h, --help                       Print help
```

New output
==========

```text
vhost-user SCMI backend device

Usage: vhost-device-scmi [OPTIONS] --socket-path <SOCKET_PATH>

Options:
  -s, --socket-path <SOCKET_PATH>  vhost-user socket to use
  -d, --device <DEVICE>...         Devices to expose
  -h, --help                       Print help
  -V, --version                    Print version

Available devices:

- iio: industrial I/O sensor
  Parameters:
  - path: path to the device directory (e.g. /sys/bus/iio/devices/iio:device0)
  - channel: prefix of the device type (e.g. in_accel)
  - name: an optional name of the sensor, max. 15 characters

- fake: fake accelerometer
  A simple 3-axes sensor providing fake pre-defined values.
  Parameters:
  - name: an optional name of the sensor, max. 15 characters

Device specification example:
--device iio,path=/sys/bus/iio/devices/iio:device0,channel=in_accel
```

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-05 15:53:52 +05:30
Manos Pitsidianakis
4ba64be44b scmi: use PathBuf for socket path
clap can parse a PathBuf directly from the command line arguments, and
paths are not always UTF-8. Use PathBuf instead of a String to allow for
all valid filesystem paths.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-05 11:58:42 +02:00
Viresh Kumar
00ad80d736 vhost-device: Don't return bool unnecessarily
Since everyone copied the first bits of code from the I2C crate, the
same issue is present almost everywhere. The returned value isn't
checked at all by the callers. Stop returning bool unnecessarily.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-12-01 09:40:52 +01:00
Erik Schilling
25c6ac3362 tree-wide: use new serve convenience function
This become available with the recent vhost-user-backend [1] updates and
allows to get rid of some boilerplate code.

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

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
2023-11-20 13:05:48 +05:30
Erik Schilling
31154ea0da Update vhost-user-backend to 0.11 series
- Features were renamed from slave -> backend
- Generics got simplified
- Some write and read functions on Volatile slice got turned into
  standalone traits: ReadVolatile, WriteVolatile
- handle_event no longer returns a bool

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
2023-11-14 10:48:19 +02:00
Manos Pitsidianakis
a1e013286f Move all crates to workspace root
Having all the workspace crates under the crates/ directory is
unnecessary. Rust documentation itself recommends all crates to be in
the root directory:

https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html#creating-the-second-package-in-the-workspace

I paste the text content here, in case the online page ever changes or
becomes unavailable:

    ## Creating the Second Package in the Workspace

    Next, let’s create another member package in the workspace and call it add_one. Change the top-level Cargo.toml to specify the add_one path in the members list:

    Filename: Cargo.toml

    [workspace]

    members = [
        "adder",
        "add_one",
    ]

    Then generate a new library crate named add_one:

    $ cargo new add_one --lib
         Created library `add_one` package

    Your add directory should now have these directories and files:

    ├── Cargo.lock
    ├── Cargo.toml
    ├── add_one
    │   ├── Cargo.toml
    │   └── src
    │       └── lib.rs
    ├── adder
    │   ├── Cargo.toml
    │   └── src
    │       └── main.rs
    └── target

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-16 12:03:57 +05:30