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>
There was a mix of just unwrapping (panicking) and catching and logging
errors. The unwrapping is not allowing for particulary pretty error
handling, so let's bubble the errors up by not crashing the thread,
but by just returning a Result<()> than is received when joining the
threads.
Not all .unwrap() uses were translated since a followup PR (#389) will
rework that code anyway (and get rid of the .unwrap() in the process).
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
I plan to add some wrapper errors around vhost errors. These end up
nesting other errors all the way to std::error::Error, which has no
Eq trait.
The implementations were only used for comparisions in tests. While
there is a assert_matches!() in nightly [1] it seems unlikely that
further testing lib additions are getting standarized soon (or ever).
One could use assert!(matches!()), but that would worsen the error
messages for test failures. Hence, during review [2] we agreed on
introducing the assert_matches crate. It got no dependencies and
allows us to keep the good error messages while not needing to depend
on nightly.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
[1] https://doc.rust-lang.org/std/assert_matches/macro.assert_matches.html
[2] https://github.com/rust-vmm/vhost-device/pull/388#discussion_r1257831748
We setup pretty-printing with all the thiserror-based Error structs, but
then only bubble the error up to the main, where it just gets printed
with the `Debug` trait.
This "catches" the error in the main and performs pretty printing using
the `Display` trait.
Before:
Error: FailedCreatingListener(SocketError(Os { code: 98, kind:
AddrInUse, message: "Address already in use" }))
After:
[2023-07-06T17:20:47Z ERROR vhost_device_scsi] Failed creating
listener: socket error: Address already in use (os error 98)
vhost-device-vsock is a bit special since it does not let error messages
bubble up to the main. It also does .unwrap() in most places, but it
_does_ pretty print errors during the main request handling part.
Had to slightly adjust the coverage since we have no tests for the main
functions.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
In order to prepare for an initial release of the crates, this adds a
CHANGELOG.md for tracking changes in the future releases.
The template was copied from the vhost crate [1].
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
[1] 900b9a5c41/crates/vhost/CHANGELOG.md
Various rust-vmm dependencies now support Xen platforms under a new
feature `xen`. Add the same here for all the crates.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Once we publish crates to crates.io, only the crate subfolder is
uploaded. Symlink the license files in in order to include them during
packaging.
`cargo package` will replace the symlinks with the actual files during
packaging, so crates.io will include the license file.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
This version brings the SCSI bindings and allows us to drop the git
dependency (which was complicating the packaging situation).
Thanks-to: Jiang Liu <gerry@linux.alibaba.com>
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
The virtio-queue crate doesn't allow invalid queue state since commit
d951283a8e88 ("don't allow processing descriptors for invalid q").
Initialize the queues properly to fix testing failures.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Rather incongruously the common VIRTIO feature flags where part of the
net binding. Now that the new binding are out we can update them to
something generic.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This is what we need eventually, while parsing the requests, lets store
the correct type instead of creating the same everytime.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The I2C device names, /dev/i2c-N, can change from one boot to another of
the host machine and so aren't stable enough to be used for bus
selection.
Instead start accepting I2C master's name as parameter and parse based
on that.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
The path "/dev/i2c-N" is valid only for Linux userspace and must be
handled within PhysDevice's implementation.
Move it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This is required to fix the errors with individual pull requests with
these crates.
Also update other dependencies with general `cargo update`.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cargo.toml defines `license = "Apache-2.0 OR BSD-3-Clause"`,
so let's update the SPDX in source files and add a section
in the readme about the license.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>