Commit graph

76 commits

Author SHA1 Message Date
Grzegorz Jaszczyk
d7db39550e sys_util: netlink: add functionality for family name query and mcast group id parsing
In order to listen on a specific netlink generic multicast group for a given
family (e.g. "acpi_mc_group" multicast group registered for "acpi_event" family),
we first need to get its group id registered by the kernel.

To achieve above, this commit implements two functionalities:
1) family name query (family_name_query), which prepares proper netlink
   message, which is next send to netlink generic controller to query
   kernel about a given family name. (e.g. it can be used to query about
   "acpi_event" family)
2) parse the netlink generic answer and get group id registered for a
   given generic netlink multicast group name (get_multicast_group_id)
   (e.g. it can be used to get multicast group id for "acpi_mc_group").

BUG=b:197247746, b:205072342
TEST=Use introduced functionality to query about "acpi_event" generic
netlink family and get group id for "acpi_mc_group" group. Additionally
test the same after hacking the kernel and registering two other multicast
groups for acpi_event, so "acpi_mc_group" got a different group id. In
both cases successfully listen on "acpi_mc_group".

Change-Id: Ia7681fae2200ff5baebbad3742c9dd97ac59cae5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3515924
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-19 07:27:42 +00:00
Grzegorz Jaszczyk
550ed754da sys_util: netlink: implement AsRawDescriptor for netlink generic socket
In order to use netlink generic socket together with WaitContext,
AsRawDescriptor needs to be implemented.

BUG=b:197247746, b:205072342
TEST=Use NetlinkGenericSocket with WaitContext and successfully use it
for threads

Change-Id: I99c9d508c86395f104a7a2f17a1726b753c9698b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3528638
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-18 15:33:11 +00:00
Dennis Kempin
925e7b54d8 Refactoring: Use super:: instead of crate:: in win_sys_util
This applies the script in https://crrev.com/c/3530119

BUG=b:22320646
TEST=presubmit

Change-Id: I0ebe218a2220f1449af9d5796207a8f8a0b92bdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530120
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 23:57:24 +00:00
Vikram Auradkar
eba2940049 upstream windows vmm_vhost
Windows vmm_vhost differs from linux vmm_vhost mostly on the structures
that it depends on. For example windows uses Tube for linux'
UnixStream.

The patch aliases some of these types in a platform specific file. Rest
of the platform independent code depends on those aliases.

Bug: b:213151429
Test: presubmit, manually run cargo test on windows.
Upstream-Crate: third_party/vmm_vhost

Change-Id: I3f98fbec1ffdd8914dc5befddce3a8483a5fd94f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3496082
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-17 01:56:08 +00:00
Dennis Kempin
ef516189db Refactoring: Move common/base into base
Executes the script in https://crrev.com/c/3530502

BUG=b:223206469
TEST=presubmit

Change-Id: Ibeffdc8de0b2270f070e60bb2de8d9fdc78a2a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 00:01:27 +00:00
Dennis Kempin
f3ceb8e1b9 Refactoring: use super:: instead of crate::
This is the result of running the script in
https://crrev.com/c/3530497/1

BUG=b:223206469
TEST=presubmit

Change-Id: Ia57c20cd13b11545ba33b6fc0c797cb973cbf565
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530498
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-16 23:59:29 +00:00
Vikram Auradkar
a141656f6d rm build_test files
Test: build and presubmit
Bug: b:213149155
Change-Id: I70ca5dac78da29abb61c24a957fc87c604d51ae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3529955
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-03-16 21:38:04 +00:00
Alexandre Courbot
e55b79102c devices: vhost: user: gpu: stop using Tube::try_clone()
Stop using Tube::try_clone() as we want to remove this method.

This requires a change in how the GPU device tube is set. Cloning the
control tube on the VMM side allowed us to pass only one tube to the GPU
device, which received the first message asking for BAR information and
then immediately recycled its tube to send VmMemoryRequests.

Without cloning, we to create two full Tubes and pass the VmMemory tube
as part of the first message to the device. This is a bit more involved
but also safer.

BUG=b:222379833
BUG=b:221484449
TEST=`cargo run device gpu` replies to the initial message and receives
the tube from the VMM process.

Change-Id: I5c85c7c54ab7be0eba322d1884da7076398c4095
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3499911
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-16 05:14:27 +00:00
Vikram Auradkar
585337ceae Fix clippy error
Bug: b:223840386
Test: tools/clippy
Change-Id: I450e5c75150c186e4f3c82b84ed471d08a81c938
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3527438
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-16 00:06:41 +00:00
Vikram Auradkar
e6bc05ef81 scoped_event: Created macro to reduce duplicate code
ScopedEvent's implementation was the exact same in 3 different places.

Bug: b:215618500
Bug: b:223840386
Test: ran emulator
Change-Id: I835ef9c523936dd651652f344f4857515afb8bdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3523746
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-15 20:36:09 +00:00
Dennis Kempin
fd68b42b6d audio_streams: Add async interface to remove dependency on cros_async
The API allows audio_streams to be used by crosvm and libcras while
their implementations of cros_async may diverge in the future.

BUG=b:223624364
TEST=./tools/presubmit and emerge tests

Cq-Depend: chromium:3519246
Change-Id: I08b6bf12e02c211275c11f1886f23f71217e40b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3518657
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-03-15 17:29:21 +00:00
Vikram Auradkar
835badb57a Upstream win_sys_util
This is as is upstream of win_sys_util except following changes
1. Ignores flaky tests in syslog.rs and priority.rs - a todo is added.
2. Ignore this crate of unix tests/clippy.
3. Fix few doctest issues on windows.

The files are pulled from downstream repo at
  Commit-Id: 53e8dfa6ec26de3f2ea2b637a5bfef96703214f3
  Downstream-Change-Id: I5dd9e70566330b469fe245fc71451fb4dcd7e1ba

The cl should not affect unix binaries.
Bug: b:223840386
Test: Tested on windows by running
      1. cargo test --all-features
      2. cargo clippy
      3. cargo fmt

Change-Id: I454f2e03b6269f374d107b83c8223ce98b9e29bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3514125
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-14 20:39:11 +00:00
Vikram Auradkar
89c687919b Upstream win_util
Since this is a windows specific crate, we will skip building and
testing the crate on unix.

The files are pulled from downstream repo at
  Commit-Id: 53e8dfa6ec26de3f2ea2b637a5bfef96703214f3
    Downstream-Change-Id: I5dd9e70566330b469fe245fc71451fb4dcd7e1ba

The cl should not affect unix binaries.

Bug: b:213149154
Test: cargo test on windows

Change-Id: I1be598c119891a6c45b4f397463bcb0a8d89b65c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3515653
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-14 20:39:10 +00:00
Vikram Auradkar
4d88ee98d5 Upstream data_model
Test: cargo test
Bug: b:213147091

Change-Id: I9c73963e18591b8a9548e508f63bbb423f5aafa3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3515113
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-10 18:48:52 +00:00
Daniel Verkamp
578e7cce45 base: remove wildcard and export specific sys_util symbols
As a step toward creating a well-defined base API distinct from
sys_util, remove the wildcard `pub use sys_util::*` and individuall
export just the types, functions, and macros that are intended to be a
part of the public base API.

The only functional change is that the net namespace is flattened into
the top-level base namespace, since it inconsistent with the rest of the
API. (sys_util is not affected and still exports mod net, but base does
not.)

BUG=None
TEST=tools/presubmit
TEST=emerge-hatch crosvm
TEST=emerge-trogdor crosvm

Change-Id: I4028d3489cb3816ec9b8d609b3957db8825eb63d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3500062
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-09 20:50:40 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Daniel Verkamp
90c1700c66 io_uring: regenerate bindgen bindings
The original io_uring bindings were hand edited to eliminate some of the
anonymous unions, so there are some changes in the helper functions.

BUG=b:218388029
TEST=tools/presubmit --quick

Change-Id: I8e049296020dd38ba7c97b096ca6cc346b0a20d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339805
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-07 21:52:24 +00:00
Daniel Verkamp
0ae13d221e Require memoffset version 0.6
Chrome OS does not currently package memoffset-0.6.5 (only 0.6.4), so
building within cros_sdk will fail to find the expected crate. We don't
need any API requirements past what is provided by 0.6, so just request
that. At the same time, upgrade the cros_asyncv2 memoffset from 0.5 to
0.6 so we don't need two separate versions. (The crosvm ebuild was not
requiring a 0.5 version, so this was technically a bug.)

BUG=None
TEST=cargo build
TEST=emerge-hatch crosvm

Change-Id: I2b6c778cdbf57977e6fffd73867e0c4818c44a61
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3502625
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-04 05:15:35 +00:00
Daniel Verkamp
8894542adf io_uring: simplify with helper functions
Add some wrappers to help tame the unruly bindgen anonymous union member
names.

BUG=b:218388029
TEST=cargo build

Change-Id: I4ca5bd9c4d0ae7f60a905a516e8cb5eab761213e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3445532
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-03 23:47:11 +00:00
David Stevens
b5aea72eb7 balloon: add failable balloon adjustment
Add a flag to the adjust command that allows the command to fail. When
this flag is set, a reply is sent with the balloon size at the end of
adjustment.

The flag also changes the semantics of inflation somewhat.  By default,
the balloon driver will indefinitely retry if it fails to allocate pages
during inflation. When the flag is set, the device reacts to puff
failure notifications on the event queue by setting the target num_pages
to the current balloon size, to abort and fail the inflation attempt.

BUG=b:213962590
TEST=manual testing with crrev.com/c/3394436
TEST=check ARCVM balloon still works

Change-Id: Idd606b90550c544ce5bea085f62ac35979679d71
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394442
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-03-02 01:07:00 +00:00
David Stevens
66dd57be46 balloon: add event queue
Implement event queue that was recently proposed upstream [1]. The puff
failure event will be used in a followup CL. The pressure event is
currently ignored. Figuring out how to use it will be done later.

[1] https://lists.oasis-open.org/archives/virtio-comment/202201/msg00139.html

BUG=b:213962590,b:216214118
TEST=check ARCVM balloon still works

Change-Id: Ie1990505da8eda1358f10f24ca3c2b6196303184
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3471334
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-03-02 01:06:58 +00:00
Daniel Verkamp
6bbdcb9e90 base: allow creating Arena from base::MemoryMapping
The sys_util implementation of From<MemoryMapping> for
MemoryMappingArena doesn't work with a base::MemoryMapping, since that
is a struct that wraps sys_util's MemoryMapping rather than a direct
re-export. Add an implementation that calls the sys_util impl with the
inner sys_util MemoryMapping.

BUG=b:213149154
TEST=emerge-hatch crosvm

Change-Id: I2a5cddade91f366b86b61cc4cf5b294c31fb1c4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490742
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-28 19:16:39 +00:00
Vikram Auradkar
6dce4fa0d4 Move os independent errno under a new crate sys_util_core
sys_util_core won't have OS specific features so that sys_util and
win_sys_util can depend on it.

Makes Error::new() to accept generic type that implements TryInto<i32>>

Test: Presubmit
Bug: b:213149154
Upstream-Crate: common/win_sys_util
Change-Id: Ib99357634fdb00414a0ade7980a3d444770980ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3426382
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-22 23:18:38 +00:00
Vikram Auradkar
ae5118f5c7 Enable windows tests for a few crates
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.

Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.

The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.

RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.

Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-18 03:18:58 +00:00
Daniel Verkamp
06771581f4 sys_util: remove SeekHole trait
This was only used in the qcow_img utility, so it is dead code now.

BUG=b:219595052
TEST=tools/presubmit

Change-Id: Ie0872df9a02c5a0ccb62b2884db0dfcfeceaa7c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3462638
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-17 22:04:21 +00:00
Vikram Auradkar
7c9b08aae9 Prepare vmm_vhost to be milti-platform 2/2
The patch prepares backend.rs and connection.rs to be platform
independent by
- depending on base instead on sys_util
- using base::Event over sys_util::EventFd
- replacing RawFd usage with RawDescriptor and derivatives

To keep the noise low, the patch
- aliases structs/traits (Event as EventFd)
- does not rename variables (say from fd to rd).

Note: With this patch the crate/files are not completely platform
independent.

Test: Built, clippy and fmt
Bug: b:213151429
Change-Id: Ib57528ef1a951c3d083cf345c878ec1417b7ce3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460428
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-15 20:56:20 +00:00
Vikram Auradkar
15cc292b7e Prepare vmm_vhost to be milti-platform 1/2
The patch prepares backend.rs and connection.rs to be platform
independent by
- depending on base instead on sys_util
- using base::Event over sys_util::EventFd
- replacing RawFd usage with RawDescriptor and derivatives

To keep the noise low, the patch
- aliases structs/traits (Event as EventFd)
- does not rename variables (say from fd to rd).

Note: With this patch the crate/files are not completely platform
independent.

Test: Built, clippy and fmt
Bug: b:213151429

Change-Id: Id93d4a70db627578e6577017f8ca4d69f892d69a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460427
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-14 19:43:17 +00:00
Vikram Auradkar
7aa543ca35 Introduce code hygiene checks
The patch disallows any platform specific code in sys_util_core and
doesn't let sys_util compile on windows platform.

This ensure to some extent that we keep sys_util and it's dependency
sys_util_core independent of windows code.

check_code_hygiene is not foolproof.

Test: Ran the script against a modified file in sys_util_core containing
      string "target_os = "
      Tried to compile sys_util on windows.
Bug: b:215610772
Upstream-Crate: common/win_sys_util

Cq-Depend: chromium:3433709
Change-Id: Ideb45092a959dd347d966633c3bd4e82f842b1a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3438709
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-08 20:59:24 +00:00
Vikram Auradkar
323006cf82 Move os independent files under a new crate sys_util_core
sys_util_core won't have OS specific features so that sys_util and
win_sys_util can depend on it.

Test: Presubmit
Bug: b:213149154
Upstream-Crate: common/win_sys_util

Cq-Depend: chromium:3433709
Change-Id: I863f7a6bc7549944b4d114cca6d7be04c3093fc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3426380
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-08 20:59:24 +00:00
Dennis Kempin
e225a10959 Enable cros_async tests
Adds use_uring checks to a few more test cases that are using the
URingExecutor.

BUG=b:218374759
TEST=./tools/run_tests

Change-Id: Ie5822dea4f22c2e8cffab13549c07873e89129d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3443634
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-08 17:08:51 +00:00
Dennis Kempin
5eb7743abd clippy: Fix cros_async
This is the last one. Just a few nits and we can now run clippy on all
crates.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: I93ad9ce3b1cf0718bda8588279d7e1a891a0a6f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439052
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:44 +00:00
Chirantan Ekbote
59c5ea8258 cros_asyncv2: Enable support for io_uring
Benchmark data for vm.Fio.block_stress_rw on my hatch_helios:
 * without uring: read bw = 92047, write bw = 214790
 * with uring: read bw = 114332, write bw = 266586

BUG=b:195468578
TEST=unit tests

Change-Id: If02e4a8c7555d6a26f9b204d97bfb9533db55973
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3366173
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-02-03 03:05:30 +00:00
Grzegorz Jaszczyk
1f4e67e324 sys_util: add acpi event support
The acpi events are netlink generic based messages, used by kernel to
notify about various ACPI related events (in fact, the "acpi_event" is
one of registered by the kernel generic netlink family). This commit
adds support for de-capsulating and parsing acpi events from the netlink
generic message.

BUG=b:197247746
TEST=Build crosvm-direct and listen on acpi events, parse and use them
[above done with additional WIP patches but without acpi_event.rs modification]

Change-Id: I1671d95b1bca1fbd31ba042eac49f5d2d99cb92a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3407320
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
2022-02-02 20:03:35 +00:00
Anton Romanov
195724b002 async: remove misplaced must_use attribute
must_use attribute clearly was meant to be set on future struct type
since futures need to be polled to do anything. It was never meant to
apply to invocation of paste macro
Also, today any implementor of `Future` trait gets that attribute by
default anyway

BUG=n/a
TEST=cargo check

Change-Id: I60db1aa2bc7c8d6130cc1579641ae815c9cb738e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425184
Reviewed-by: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-29 03:26:09 +00:00
Allen Webb
da4bad999f sys_util: Add support for F_SEAL_FUTURE_WRITE.
BUG=b:210847494
TEST=cargo build

Change-Id: I8bb714cafba994afed42cbf0c9e6d9adee799dd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3408094
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Auto-Submit: Allen Webb <allenwebb@google.com>
2022-01-28 18:45:49 +00:00
David Stevens
0f924dd693 balloon_control: expose rust API for balloon
Add a crate containing an API for controlling the balloon. This is done
by reusing the API between the control socket and the balloon device.

BUG=b:213962590
TEST=compiles

Change-Id: I5d89d5ebee55162d28ba45ca2c49b7083561b916
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394440
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-28 03:52:35 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Dennis Kempin
6b06f405ff docs: Use mdformat to format markdown files
The tool is added to ./tools/fmt which will be called during
./tools/presubmit as well as by Kokoro during testing.

This requires a new dev container version to bundle the mdformat
tool in the container.

Note: mdformat does not have any IDE integrations, but the prettier
plugin with prose-wrap enabled and a line length of 100 provides
almost identical results.

BUG=None
TEST=./tools/fmt --check

Change-Id: I0ae5659eff8555df7c85c70e62095a1e116b98da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-27 21:29:11 +00:00
David Stevens
4700aa062f sys_util: add more features to UnixSeqpacket
Add an accept_with_timeout method to UnixSeqpacket and implement a few
basic traits for UnixSeqpacket.

BUG=b:213962590
TEST=cargo test

Change-Id: I1b8461e54aac2be31604213b252c15ce2195e33a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394438
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-26 13:42:19 +00:00
Daniel Verkamp
24fcef386a p9: re-add OWNERS file for fuzzer ownership
The dev-rust/p9 ebuild passes the OWNERS file to fuzzer_install, so we
can't remove it entirely.

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

Change-Id: I34c4cdf505a64a73dc7d213dce0eb58de208cc1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373452
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-10 20:43:27 +00:00
Grzegorz Jaszczyk
2c0459db66 sys_util: netlink: fix wrong setting of the netlink msg data end boundary
The netlink data end boundary should be actually set by msg_len. The
previous calculation of data_end and its usage was probably confused with
data size.

This bug prevented access to the entire netlink's message data.

BUG=b:197247746
TEST=Build and print the `data` when netlink message arrives.

Change-Id: I601bcfee9132649f48f774e23426281ba1e88fde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3375544
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-10 20:42:35 +00:00
Grzegorz Jaszczyk
477459aea6 sys_util: netlink: use better naming for netlink message length
The hdr_len was actually keeping length of the netlink message including
header (nlmsg) which was misleading. Rename it to msg_len which is more
accurate.

BUG=b:197247746
TEST=Build with 'USE=crosvm-direct emerge-${BOARD} crosvm'

Change-Id: Id4adcd038d41960eeeb8bda3623c8b3b129ef9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3375543
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-10 20:42:34 +00:00
Daniel Verkamp
98813a4f0b Revert "Remove empty OWNERS files"
This reverts commit 34df9a13cb.

Reason for revert: dev-rust/p9 ebuild depends on common/p9/OWNERS

Original change's description:
> Remove empty OWNERS files
>
> These directories can just inherit the top-level crosvm OWNERS now.
>
> BUG=None
> TEST=None
>
> Change-Id: Iea439e92aac4a03fcf821e4ce715266161209809
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3370743
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug: None
Change-Id: I1043a89e17588cd727614dfc39d69bcf06d82221
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373453
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-01-07 23:35:49 +00:00
Daniel Verkamp
34df9a13cb Remove empty OWNERS files
These directories can just inherit the top-level crosvm OWNERS now.

BUG=None
TEST=None

Change-Id: Iea439e92aac4a03fcf821e4ce715266161209809
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3370743
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-01-07 15:52:04 +00:00
Junichi Uekawa
a11190428b crosvm: minor change in O_DIRECT flag specification.
I could use inline if seems more elegant and in line with
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328602

BUG=b:190435784
BUG=b:184204645
TEST=build

Change-Id: I0d46f6f2520a7c68ae6ed748a3bc217ec83def4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3334326
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-06 22:59:55 +00:00
Chirantan Ekbote
2c16797f00 Remove chirantan from OWNERS
Change-Id: I5ef36b186ee964f33eab7371e2c8b25819354944
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3366171
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-06 21:32:18 +00:00
Chirantan Ekbote
ea956bd908 cros_asyncv2: Add async version of SafeDescriptor
Add a `Descriptor` type that allows callers to asynchronously wait for
the descriptor to become readable or writable.  This is meant to be a
temporary solution so that we slowly convert code over to async rather
than having to do it all at once.

BUG=b:195468578
TEST=unit tests

Change-Id: Ib3ccefe09c25e222afe872d4e6d076e1e3b57b39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3329741
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-22 04:36:39 +00:00
Chirantan Ekbote
1c4bb91c03 cros_asyncv2: Add async UnixSeqPacket
BUG=b:195468578
TEST=unit tests

Change-Id: Id9242a4b94d9e1ea72fc09449acbeefc1e2cb9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3312767
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-22 04:36:37 +00:00
Chih-Yang Hsia
7c97b2e7d3 devices: virtio: snd: Change start_pcm_worker to be polled by streams
Improvements:
- Once a {playback, capture} stream is initiated.
  We should start write (read) audio in each callback period or
  the underlaying audio server will underrun (overrun).
  (Even in the WorkerStatus::Pause state).

- Change the polling loop logic to

  wait for next buffer
  -> check status
  -> try_next desc_chain or exit
  -> transfer data or exit

  And make start_pcm_worker act like real audio hw device, which
  consumes data in every fixed period.

- Right before leaving from WorkerStatus::Quit, we still need to
  transfer data to/from the running stream to prevent
  underrun or overrun.

Changes:
- changes in start_pcm_worker:
  - extract read_data, write_data utils
  - implement From<Result<()>, Error> for virtio_snd_pcm_status
  - poll next_{capture, playback}_buffer
  - if status == WorkerStatus::Pause, still need to transfer data to
    prevent underrun or overrun
  - split Output and Input stream logic
- use copy_from or copy_to instead to io::copy
- remove Condvar usage
- changes in audio_streams
  - add copy_from in AudioBuffer and AsyncPlaybackBuffer
  - add copy_to in AudioBuffer and AsyncCaptureBuffer

BUG=b:210197743
TEST=alsa_conformance_test and make sure there is no
     `ERR cras_server[1818]: Error reading msg from client: rc: -104` or
     `ERR cras_server[1818]: fetch err: -32 for 6490001`
     errors.

Change-Id: I004969040881cb2d46b54589e3e7e634ea67d152
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3341135
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-15 11:28:55 +00:00
Anton Romanov
19ea70b293 sys_util: fix CMSG_SPACE test on arm32
BUG=b/210015827
TEST=cd common/sys_util; cargo test sock_ctrl

Change-Id: I385719ee606279c7d6cbf9faed142fb51bcaef53
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331736
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-14 18:11:31 +00:00