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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>