If the parsed commandline options cannot be converted into a
`VuRngConfig` we would only get a .unwrap() error message.
Chain this before the check of the daemon launch.
Suggested-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Signed-off-by: Erik Schilling <erik.schilling@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>
Tests were run in a series before the previous commit because of a
testing failure (#232), and masked a bug. This is not necessary anymore
since the bug was fixed in the previous commit.
Instead of reverting to running the tests without the #[serial]
attribute, make every test self-contained by using unique temp
directories in each test run.
Test files that refer to sockets need to be unique because they risk
sharing filenames with other tests after refactoring. Since these tests
create/use/free resources, they should take care not to litter /tmp/ and
not share any file with other tests.
This commit uses a unique temp dir as location of test run files instead
of `/tmp/`. It adds a new dev-dependency, `tempfile`.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Using a raw file descriptor in `stream_map` caused two `UnixStream`
instances have a shared single reference to the underlying stream
socket. Use UnixStream::try_clone instead which duplicates the file
descriptor while still referring to the same stream.
Fixes#232
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Earlier we were sending credit update messages to guest
everytime data was read, now we send it only if the available
space is less than 1/4th of the tx buffer size.
benchmarks:
host->guest[Gbps]
before 1.45
after 1.51
guest->host[Gbps]
before 5.68
after 6.07
Note: I did 3 runs of 10 secs and took average of all,
they are relative results.
Fixes#317
Signed-off-by: Ramyak Mehra <rmehra_be19@thapar.edu>
[SG: fixed S-o-b and small things in the commit description]
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
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>
4.3.2 got yanked [1]. No reason was given, but it looks like a build fix
for a bitflags updated [2].
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
[1] https://crates.io/crates/epoll/4.3.2
[2] d3a2304d38
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>
Before bumping, the error was:
error[E0554]: `#![feature]` may not be used on the stable release
channel
--> [...]/rustix-0.37.20/src/lib.rs:101:26
|
101 | #![cfg_attr(rustc_attrs, feature(rustc_attrs))]
| ^^^^^^^^^^^^^^^^^^^^
error[E0554]: `#![feature]` may not be used on the stable release
channel
--> [...]/rustix-0.37.20/src/lib.rs:117:5
|
117 | feature(core_intrinsics)
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0554]: `#![feature]` may not be used on the stable release
channel
--> [...]/rustix-0.37.20/src/lib.rs:117:13
|
117 | feature(core_intrinsics)
| ^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0554`.
error: could not compile `rustix` (lib) due to 3 previous errors
Bumped using: cargo update -p rustix --aggressive
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
With epoll-4.3.2, bitflags moves to 2.3.3 from 1.3.2 and breaks the
build with following error:
error[E0369]: binary operation `!=` cannot be applied to type `Events`
Fix those by using the .bits() functions.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cross-check the packet `src_cid` with the CID configured for the guest.
This will forbid a VM from impersonating another.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
Adds support for communication between sibling VMs that use the
vhost-user-vsock devices from the same vhost-user-vsock application.
Tested with nc-vsock patched to set `.svm_flags = VMADDR_FLAG_TO_HOST`:
host$ vhost-user-vsock \
--vm guest-cid=3,uds-path=/tmp/vm3.vsock,socket=/tmp/vhost3.socket \
--vm guest-cid=4,uds-path=/tmp/vm4.vsock,socket=/tmp/vhost4.socket
vm_cid3$ nc-vsock -l 1234
vm_cid4$ nc-vsock 3 1234
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
In future, we could add the ability to change the configuration at runtime
and allow new guests to be added even without having to restart the
daemon. So it is reasonable to not differentiate between the single and
multiple VM cases, even with only one guest.
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
This simplifies the packaging and allows using existing tooling to
manage further updates.
The lock file was updated with:
cargo update -p libgpiod --aggressive
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Adds support for instantiating multiple `VhostUserVsockBackend`s parallely
to handle multiple guests. Extends the CLI interface to accept the config
for multiple VMs in addition to the yaml config file with the `--vm`
argument as follows:
vhost-user-vsock \
--vm guest_cid=3,socket=/tmp/vhost3.socket,uds_path=/tmp/vm3.vsock \
--vm guest_cid=4,socket=/tmp/vhost4.socket,uds_path=/tmp/vm4.vsock
Signed-off-by: Priyansh Rathi <techiepriyansh@gmail.com>
Polishing this up for inclusion is currently not high on the priority
list, but we can at least link it.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
This provides some tooling for running blktests. The README.md contains
documentation about the architecture.
I am seeing some race-conditions that sometimes lead to boot
freezes [1], so this is not really ready for automatic evaluation during
a CI pipeline.
[1] https://linaro.atlassian.net/browse/ORKO-37
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Link: https://linaro.atlassian.net/browse/ORKO-17
While the command also allows syncing individual regions of a LUN, we
do not support that here and simply sync the entire file.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
WRITE SAME allows writing a block for a repeated number of times.
Mostly, it can also be used to deallocate parts of the block device
(the fstrim functionality uses this). We do not support that aspect
yet. Instead, we will just stupidly repeat the pattern as many times
as we are told.
A future, smarter implementation could just punch a hole into the
backend instead of filling it with zeros.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
This adds write support. Being very similar to READ(10) in structure,
much of the code is very similar.
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
The config that we send is based on the current QEMU defaults
(as of 60ca584b8af0de525656f959991a440f8c191f12).
This allows testing using Alex Bennee's vhost-user-generic series and
will be required for hypervisors that do not come with the stubs that
QEMU has (eg: Xen).
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Link: https://lore.kernel.org/all/20230414160433.2096866-1-alex.bennee@linaro.org/