Commit graph

142 commits

Author SHA1 Message Date
Gurchetan Singh
a52694d88e crosvm: add licensing/description to alpha crates
crates.io requires:
    - descriptions
    - license or license-file.

in the manifest.  It doesn't seem the SPDX license
list includes the Chromium license, though it could
be added in the future.

https://github.com/spdx/license-list-XML/blob/main/DOCS/license-inclusion-principles.md

Though for now just copy the license to the specific crates.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: I84676d2fe0200b18a23c85dec75c2a934353f507
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082335
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-14 02:05:06 +00:00
Gurchetan Singh
32ec615426 crosvm: pre-release alpha for data_model
data_model is probably going away in the future, but
until we can release it as pre-release alpha for internal
efforts.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: Ie13ec3ab9083d315c78a035b532132296a8fb651
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082333
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-13 17:23:23 +00:00
Gurchetan Singh
a3596b6175 data_model: match Fuchsia releases of various crates
BUG=b:173630595
TEST=compile

Change-Id: I9f258518dc8a475c3f76ed1b56928ea71c522096
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4151814
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-13 17:17:28 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Pattara Teerapong
8162b4ab9e audio_streams: Add default implementation for wait_fd_readable
Add default implementation for wait_fd_readable to help with uprev
process with older package of cros_async.

BUG=b:258759773
TEST=emerge audio_streams

Change-Id: I494ac8615e4d73a0cceaf4c2e1beb6e04e9eedc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4086627
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-12-08 15:15:38 +00:00
Pattara Teerapong
a87d48c12f audio_streams,cros_async: Add async create stream methods
Add async_new_async_{playback,capture}_stream to StreamSource trait.
These methods are used to create new async playback or capture stream
asynchronously. Default implementation is to call their sync version.

cros_async: Add wait_fd_readable to AudioStreamsExecutor trait, this
will be used by libcras to implement the new async_new_async_*_stream
method.

BUG=b:258759773
TEST=emerge audio_streams cros_async
TEST=FEATURES=test emerge-amd64-generic audio_streams

Change-Id: I8dfc743eb8fa6552a1a6b2953b79666e2909e417
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4066242
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-12-05 16:46:49 +00:00
Ronald G. Minnich
9b8fe9237a p9: Add readlink support to 9p
readlink support works in 9p. Symlinks will now stat and
read correctly. A unit test is added.

BUG=None
TEST=cargo test -p p9

Change-Id: If37e0e716535d17222fe67c013986720180b5cb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4072744
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ron Minnich <rminnich@google.com>
2022-12-01 20:51:00 +00:00
Daniel Verkamp
ef6fdc97f5 p9: use MaybeOwned to avoid extra clone in do_walk
When passing the initial path to the do_walk() function, we previously
always called try_clone(), which duplicates the file handle of the
starting path. However, in most cases, the walk will only use the
starting path to open the next file or directory in the chain, and then
the duplicated file descriptor would be immediately closed again.

To avoid this extra overhead, we can use the MaybeOwned type to pass in
a borrowed reference to the starting path and only clone it in the case
where the starting path is also the final path.

BUG=None
TEST=deploy 9s to device, `ls` shared directory, observe strace output

Change-Id: I15aabc850a3b8b72a9097294a35ab6babfcb0556
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3943529
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-12-01 18:47:48 +00:00
Daniel Verkamp
10990c89af Rust 1.65: Fix clippy derive_partial_eq_without_eq lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: Ib2b595385ed04b9480b22549334ce798d980d347
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064717
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-12-01 01:32:30 +00:00
Daniel Verkamp
dfe9869d6c Rust 1.65: Fix clippy borrow_deref_ref, needless_borrow, and explicit_auto_deref lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: I85cd5e096bc7b977fe1d9b231c08338b65e71780
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064714
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-30 19:33:31 +00:00
Grzegorz Jaszczyk
8eae8e0d2d crosvm: improve suspend implementation
As part of commit cadc84b32a the crosvm
suspend command has been extended to generating sleep button injection
in order to put VM in suspend state. Additionally the crosvm suspend
command completed after the guest entered proper power state.

Nevertheless in some circumstances above implementation caused issues.
E.g. when the guest with pass-through devices entered run-time device
suspension, triggering a subsequent system suspend request fails and
makes VM inaccessible. It is because before entering system suspension,
devices which entered device run-time suspension needs to be resumed.
Therefore in problematic scenario:
- VmRequest::Suspend was triggered and it resulted with blocking till
  guest entered proper suspend state
- during VM suspension process some pci config write accesses are made,
  which in some cases triggers write_msi_reg-> write_msi_capability->
  add_msi_route, which underneath sends VmIrqRequest::AddMsiRoute
  request
- above VmIrqRequest::AddMsiRoute request can't be satisfied since
  VmRequest::Suspend made the run_control wait loop busy waiting and
  preventing further requests to be processed

In order to fix the above issue, instead of busy waiting directly in the
run_control wait loop for suspend notification, spawn a new thread, which
will generate the acpi power button and start busy waiting for a
notification that the VM actually entered suspend state. This allows to
postpone sending response over the control tube indicating that the
'crosvm suspend ...' command completed and in the same time process
other Vm*Requests.

Mentioned postponement of 'crosvm suspend ..' completion is crucial
since the full system suspension needs to be blocked till VM actually
enters proper suspend state.

BUG=b:248462336
TEST=With a setup where some device is pass-through to the VM and
--force-s2idle flag is used: wait till pass-through device enters
run-time suspend state and trigger "crosvm suspend
/run/vm/vm.<hash>/crosvm.sock" followed by "crosvm resume ..". Also make
sure that full system suspension/resumption doesn't make VM inaccessible
anymore.

Change-Id: Ic23461a78a62d2116cf5674c71d89f4f86ad96c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3944915
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-11-16 21:38:29 +00:00
Daniel Verkamp
abe87c1c8f Revert "data_model: remove VolatileRef"
This reverts commit d39e5811df.

Reason for revert: libcras still uses VolatileRef and needs to be fixed before we can remove it

Original change's description:
> data_model: remove VolatileRef
>
> All uses except in test code have been eliminated, so we can remove it
> now.
>
> This was an unsafe abstraction, and we have better alternatives (such as
> the read_obj()/write_obj() functions) that do not create a long-lived
> mutable reference that could easily alias other slices.
>
> BUG=None
> TEST=tools/presubmit --all
>
> Change-Id: I84f1e2487d6211ce24b8fc992fa7675765870132
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824000
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>

Bug: None
Change-Id: I867cd1adff6c0c895791833432acd4a64aef0506
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4018409
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2022-11-09 23:37:26 +00:00
Daniel Verkamp
d39e5811df data_model: remove VolatileRef
All uses except in test code have been eliminated, so we can remove it
now.

This was an unsafe abstraction, and we have better alternatives (such as
the read_obj()/write_obj() functions) that do not create a long-lived
mutable reference that could easily alias other slices.

BUG=None
TEST=tools/presubmit --all

Change-Id: I84f1e2487d6211ce24b8fc992fa7675765870132
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824000
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-11-09 21:28:12 +00:00
Daniel Verkamp
11322f007d tree-wide: use LFS variants of libc functions
Use the off64_t versions of libc file functions.

There is no Rust libc crate equivalent of the C _FILE_OFFSET_BITS and
related defines, so we have to use the Linux-specific *64 variants
explicitly.

This extends the size of file offsets to 64 bits instead of 32 on
platforms with 32-bit userspace.

(It also fixes the recently introduced check for non-LFS functions in
ChromeOS - see b/201531268 for details.)

BUG=b:201531268
TEST=emerge-kevin crosvm
TEST=start Crostini on kevin

Change-Id: Ife42917c8896d4fa1ccd78051c2a0b7dd565b2b3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3979975
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-02 22:20:18 +00:00
Richard Zhang
24ed80fd99 win_audio: Upstream Windows audio backend code
The most notable changes are:

* Playback Async support
* Audio Client flags to hide app from SndVol when audio session has
  expired
* Updates to audio_streams and cros_async crates for playback async
  support

BUG=b:256655413
TEST=Verified to work downstream

Change-Id: Ifbe9a15791feaa41d6e1d5eaf2c5824b2c7c25b8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3994882
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-11-02 21:07:37 +00:00
Dennis Kempin
5097b46a62 Fix p9/fuzz build
A search/replace broke the toml file. Fuzz builds are currently
not included in upstream builds.

BUG=None
TEST= USE=fuzzer emerge-amd64-generic dev-rust/p9

Change-Id: I9a42d8a18bc60d137f50fb44581e2e47db259f87
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3999265
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-02 17:24:51 +00:00
Daniel Verkamp
33078aac98 base: replace internal PlatformEvent uses with Event
We should use the public Event API wherever possible, even within the
base crate.

BUG=b:231344063
TEST=tools/presubmit --all

Change-Id: Ie4c8b2b82cf16299666998acb7b9b174c2bedc3b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3966484
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-11-01 20:59:29 +00:00
Dennis Kempin
45b5c13047 Make common crates part of the crosvm workspace
This greatly simplifies and speeds up compilation
and clippy times.

This ChromeOS-side building these crates has been
updated to copy the source out of the source tree
so that they will compile as a separate workspace.

BUG=b:256020427
TEST=presubmit

Change-Id: I2e0f1f6724924d6bdd70ea28d7777df7966cf724
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988324
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-10-31 21:33:33 +00:00
Dennis Kempin
7990b9da3c Replace common/assertions with static_assertions
The crates do the same thing, but static_assertions is
proven and stable, with no added dependencies.

Note: While this won't require changes to chromeos ebuild files
it will require the removal of dev-rust/assertions when crosvm-base
is upreved.

BUG=b:255989923
TEST=presbumit

Change-Id: I1420447ebdaa1a3649b30e6a6ec57f8dee858b98
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988328
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-31 21:33:33 +00:00
Dennis Kempin
278e5ffeba test_runner: Add separate cargo target dir for each platform
Using the same CARGO_TARGET_DIR for all builds prevents us from
building for platforms in parallel, since cargo will lock the
directory to only run one build at a time.

Use the same directory for clippy as well, and ensure that
clippy won't invalidate caches created by run_tests.

This reduces the build time for tools/presubmit by about 50%.

Another advantage is that rust_analyzer and run_tests will no longer
block each other or invalidate the cache when run with different
feature flags.

Note: This introduces two subtle changes to the build that required nit
fixes:
- build.rs files are now run through clippy as well
- common/* crates are now also built for the target architecture instead
  the host.

BUG=None
TEST=tools/presubmit

Change-Id: I8da9ef53418c0b15827d512a04e77828621aef88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3984416
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-31 21:33:33 +00:00
Daniel Verkamp
a323861bf5 p9: set filetype from directory to file in lcreate
The 9p lcreate operation takes a directory fid as input and creates a
file in that directory; when the operation completes, the same fid
becomes a reference to the newly-created file. We updated the internal
self.fids structure's file and path fields to point to the new file, but
we neglected to update the filetype field, which would remain as the
original FileType::Directory.

This caused an issue with commit 53cd18e062 ("p9: use *at() functions
for set_attr"), since that change causes set_attr requests to validate
the filetype is not a directory when attempting to set its length.

BUG=b:253838039
TEST=tast run <...>.DefaultSharedFolder

Change-Id: Ie46a660dd4616d669c924014e704e9b5703eb7e9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3983116
Reviewed-by: Joel Hockey <joelhockey@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-10-26 23:23:53 +00:00
Frederick Mayle
3d4b4809ba base: cross platform Event API
Trying to reconcile the difference between the linux and windows
implementations.

Code relying on the eventfd count must now use the linux specific
`EventExt` interface.

BUG=b:231344063
TEST=presubmits

Change-Id: I14eb50f7a02d766a00f27aca388823309633e193
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864030
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-10-19 20:17:42 +00:00
Daniel Verkamp
53cd18e062 p9: use *at() functions for set_attr
Use fchmodat(), fchownat(), and utimensat() to implement the SET_ATTR
request rather than using the non-'at' variants of these functions.
These can operate on a file descriptor path using the /proc file handle
and "self/fd/N" filename to modify the attributes of a file without
actually opening it, which means we can avoid problems like not being
able to open a read-only file with O_RDWR, which happened previously
with chmod requests.

This means we don't need to open the file at all, except in the case of
a request that needs to set the size, since there is no equivalent
truncateat() function.

BUG=chromium:1369647
TEST=touch /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod -w /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod +w /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod a-r /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod a+r /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chown $USER /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=truncate -s1 /mnt/chromeos/MyFiles/Downloads/hello.txt

Change-Id: I0461ed231cc78b26bcc37ede1a364af984c87f8b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935537
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-10-10 17:50:07 +00:00
Zihan Chen
646b6ea8fa crosvm-fuzz: Migrate crosvm-fuzz to cargo fuzz
Fuzzer targets can be ran with
cargo +nightly fuzz run --fuzz-dir crosvm-fuzz --features
upstream-fuzz <target>

This should enable us to move fuzzing to anywhere including
ClusterFuzz while maintain compatibility with cros infra.

TEST=`cargo fuzz` won't crash in first 30s,
`USE="asan fuzzer" emerge-hatch crosvm` builds,
`/build/hatch/usr/libexec/fuzzers/crosvm_qcow_fuzzer` won't
crash in first 30s
FIXED=b:245007212
BUG=b:244631591

Change-Id: I4b262ee1a6a90247dea96347c55a3849af793bec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3905095
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-03 16:12:15 +00:00
Frederick Mayle
1c3ba38583 base: don't export platform specific Event types
TEST=cargo build && ./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64 --build-only
BUG=b:231344063

Change-Id: I125f4b200abdc6758bae93d98c590c2139fe915b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864025
Auto-Submit: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 21:35:48 +00:00
Pujun Lun
dd2c0a932a crosvm: move enum ProcessType to win_util.
This is to keep consistency with Windows downstream code.
The conversion from ProcessType to EmulatorProcessType is moved to
the metrics crate as it is only used for generating metrics.

BUG=b:213146388
TEST=presubmit

Change-Id: Ia62f76835a1f162dd8bbc9e53fd671968c368473
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3908370
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-21 19:28:49 +00:00
Daniel Verkamp
7c6d8bec3f health-check: enforce blank line after copyright
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)

This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:

/*
 * Example comment block
 */   <-- this line

Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-13 22:24:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
Dennis Kempin
78f62a44e7 Update copyright header check to cover all files
generated files and a list of excluded files are skipped.
Others are fixed to include the missing header.

BUG=b:246579983
TEST=./tools/health-check --all copyright_header

Change-Id: I13e9bf79df18789f1ed4b83fc47c0c2e080d70a8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894240
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-13 18:41:29 +00:00
Vikram Auradkar
644251cec0 crosvm: fold windows-only proto-tube-hack into kiwi
Makes proto-tube the default behavior when kiwi is enabled.

BUG=b:244666222
TEST=tested downstream

Change-Id: I4281dec4dc201ff981662498dae932b514c34050
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3881729
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
2022-09-08 19:04:26 +00:00
Daniel Verkamp
882363bbaf cros_asyncv2: remove pointless drop() in test
Fixes a new clippy lint:
<https://rust-lang.github.io/rust-clippy/master/index.html#drop_non_drop>

BUG=b:243677117
TEST=tools/clippy # with Rust 1.62

Change-Id: I8ff384821a2b20a4fabd1afde16d2f808caae636
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3854974
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-01 19:13:40 +00:00
Judy Hsiao
df71d99018 audio_streams_conformance_test: add playback test for NoopStream
The first version of audio_streams_conformance_test.
It is used to test if the implementation of
audio_streams::AsyncPlaybackBufferStream is correct.

This version only supports the playback test of NoopStream.
It prints the following information for NoopStream.
==

Playback Source: NoopStream
Channels: 2
Format: S16LE
Sample rate: 48000 frames/s
Buffer size: 240 frames
Iterations: 10

Cold start latency: 3.89µs
Records count: 10
[Step] min: 4.94 ms, max: 5.15 ms, average: 5.01 ms,
standard deviation: 0.06 ms.
[Linear Regression] rate: 47916.19 frames/s, standard error: 2.0

BUG=b:238038707
TEST=cargo run

Change-Id: Ifca7dfd35473ffd75856a27e2c6aa1555eba7576
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3805090
Tested-by: Judy Hsiao <judyhsiao@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
2022-08-22 08:17:59 +00:00
Daniel Verkamp
482f46fb2a data_model: add read_from_prefix() function
This is a handy primitive when parsing a buffer of bytes, and it mirrors
the API of byteorder's read_from_prefix().

BUG=None
TEST=cargo build

Change-Id: I4fdfaf2fafdf0c6914e6150d0832a3244239ae02
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3823998
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-08-16 18:43:03 +00:00
Dennis Kempin
3ec91c4653 Add Cargo.lock files to version control again
We originally removed it because we had frequent merge conflicts
and all downstream projects were doing their own pinning already.
We also had CI issues because ChromeOS changes could trigger
Cargo.lock changes in crosvm back then.

The new Cargo.lock format should ease the merge conflicts and we
no longer have issues with external changes triggering changes
in our Cargo.lock. So let's bring it back in.

This will allow us to judge the impact of changing third party
dependencies and gives us a chance to implement a special
review process.

BUG=b:240435583
TEST=CQ

Change-Id: Ie53e5616cc98d7e50a84f3c0a91902dd539f2520
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3795655
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-08-15 19:38:44 +00:00
Daniel Verkamp
600ad38ff8 Remove redundant {self} imports
- Remove trailing ::{self} on all use statements
- Remove any resulting single-level use statements (e.g. use libc;)
- Reformat with `tools/fmt --nightly`

BUG=b:239937122
TEST=tools/dev_container tools/presubmit --all

Change-Id: I8afd1b0458ca6d08d9b41a24583f7d4148597ccb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3798973
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-08-01 21:27:54 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
Richard
27d27a0402 audio_streams: Upstream to support Windows
BUG=b:213150293
TEST=built and presubmits

Change-Id: Ia032dd4645d5a827e4b462ebbf9d10db410f5468
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764468
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: Richard Zhang <rizhang@google.com>
2022-07-15 20:33:15 +00:00
Daniel Verkamp
cdf33f9660 cros-fuzz: upgrade to rand_core 0.6
This is the version used by rand 0.8.x (and the latest available version
as of this writing), so this allows us to upgrade crosvm-fuzz to rand
0.8 as well.

BUG=b:236978141
TEST=tools/dev_container tools/run_tests --target=host
TEST=USE='asan fuzzer' emerge-amd64-generic crosvm

Change-Id: I297f6c17114b2b8e8f12d5dd9d35b071b91d6780
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722780
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-30 23:22:39 +00:00
Vikram Auradkar
1295a6af47 crosvm: add serde to arg types
Windows serializes/deserializes these types to send over a Tube.

BUG=b:213146388
TEST=built on downstream windows and presubmit

Change-Id: Ib9ca4cbb2758a997788c4bab46d573a532e8e3d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3735635
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-30 17:47:59 +00:00
Norman Bintang
8dd4be42e9 audio_streams: Add StreamSourceGenerator trait
Add StreamSourceGenerator trait and add its implementation
for NoopStreamSourceGenerator

BUG=b:220649000
TEST=emerge audio_streams

Change-Id: I470353e95dded61aaab3048c6b3c90bb4bb893b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715078
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-06-30 13:01:29 +00:00
Allen Webb
ac1b5734be common/sync: Bump the version to 0.1.99.
Avoid a collision with sync 0.1.0 on crates.io so patches.crates-io can
be used to override cargo.

BUG=None
TEST=CQ passes

Change-Id: I3f5eb33f20fa5ffab2675ad1a156eefdf687e5b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707378
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-21 18:02:52 +00:00
Daniel Verkamp
9315d0a741 Use 4-space indent in cfg_if treewide
A few of the cfg_if blocks got misaligned somewhere along the line, and
cargo fmt won't rewrite code inside macro invocations, so we have to fix
them manually.

BUG=None
TEST=stare at whitespace

Change-Id: I1ccf7aff7c7827a2687ab5fa50cc192c79d6400b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691968
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-07 17:36:51 +00:00
Daniel Verkamp
62636c5b2f data_model: use fully qualified name in flexible_array_impl! macro
The flexible_array_impl! macro should not rely on the caller to import
FlexibleArray; use $crate::FlexibleArray to refer to it instead.

BUG=None
TEST=tools/presubmit

Change-Id: I9743a4cbc01deb6cdfadd98e63f4803a5572421c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687064
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 18:17:03 +00:00
Peter Collingbourne
4f7d84e5b9 Fix some clippy warnings on aarch64.
Change-Id: Iac9a9540c585a08374c966a1014c6746fbba0554
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687061
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 16:58:32 +00:00
Hikaru Nishida
4f5ba4bd28 Revert "crosvm: remove balloon stats request timeout"
This reverts commit 56c0d02760.

Reason for revert: Break ARCVM after suspend/resume

BUG=b:234067421
TEST=Checked that ARCVM kept working after suspend/resume

Original change's description:
> crosvm: remove balloon stats request timeout
>
> It was done to avoid deadlock when stats are requested before guest is
> up. Implement a stub BalloonStats::NotReady replier until host is up so
> that timeout is no longer necessary.
>
> BUG=b:232289535
> TEST=few tast crostini/arc tests
>
> Change-Id: I6731b4ee9eaecdd65aebdd3f530f0932b0660c85
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3652887
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Anton Romanov <romanton@google.com>
> Auto-Submit: Anton Romanov <romanton@google.com>

Bug: b:232289535
Change-Id: Iffafaef1e1136ebc050d69d001d384eedd0a2319
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3686789
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
2022-06-02 11:09:31 +00:00
Anton Romanov
56c0d02760 crosvm: remove balloon stats request timeout
It was done to avoid deadlock when stats are requested before guest is
up. Implement a stub BalloonStats::NotReady replier until host is up so
that timeout is no longer necessary.

BUG=b:232289535
TEST=few tast crostini/arc tests

Change-Id: I6731b4ee9eaecdd65aebdd3f530f0932b0660c85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3652887
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
2022-05-19 23:34:28 +00:00
Anton Romanov
0124707336 Revert "crosvm: remove balloon stats request timeout"
This reverts commit 716b698659.

Reason for revert: this is wrong in multithreaded mode

Original change's description:
> crosvm: remove balloon stats request timeout
>
> It was done to avoid deadlock when stats are requested before guest is
> up. Implement a stub BalloonStats::NotReady replier until host is up so
> that timeout is no longer necessary.
>
> BUG=b:232289535
> TEST=few tast crostini/arc tests
>
> Change-Id: Ieb6888487ea5b10664b76d8f94330564e7a3c726
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647161
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Auto-Submit: Anton Romanov <romanton@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Anton Romanov <romanton@google.com>

Bug: b:232289535
Change-Id: I11faa967d6030ad4a0c292069b0678260757fda8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3651672
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-05-17 19:23:48 +00:00
Anton Romanov
716b698659 crosvm: remove balloon stats request timeout
It was done to avoid deadlock when stats are requested before guest is
up. Implement a stub BalloonStats::NotReady replier until host is up so
that timeout is no longer necessary.

BUG=b:232289535
TEST=few tast crostini/arc tests

Change-Id: Ieb6888487ea5b10664b76d8f94330564e7a3c726
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3647161
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-05-17 17:45:21 +00:00
Vikram Auradkar
be1cc96549 Make the mod not-arm only
BUG=b:213153157
TEST=presubmit

Change-Id: Ia351a3254c4bc261f2abd5380e5e678156353900
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3614614
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-29 17:45:59 +00:00
Maciek Swiech
0dc385a1f8 crosvm: p9: add support for lock() and getlock() to p9
our current p9 server implementation does not support
fiile locks
(https://www.gnu.org/software/libc/manual/html_node/File-Locks.html).

NOTE: this implementation mirrors the QEMU approach, which defers
locking semantics to the client VFS. This means we do not provide
any guarantees about locks between client/server, nor between
multiple potential clients.

BUG=chromium:1225763
TEST=tests added

Change-Id: I73f04712c7e6869f7679d4f55b2706d21e5cf6b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578027
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2022-04-26 20:36:58 +00:00