Commit graph

123 commits

Author SHA1 Message Date
Daniel Verkamp
96e50eb795 base: return SmallVec directly from platform wait impls
On Windows, this changes the EventContext::wait() return type from Vec
to SmallVec; this removes an extra conversion step, since the only
caller, WaitContext::wait(), constructed a SmallVec from the return
value anyway.

On Linux, this lets us get rid of the PollEventsOwned structure, since
the SmallVec contains the events and does not need to point back at a
separate type for storage.

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

Change-Id: I7857a306ad71be020af309d4186d9e3e651fcc05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633110
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 20:37:30 +00:00
Shao-Chuan Lee
c3c170f780 Revert "base: Add CloseNotifier support to Linux"
This reverts commit b10fa49a6f.

Reason for revert: made ARCVM unresponsive during CTS tests

Original change's description:
> base: Add CloseNotifier support to Linux
>
> This is necessary for its cross-platform usage in metrics.
>
> BUG=b:213152497
> TEST=build
>
> Change-Id: I6618777679349d1f6298f79e1f93fe4e9a3ecf7a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622798
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Michael Hoyle <mikehoyle@google.com>

BUG=b:213152497,b:232316549
TEST=CtsAccessibilityServiceTestCases

Change-Id: If27d2ad016878896a261d6d80c4ea3e252ddd08e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641219
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Shao-Chuan Lee <shaochuan@chromium.org>
2022-05-12 16:31:52 +00:00
Vikram Auradkar
151a573acc base: catch-up with downstream windows changes
- Updates changes to named-pipe.
- Adds high resolution timer support.

BUG=b:213153157
TEST=presubmit

Change-Id: I08615d343aaa0f6576f3e8df884310adf3ade087
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639144
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 00:21:59 +00:00
Daniel Verkamp
b5f8224312 base: windows: use sync::Mutex to avoid unwrap()
Switch the uses of std::sync::Mutex to our custom sync::Mutex, which
panics internally if lock() fails. This helps to reduce the instances of
unwrap(), making it easier to review and understand the code.

BUG=b:213153157
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: I99bfc85967152f50045e64293104de788a5d3829
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633108
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-11 17:56:27 +00:00
Vikram Auradkar
8212e88f83 base: add generate_uuid function
This function will be used by crash reporter to associate a unique id
to a session.

BUG=b:213153157
TEST=presubmit

Change-Id: I5f17e023f8895a75062d80773d1aac6315ce4dcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639685
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 15:43:25 +00:00
Vikram Auradkar
878a53ea57 base: remove wildcard exports
Also exports few more windows symbols.

The current exports are not well grouped/organized yet. We will get to
that in another patch.

BUG=b:213153157
TEST=presubmit

Change-Id: I902ec0f9f572ac7889bd7703365dad472fc8d930
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636274
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-10 21:04:22 +00:00
mikehoyle
b10fa49a6f base: Add CloseNotifier support to Linux
This is necessary for its cross-platform usage in metrics.

BUG=b:213152497
TEST=build

Change-Id: I6618777679349d1f6298f79e1f93fe4e9a3ecf7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
2022-05-10 03:52:11 +00:00
Vikram Auradkar
209c8e774d base: add few more windows specific Event functions
BUG=b:213153157
TEST=presubmit

Change-Id: Ie0fa96e4b84199323bd03000f9be25cf6c3b7723
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636273
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 02:19:24 +00:00
Vikram Auradkar
c57fcc8ef2 base: add clear() to WaitContext as a platform specific extension
BUG=b:213153157
TEST=presubmit

Change-Id: I9f7c958834e9727acaba860600aecfbdc98fcdc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631414
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-09 17:06:19 +00:00
Vikram Auradkar
fd277205e2 base: enable wait_context on windows
BUG=b:213153157
TEST=presubmit

Change-Id: I34707cab4d7a4c6a5b0fa349258eb271cb2e0255
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631413
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 23:13:11 +00:00
Vikram Auradkar
ffc0fb84fa base: move platform specific WatchingEvents under unix/
The struct is not used on windows - windows has something equivalent.

BUG=b:213153157
TEST=presubmit

Change-Id: Ied2d76c33a179d801f2cf185b2224b32c7367254
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631412
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 23:13:10 +00:00
Daniel Verkamp
4fb38ced74 base: improve the WaitContext doc test
Use the PollToken derive and the build_with() function to make the
example more representative of actual uses.

BUG=None
TEST=cargo doc
TEST=cargo test -p base --doc wait_context

Change-Id: I1f154dfd6247786024dc94035ea63db11968e85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630424
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:46:59 +00:00
Daniel Verkamp
45b0920767 doc: add a top-level comment to all crates
This provides at least a minimal one-line description to show what each
crate is about.

BUG=None
TEST=tools/cargo-doc

Change-Id: I26732e8c29062e622d5be09bdc120a49d564b9fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630422
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 20:46:57 +00:00
Daniel Verkamp
5e43f03d80 Fix rustdoc bare URL warnings
BUG=None
TEST=cargo doc

Change-Id: Ib9d14d8aa38eef97c02c60fca3928b70a833b6bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630420
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:46:55 +00:00
Daniel Verkamp
418c33e605 base: unify WriteZeroes and PunchHole traits
Move the trait definitions and tests into a single cross-platform file.
The File impl is also defined in the top-level crate so it can be
exported, and that impl calls new platform-specific functions that
provide the actual implementations.

BUG=None
TEST=cargo test -p base write_zeroes
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: I15267c27bd43385545bc406a0143e943e06b16e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631027
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 18:14:25 +00:00
Vikram Auradkar
71902a2af5 flatten windows/ directory tree a bit
Moves most of the files out of windows/win into windows/. There are a
few files still in windows/win which will be moved in later cls.

BUG=b:213153157
TEST=presubmit

Change-Id: I1fe1bf0cfdcf6ddfdbe35611c0592bac9cc1e6ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630710
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-05 21:35:50 +00:00
Vikram Auradkar
1018275948 base: Prefer descriptor over raw fd in shm
BUG=b:213153157
TEST=presubmit

Change-Id: I308ca7a554bffa0887705a294e0f53c9d2bd1299
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630705
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-05 21:35:49 +00:00
Vikram Auradkar
eee515bb56 base: windows shm support
BUG=b:213153157
TEST=presubmit

Change-Id: I1a6b17821ff274ac8c0b010c44c3927881975aaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630704
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-05 21:35:48 +00:00
Daniel Verkamp
b12dcb5405 base: enable WriteZeroes tests on wine
Replace the File::set_len() call with a normal write to set the initial
file size. Wine does not support the SetFileInformationByHandle features
that set_len() needs:

  0009:fixme:file:SetFileInformationByHandle 0000000000000078, 6,
  00000000002ED970, 8

BUG=None
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: Ib63cef7fd909d8f8a2163f6fe8a27ad8a2e27e76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626024
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 21:12:01 +00:00
Daniel Verkamp
eaac8ba442 base: remove WriteZeroes trait
Only WriteZeroesAt is required now, so remove the unused trait.

BUG=None
TEST=cargo test -p base write_zeroes

Change-Id: I138529c4242d8307fab423fb1f1092b00cb3e950
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626023
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 21:12:00 +00:00
Andrew Walbran
ecbf9dcfa1 Derive Debug for SharedMemory.
This is useful when adding temporary logs to dump it for debugging.

TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: Ia982104943b214b67472f7bdd03c9511191c35cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627452
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2022-05-04 18:01:58 +00:00
Andrew Walbran
9ef18e4760 Use ? rather than Result::map.
It's simpler and cleaner.

TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: I6289722c2415e5afd51c337a8628ba7f5dcc0702
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627451
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-04 17:01:41 +00:00
Vikram Auradkar
d0e5b6ae83 base: export PollContext as EventContext
EventContext is a platform independent name.

BUG=b:213153157
TEST=presubmit

Change-Id: Ib0f51fabb622a4ff0b0678768cee8f0e1ab9bba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3625896
Commit-Queue: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-03 21:23:12 +00:00
Vikram Auradkar
68fb967912 base: Export event related symbols from base in windows
BUG=b:213153157
TEST=presubmit

Change-Id: If4b122b70c11ec1b1591296ff2f67c389fa89671
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3625708
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-03 21:04:21 +00:00
Vikram Auradkar
cdb9e125ae base: rename EventFd to Event
Note that
- the file/symbols within `src/sys/unix/eventfd.rs` have not
  changed yet.
- base still exports EventFd to keep common/cros_asyncv2 happy

BUG=b:213153157
TEST=presubmit

Change-Id: Ie0a4308e8501d2e91364b049e6575d656af866cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3624568
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-03 21:04:19 +00:00
Vikram Auradkar
d67395808e base: move unix specific trait into sys/unix/shm.rs
Also makes symbols exported from sys/unix/mod.rs slightly more
explicit.

BUG=b:213153157
TEST=presubmit

Change-Id: Ibf4390ddf448ab8dc41973ea5071ca59f6abfc29
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621212
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-03 18:55:33 +00:00
Vikram Auradkar
cceb96ee3c base: add from_safe_descriptor to SharedMemory
from_safe_descriptor is used by both windows and unix - windows has to
supply size because the way `handle`s are treated. So make size
optional.

BUG=b:213153157
TEST=presubmit

Change-Id: I984b706852f91f5df6b8701df09526f40068f8fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621211
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-03 18:55:32 +00:00
Daniel Verkamp
df929efce3 base: timer: fix crate name in ignored tests
Update the crate name in the comments describing how to run the ignored
timer tests now that they've been moved into the base crate.

BUG=b:213153157
TEST=cargo test -p base timer -- --ignored

Change-Id: I6f8d233c7743c6d379ac4c78d20a70c82344876c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621200
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-03 17:09:19 +00:00
Daniel Verkamp
7b272a4a1b base: use a common FakeClock implementation
The unix and windows clock modules are almost identical now that they
both use the base::Event type, so we can merge them into a single
platform-independent version now.

BUG=b:213153157
TEST=tools/presubmit

Change-Id: I442f3b21b0425f86ca79d0090cae54acfbdfd344
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621204
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-03 16:33:49 +00:00
Vikram Auradkar
936b567452 base: move ioctl.rs from windows/win/ to windows/
BUG=b:213153157
TEST=presubmit

Change-Id: If3958b6f0a5075f11ecdad0cb8c02a91de667b24
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602923
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-03 02:20:00 +00:00
Vikram Auradkar
c73a8581ca base: make src/mmap.rs platform independent
Mostly moves a code around. Note-worthy changes includes,
- Adds an optional file descriptor field to MemoryMapping.
- Adds is_file_descriptor to MemoryMappingBuilder.

BUG=b:213153157
TEST=presubmit

Change-Id: I288c666eb45bf2bd2fcbcb90c0d748674c287367
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3614853
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-03 02:19:31 +00:00
Vikram Auradkar
6dbc26eec3 base: Export windows ioctl interfaces
Minor refactor to rename variables from 'handle' to 'descriptor'

BUG=b:213153157
TEST=presubmit

Change-Id: Ic4c51368f53b3dfab15a12f2bd07be7f1bc277a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602922
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-03 01:11:02 +00:00
Vikram Auradkar
d27a1b1f25 base: refactor unix ioctl
There is very little of ioctl that is shared across platforms. This
cl moves all of code from src/ioctl.rs into src/sys/unix/ioctl.rs.

We also prefer to keep descriptor version of the interfaces.

Deletes unused windows ioctl.rs file located under src/sys/windows/.
Windows version of the file will have same interfaces but completely
different implementation.

BUG=b:213153157
TEST=presubmit

Change-Id: I047f58c3732c05a16dfe6885b2b875b07fedf860
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602921
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-03 01:11:00 +00:00
Daniel Verkamp
55a5b54bf2 base: clean up vestigal sys_util references
The sys_util crate has been merged into base, but a few places still
refer to the old name. Fix or remove them as appropriate.

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

Change-Id: Icf9b57aff672b7c1afec768c9694e059f0f9a43d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621205
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-02 20:16:18 +00:00
Daniel Verkamp
afc4fb8dc0 base: syslog: fix error log case
Previously, err_buf would just be a slice of 1024 zero bytes, but it
seems like we wanted to print out the warning message instead.

BUG=None
TEST=tools/presubmit

Change-Id: I92613fd4b9e09b951cd52f5a1ab227068e9de092
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3617366
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-05-02 17:54:34 +00:00
Vikram Auradkar
f0b1a5d112 base: move windows timer
Move and use windows timer. With this, windows base should export/test
Timer/FakeTimer functionality.

A series of patches move unix specific code into src/sys/unix/timer.rs,
retain platform independent code in src/timer.rs and then introduces
windows timer.rs.

BUG=b:213153157
TEST=presubmit

Change-Id: Icbd48756c270184395f0b324e9e1f49d564a929a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600761
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-29 23:40:09 +00:00
Vikram Auradkar
093fb570a9 base: use common timer
- Use SafeDescriptor in Timer is it platform independent
- Move FakeTimer into src/timer.rs as it can be shared across platforms
- Add windows required but unix only(for now) functionality

A series of patches move unix specific code into src/sys/unix/timer.rs,
retain platform independent code in src/timer.rs and then introduces
windows timer.rs.

BUG=b:213153157
TEST=presubmit

Change-Id: I902cae151f7c6d073711b6055e343246f2bea2af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600760
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-29 23:40:08 +00:00
Vikram Auradkar
dc6fc84d41 base: define Timer type
Alias TimerFd to Timer for now. Next patch should get rid of the alias.

A series of patches move unix specific code into src/sys/unix/timer.rs,
retain platform independent code in src/timer.rs and then introduces
windows timer.rs.

BUG=b:213153157
TEST=presubmit

Change-Id: I155936fb14c2435a121d8ef602e208ffb88ebf3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600759
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-04-29 23:40:07 +00:00
Daniel Verkamp
c9ae4da251 base: windows: remove STDOUT_FILENO/STDERR_FILENO
These are not used in the downstream fork. Removing them lets us get rid
of the build.rs file for the base crate.

BUG=None
TEST=tools/presubmit --all

Change-Id: I8d8dfea77b0dc49d2179f0825edb4d1525d8724a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3617364
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-29 22:38:14 +00:00
Daniel Verkamp
7296fa5e12 base: remove unix Fd type
All users have been migrated to the more portable Descriptor type.

BUG=None
TEST=tools/presubmit

Change-Id: I41ea238995242c48f9ad02a78491a73e0d9bdbe6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3616617
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-29 20:20:35 +00:00
Vikram Auradkar
fb874a8a9f base: Prefer platform independent descriptor over fd
BUG=b:213153157
TEST=presubmit

Change-Id: Ie697c92fe84beeb8fb91620b4888bc354882d5db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3615334
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-29 17:54:31 +00:00
Noah Gold
7e0c7f1173 base: document early wake potential on Timer.
The Windows timer can wake up early, which may be unexpected. This CL
documents that behavior.

BUG=b:229680949
TEST=n/a

Change-Id: I2047c1cdcf0819ed1c4b5f5d4ed9c70e8cb71caf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3615343
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-29 17:39:38 +00:00
Vikram Auradkar
7c7a4788d5 base: enable notifier
BUG=b:213153157
TEST=presubmit

Change-Id: I9e7af1e84e57c8f176d47cff1c15abbcd0e00776
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602930
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-29 17:16:52 +00:00
Vikram Auradkar
7e6cfb912d base: remove unused files
These files are left-over from a couple of earlier refactors.

BUG=b:213153157
TEST=`cargo test` from base/

Change-Id: I9944d42db6101f3f77a140021f0fa7d0111b075d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3615335
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-04-29 15:51:20 +00:00
Anton Romanov
ed50691066 crosvm: ignore certain tests on wine
Use target_env as heuristic to detect wine as we build wine tests with
mingw while real tests use msvc

BUG=none
TEST=cargo test --target x86_64-pc-windows-gnu -- --test-threads=1

Change-Id: I96afd964d52539ab40b56d236442aa3651637991
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3615511
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-04-28 23:50:58 +00:00
Vikram Auradkar
05ef6b1679 base: fix doc error
BUG=b:213153157
TEST=`cargo test` from base/

Change-Id: I38d682a10d2183dd51713d631886d752bb23e832
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3614854
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
2022-04-28 22:24:43 +00:00
Vikram Auradkar
09a0f438f4 base: Add Serialize and Deserialize to Priority and PriorityFilter
Downstream uses this to dump Config found in /src/crosvm

BUG=b:213153157
TEST=presubmit

Change-Id: I191a799d7cce84e27c3b4c4aa2d6f8e939439ac6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3611468
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-27 23:44:01 +00:00
Vikram Auradkar
0c0ba1c158 base: fix Event import in clock
The unix clock uses crate::Event. Using crate::Event makes it
consistent and downstream compiler happy.

BUG=b:213153157
TEST=presubmit

Change-Id: Ia03f0eb787eb8eaf344fe4fa25b5a78f705f43c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606372
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-25 22:57:06 +00:00
Vikram Auradkar
273a9b16b3 base: move timerfd to timer
A series of patches move unix specific code into src/sys/unix/timer.rs,
retain platform independent code in src/timer.rs and then introduces
windows timer.rs.

BUG=b:213153157
TEST=presubmit

Change-Id: I1dad42b112305e70582f0ec8a0e38b7e305783fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600758
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-22 02:13:13 +00:00
Vikram Auradkar
5bafb3a3c7 base: Fix doc tests
Some of the fixes are already available for unix code. This change will
make future cls pass doc tests on windows.

BUG=b:213153157
TEST=presubmit

Change-Id: Ie172c1cb253f633628ae9db016fcd259b39b0bfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600757
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-22 02:13:12 +00:00