The original usb transfer implementation assumes usbdevfs semantics and
relies on the usb_util crate. With this refactor we abstract the
semantics so we can support different backends and more generic
transfers that only care about allocating transfer buffers and passing
around generic callbacks.
BUG=b:307660802
TEST=built and tested USB functionality on a DUT is unchanged
Change-Id: If31beac94642d4fc63a51f2ac39514998abef536
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065368
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Commit-Queue: Ryuichiro Chiba <chibar@chromium.org>
Auto-Submit: Morg <morg@google.com>
Currently the queue size of virtio-scsi device is set to 256, but the
FIO performance result improved on a larger size 1024. This commit
changes the queue size to 1024 given the performance increase.
BUG=b:300042376
TEST=tools/presubmit
Change-Id: Iad29541436e9a0c2f9acd2587e3bb9ae5e4110cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5067394
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
SerialParameters implements FromKeyValues, so it does not need a custom
from_str_fn to be parsed.
Additionally, fix a typo in the multi-port error message.
BUG=b:295881923
TEST=tools/dev_container tools/presubmit
Change-Id: If72b325c0ab4422dfce9381e78e06fbd25943e5d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5053920
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
It only handles bytes and FDs now.
Change-Id: Ie28ee94c04d9fcd34b9803581ff0e0f087555fce
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5073072
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
The connection type is no longer polymorphic, so there is no need to
thread the file descriptors through an existing connection instance.
The SAFETY comment isn't very satifying, but at least it is closer to
the code that makes the assumption now.
Change-Id: I2b040c2d56c17bddec856fa91da15b9b8cdd62eb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5069045
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Nigthly is enabled as part of https://crrev.com/c/4950268
This change contains the formatting changes resulting from the switch.
BUG=b:302055317
TEST=dev_container presubmit format --no-delta
Change-Id: Idaf2b8bae2e09c624b19d9cd3dd5fc8e4d099b3c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5067088
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This enables nightly rustfmt features in CI so we can keep a consistent
imports style.
The resulting formatting changes are in the follow-up CL and will
need to submit together.
This change also uncovered a bug from a previous commit that caused only
the first command in a series to be waited for. Formatting issues would
not be reported by the tool. The bug is fixed as part of this CL.
BUG=b:302055317
TEST=dev_container presubmit format --no-delta
Change-Id: I5d50609cc89d7e78bce66db120737a302f5c57e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4950268
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
The new version of nix uses OwnedFd in various places, which allows us
to have less unsafe code.
TEST=CQ
BUG=b:293289578
Change-Id: I61aa80c4105eaf1182c5c325109b5aba11cf60de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5072293
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Syscall frequency table is updated with real-world data collected
from typical use cases of crostini and arcvm combined with upstream
benchmark suite.
FIXED=b:258316090
BUG=b:258316090
Change-Id: I4d832a4fc1f9c78dfa753071eea1fe1fad16f096
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068402
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
It isn't safe to send or recv messages concurrently. The byte stream
could get mixed up.
Change-Id: I27039d3f44d5d8ec609ce7974c6f2f3fcbd9768c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068397
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
`Endpoint` has mixture of raw socket methods and vhost-user message
framing methods. This CL hides all of the raw socket methods so that the
type is focused on message framing.
The recv methods' names were changed to more closely match the send
method names. The documentation for returned errors has been deleted
because much of it was out of date.
Change-Id: I55a4f8bea5902fafd8b52468e140de5aa61c5539
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066131
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This was only implemented for unix and is never called anywhere. The
listener code just calls SocketListener.accept() directly, and Windows
does not implement a Listener anyway, so this doesn't help abstract
anything.
Change-Id: I44503e37bccfd180101a91879abc592242187979
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068395
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Convenience methods like this aren't worth the mental overhead IMO.
Change-Id: I2c08cf64b781328f515b88373170c4506058814c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066129
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
It isn't well differentiate from the other methods and inlining it is a
net win in lines-of-code.
Change-Id: I829a96dc4de5f4ee579b1a5beb9b09efddfdcd53
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066128
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This changes the behavior of `Endpoint::recv_body_into_buf` a bit, but
it is only used by a test and the new behavior within the test is
equivalent (if something goes wrong, the `Result::unwrap` will fail
instead of an `assert_eq!`). I'll try to delete that method in a follow
up.
Change-Id: I6a25fb1329575fb641720a43bbb29b53f0996a6d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065427
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This is where we process host display events, such as window size
change and mouse input events. MouseInputManager etc are currently
no-op. Their implementation will be added later.
BUG=b:306024335
Change-Id: Ib67fd64894bd8c9f47cf2ee3cdf2a20901defe3b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5053935
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
protocol_features and protocol_features_ready were set but never read.
hdr_flags could only be set via set_hdr_flags(), which was never called.
as_raw_descriptor() was only needed for a unit test, which can peek into
the innards of the struct instead, resolving a TODO about its purpose.
BUG=b:221882601
Change-Id: Ic5fbe9353aa3de92b8413b04bfbe16fdc7e5dd0a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065409
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The Master struct previously contained an Arc<Mutex<MasterInner>>, but
the only user (VhostUserVirtioDevice) did not need the thread safety
guarantees of a mutex (neither Sync nor Send is necessary). A few
functions on Master used the mutex for inner mutability, but these can
be fixed by just making the functions in question take &mut self instead
of only &self.
Change-Id: I09f344b15c172f4bb671ab3bbd76b2be4614de6d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5064382
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
For some reason, when running in production CI the merge bot
script can't find directories created inside the container. This
is the best explanation I can think of for the error I see in CI
log. This CL moves `mkdir` for all directories host need to access
to run from host.
BUG=b:181105093
TEST=untested, as led can't reproduce this issue
Change-Id: I9b10838c06c32ff607b98e21616f09c4b96392f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5064383
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Option<(usize, bool)> is 16 bytes per item and FilePageState was 16
bytes.
Since we can assume that guest memory size is not that big, page id can
fit in 31 bits.
The metadata size for the swap file is 1MB per 1GB of maximum guest
memory, plus 1MB per 1GB of swapped data.
BUG=b:312072150
TEST=tast run -buildbundle=crosint $DUT arc.SwapAppLatency
Change-Id: I35937fca7800adc14a18720d2722b738bafe2290
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5048213
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
This commit fixes a bug that causes a significant delay when logging out
of an account. The bug occurs because:
* Simple file formats can have many holes, which results in a large
number of discard commands being issued when the file is deleted.
* crosvm implements a mitigation to slow down file size reduction, but
the crosvm process terminates when logging out, causing the swap file
to be deleted simultaneously.
To fix this issue, we compact the data and store it at the beginning of
the file.
BUG=b:312072150
TEST=tast run -buildbundle=crosint $DUT arc.SwapAppLatency
Change-Id: If29611daa1a1eda49a87fdad13541a23a8dcdcf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5043882
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Calculate the page index in a file at page handler layer instead of swap
file layer.
This helps to migrate the swap file to be compacted in the next CL.
BUG=b:312072150
TEST=tast run -buildbundle=crosint $DUT arc.SwapAppLatency
Change-Id: If895f943e2bfe8072e46c3172974ea3edb0f7853
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5040208
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
The mmap_handle and mmap_offset fields are not optional, so the comments
are adjusted to match reality.
Only one test function needed the Copy, Clone, and Default impls, which
can be avoided by tweaking the test (while also making it more useful,
since it tests exactly one failure instead of multiple).
BUG=b:221882601
Change-Id: Icc45577435aa27b18384cd10cb273c5152ad55ac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5063681
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
The "Linux" code depends only on AF_UNIX sockets, which should be
available on any unix-like platform.
Change-Id: Icced9594bf61215fce39e2702cf2aeed86ea42a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5063680
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
crosvm always enables both of these features, and the crate doesn't
build properly without them enabled anymore due to our local changes, so
just drop the features and all cfg checks for them.
TEST=(cd third_party/vmm_vhost/; cargo test)
Change-Id: I02f9caca387846dd24d9486284b064897f275205
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5063679
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Ports the implementation of snapshotting from virtio-snd to vhost-user's
virtio-snd. As part of getting things working, a few bugs were
identified and fixed:
* start_queue was throwing away the event queue. This means we can't
then return that queue back in stop_queue, which is critical for
snapshotting. Now we retain the queue.
* stop_queue removed each worker twice, which was guaranteed to fail.
Now we just remove the worker once.
BUG=b:308890529
TEST=verified audio works across a snapshot/restore.
Change-Id: I661b69327c6630d49700ccf37bb8944c95153380
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5054421
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
In a recent CL, we found that errors from stopping a queue were being
swallowed by the vhost-user middleware. This CL adds some logging to
cover this case.
BUG=b:308890529
TEST=used new logging to debug an issue.
Change-Id: I83a89e542d79ae0fcc4ff430c90edb5fc4335497
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5054420
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Merge bot will now automatically run crosvm benchmark suite and
produce merged profile data file for PGO use at each merge commit
generated on Monday.
As profile data functions with snapshot of code and generating
them requires a non-trivial amount of compute, we decided on
generate profiles at each "natural" snapshot point (cros merges)
instead of each commit, and thus `merged.profdata` will not be
available in upstream repository.
We decided against generating profile at every merge to avoid
bloating cros repository. The profile is also compressed
with xz to reduce its footprint.
TEST=./tools/chromeos/merge_bot --verbose update-dry-runs origin/main
TEST=https://luci-milo.appspot.com/swarming/task/662c0e8432332c11
Change-Id: I0787f3e01b9a83e9e53f36c36cda1a043ceee0d8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5038001
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
The current output of the "list" subcommand is like:
```
\#1: create: 1234 usec
\#2: mkdir: 567 usec
```
This output format is not so easy for futher processing.
Also, it doesn't contain how many times a result is sent.
So, this CL update the format to the following one:
```
name,total (us), count
create, 1234, 400
mkdir, 567, 89
```
BUG=none
TEST=cros_trace_analyser list --input trace.dat
Change-Id: Ia0e0d2d9777e8ba7431a8b90e8ec54e65d242166
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5061774
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Morg <morg@google.com>
Reviewed-by: Morg <morg@google.com>
Also, switch `run_with_handler` to use the concrete type since it is in
a unix only file already.
Change-Id: I512d582ee5407f2e3b830ac8c5caaae12c714c15
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844142
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Since VVU support was dropped, there is now only one Endpoint
implementation (per platform) and so we can remove the related
generics.
Change-Id: Ica35a93dc43326ecb182e0ddeb80cba98f68fb2d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844141
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This matches the Windows Endpoint naming (TubeEndpoint) and helps avoid
confusion with `trait Endpoint`.
Change-Id: Idd3d8c84e995e38dad68848c8bd5b2188f619485
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844140
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
IoBuf is defined in a platform-specific way (it is either iovec on unix
or WSABUF for windows), so it fits into the mission statement of the
base crate, which is meant to be *the* platform abstraction layer in
crosvm.
IoBufMut and VolatileMemory/VolatileSlice are defined in terms of IoBuf,
so they are also moved into base for consistency. Every crate that uses
these types already depended on base, so no extra dependencies are
added, and a few can be removed.
BUG=b:312312646
TEST=tools/dev_container tools/presubmit
Change-Id: I4dddc55d46906dfc55b88e8e6a967d7e1c1922dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046605
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>