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>
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>
The test needs to be run single threaded and is not suitable
to be a unit tests.
Integration tests are automatically run single threaded.
BUG=None
TEST=presubmit
Change-Id: Idd49af90c7c1858b28ba47a642a8a808319138c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4018113
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This extra file/mod was left over from before the base/sys_util refactor
and is unnecessary now. Everything has been moved into the
stream_channel mod.
BUG=b:256739711
TEST=presubmit
Change-Id: Ie77c54e3f27ff2173c26060a62258941f710206a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4015561
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Currently, we ignore clippy::needless_return, with many violations in
the code base. This CL fixes trivial, safe-to-fix violations of
needless_return. These were found by removing the needless_return
suppression in .cargo/config.toml and then fixing needless returns.
These are not all needless returns in the code base; it is only the
trivial fixes. This CL is a part of a chain of CLs to fix the
needless_returns in the code base.
BUG=chromium:908640, b:157245930
TEST=cargo clippy + cargo build
Change-Id: I6f8f3a0bed25d774fba7ae4b6e4c021af439ec22
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4014832
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
This is a reland of commit 77688e305d
Tests are ignored on some architectures due to the single thread test
issues b/258371694
Original change's description:
> base: unix: add fork_process
>
> The vmm-swap feature will fork a process to run monitoring userfaultfd.
>
> crosvm uses minijail to fork device processes `ProxyDevice::new()`.
>
> Minijail panics on fork if there are any other threads running. The test
> must be executed in a single thread.
>
> design document: go/tanooki-phase1-dd
>
> BUG=b:215093219
> TEST=cargo test -p base -- --test-threads=1
>
> Change-Id: I408dbfa4d606cbe7b2218096b414512710d60100
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935683
> Reviewed-by: David Stevens <stevensd@chromium.org>
Bug: b:215093219
Change-Id: I94b912b04947cada3e3332861f18988873dfcf81
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4015626
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Auto-Submit: Shin Kawamura <kawasin@google.com>
The vmm-swap feature will fork a process to run monitoring userfaultfd.
crosvm uses minijail to fork device processes `ProxyDevice::new()`.
Minijail panics on fork if there are any other threads running. The test
must be executed in a single thread.
design document: go/tanooki-phase1-dd
BUG=b:215093219
TEST=cargo test -p base -- --test-threads=1
Change-Id: I408dbfa4d606cbe7b2218096b414512710d60100
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935683
Reviewed-by: David Stevens <stevensd@chromium.org>
lseek(2) + SEEK_DATA/SEEK_HOLE is used to find active data in a file.
The api is also effective for memfd. snapshot feature uses to traverse
active pages in the memfd backed guest memory.
BUG=b:215093219
TEST=cargo test -p base unix::file::tests
Change-Id: I9f0eb46a568dadc94231ac437dec25c3478a7d37
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3993126
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
In non-privileged containers, comparing a file descriptor may not
work. So the test will not work in every runtime environment.
BUG=b:244623061
TEST=dev_container --podman --unprivileged tools/run_tests base:base
Change-Id: Ifa67e11db9694c36b47cd5ae88de9247284e1cdf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3999711
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
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>
Refactor the Windows PlatformEvent wait and wait_timeout functions to
use an internal wrapper function that correctly handles waiting forever
by passing the INFINITE value to WaitForSingleObject.
Previously, the wait function used a Duration value of i64::MAX seconds,
which becomes 0xfffffc18 when converted to milliseconds and truncated to
a DWORD. This does not correspond to the INFINITE value (-1, 0xffffffff)
that the Win32 Wait* functions expect, so theoretically a wait() call
could have returned without the event being signaled.
BUG=b:231344063
TEST=tools/presubmit --all
Change-Id: If68c4b2518926c12e8caf6746ef4b0bb152be00d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3966485
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
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>
Use the cross-platform AsRawDescriptor rather than the unix-specific
AsRawFd. FileFlags and PlatformEvent are migrated simultaneously since
the FileFlags unit tests use PlatformEvent.
BUG=b:231344063
TEST=tools/presubmit --all
TEST=cargo test -p base -- --test-threads=1
Change-Id: I3653f7d50524bf459c6fb944b00dce90e9d4e659
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3966483
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
The extracted tests rely on access to system devices
or global state that prevent them from being run in parallel
or in restricted environments.
As an integration test they will be executed separately and
single threaded.
Updates the test runner to ensure integration tests are actually
run single threaded as intended.
BUG=b:244623061
TEST=./tools/run_tests base:\* --repeat 100 -p x86_64/mingw64/aarch64
Change-Id: I4267b9f79055208aca86796d902da251816bcada
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3971025
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Replace the single new_with_manual_reset() call, which passed false to
create an auto-reset event, with a call to the more descriptive
new_auto_reset() function.
This allows the new_with_manual_reset() API to be removed.
BUG=b:231344063
TEST=tools/presubmit --all
Change-Id: I51d1fcbab161d10539c44689b31e2d86ad9e1527
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3966482
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This allows resetting an Event without waiting on it. Windows already
had this functionality in its EventExt, and we can provide an equivalent
implementation for eventfd on Linux, so promote this function to the
cross-platform Event type.
BUG=b:231344063
TEST=tools/presubmit --all
Change-Id: I6dba3cb2e0b2d702e8a3f0dacf5c25c1dd044a13
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3966480
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
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>
The loop that generates the CPU affinity mask uses a shift by the CPU
index to generate a u64, so if the shift count is 64 or greater, it will
shift past the end of the u64 and panic when overflow checks are enabled
(which we enable by default in release builds in Cargo.toml).
Add a bounds check so set_cpu_affinity() will return an error rather
than causing a panic in this case.
BUG=None
TEST=run tests via wine on 72 logical core machine
Change-Id: I2ac4a0602b2c014aeca4939ec2882926cdfe2c29
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935523
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
When we detect a VCPU stall we propagate the watchdog reboot error code
to the event tube. The newly added error code WATCHDOG_REBOOT = 36 is
returned from the crovm process.
Bug: 245900797
Test: manual testing, build and Virtualization apk on a device
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Change-Id: Ib1ce97de911784b33d130d40536be26813edc3d7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936647
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The path does not belong to crosvm and should not, for example, be
revealed to UnlinkUnixSeqpacketListener which would try to remove it.
TEST=cargo test, added a new unit test
BUG=b:251742702
Change-Id: I6e81623b76d62961c774010e1dafcf73ffca6471
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3941684
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
The platform event types are now private, and their methods are exposed
through the base Event type, so remove that comment that triggers a
warning with `cargo doc`.
TEST=`cargo doc` does not warn about this line.
Change-Id: I4577a194582dddaa2536541247807fc4cd1eea06
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932438
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This isn't necessary, but it does aid readbility in my opinion.
BUG=b:231344063
TEST=cargo build && ./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64 --build-only
Change-Id: Id486d66773a15f1a544f717aab508d5006be3553
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864026
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
The existing file descriptor must refer to a listening socket.
TEST=cargo test, added a new unit test
BUG=b:238931628
Change-Id: Ia6bd5d6d30af69fb4b5fa00865f5528f19f569d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932714
Commit-Queue: Keir Fraser <keirf@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Make it official that setting a Timer's interval to 0 is the same as
setting it to None, meaning it will not be periodic. Fixed the windows
timer to behave this way again, and updated Timer docstring.
Also updated APIC timer to use None for interval which is clearer.
Bug: b:248612697
Test: tested with UserspaceIrqChip in dynamic tick mode
Change-Id: I57713c3ace345a8c64b9219a8e60f36c54a9481c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925006
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
An existing file descriptor is specified by a path of the form
/proc/self/fd/<fd>. In this case crosvm will use this existing
listener socket directly, rather than trying to create a fresh one at
the specified path location.
This is useful for sandboxing crosvm in an environment in which it is
unable to create new filesystem entries.
BUG=b:238931628
TEST=Tested downstream
Change-Id: Ic6b24196bbe01960aedfe3f00ec69fd799e6ba91
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928022
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
Windows' SetWaitableTimer function takes a period argument that is in
milliseconds. If it's set to 0 then the timer will not be periodic. If
the reset function is called with a period that is <1ms but not None, we
should set the period to 1ms which is the best we can do.
Bug: b:248612697
Test: ran kernel with HZ=1000 on Windows, verified PIT works
Change-Id: Ie908205a455c818bad5b246da54b504eb9ce7b27
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926198
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
This feature is only available on ChromeOS and should live in
the downstream ChromeOS repository.
Note: This change should be reverted with the next ChromeOS merge.
BUG=b:244618505
TEST=None
Change-Id: I33d4e6c5feb4178ebf7cd946ea654dbd20291653
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3907532
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Virglrenderer must not unmap from any thread other than the virtio-gpu
thread because virglrenderer is not thread-safe and EGL requires that
only one thread own a context concurrently.
For the VirglRenderer RutabagaComponent, we can unmap directly from the
virtio-gpu thread. In fact, we can greatly simplify the use of
ExternalMapping if we eliminate the associated map/unmap callbacks for
all RutabagaComponents.
Now VirtioGpu is responsible for ensuring that the map/unmap occurs and
is registered/unregistered. Also, the shared `map_request:
Arc<Mutex<ExternalMapping>>` spanning the KVM and virtio-gpu threads is
no longer necessary.
BUG=b:244626679
TEST=OpenGL and Vulkan gameplay with sandboxing disabled
TEST=OpenGL and Vulkan gameplay on ChromeOS with sandboxing
Change-Id: I4acaf4aabff3891536ca0439221cfbd021dba123
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3888602
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
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>
Remove the _bytes_read variable, since it is not needed. It was also
misnamed since we are writing, not reading, data.
Fixes a Rust 1.62 clippy lint:
error: this let-binding has unit value
BUG=b:243677117
TEST=tools/clippy # with Rust 1.62
Change-Id: I53f7b675f8e95c94ab127e500127a9153166a906
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3854968
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Behavior should be exactly the same.
- Use `CpuSet::new()` directly instead of duplicating its code
- Use the `syscall!()` macro for error handling
TEST=./tools/presubmit
BUG=None
Change-Id: I371e9a113914db7ffdecbf4bf8770be157368569
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858174
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Christian Blichmann <cblichmann@google.com>
Reviewed-by: Christian Blichmann <cblichmann@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
If we can't create a PlatformSyslog instance (for example, if /dev/log
is not available on a minimal Linux system without a traditional init),
warn the user and continue executing instead of failing.
BUG=b:242103548
TEST=Run crosvm inside minimal VM with no init
Change-Id: I4d81da396125331ef7ad335e57b37645b6546980
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842814
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Ensure that openlog_and_get_socket() is only called once by storing its
result in a OnceCell. This fixes logging initialization when the syslog
State structure was constructed more than once, causing the log fd to be
invalidated and breaking sandboxed startup.
BUG=b:242103548
TEST=Start crosvm on Linux with sandbox enabled (default mode)
Change-Id: I663a7e918b81f4c23415a28cfcc2c72f6b4a51d8
Fixes: 7dbdc73063 ("base & src: allow multiple log inits.")
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842813
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
With the migration to env_logger, we lost the ability to initialize
logging multiple times. This meant that we had to wait until we had
parsed CLI args and knew exactly what we wanted our logging spec to be,
which meant that it would sometimes be too late to log startup errors.
This CL modifies the logging facade to be modifiable on the fly, albeit
with some restrictions, to obviate the problem.
The syslog API has been modified as follows:
syslog::early_init: initializes stderr logging, can be called only once
per process. Called as the first function in main.
syslog::init/init_with: can be called after early_init to modify the
parameters used by the logging system. Can be called only once per
process. Will be called roughly after argument parsing or bootstrapping
is complete.
The fundamental change to enable this was in the logging facade. Now,
the facade passes all logging operations to a static, mutex protected
struct. This way, the facade never changes, but we can modify the
struct whenever we wish.
BUG=b:242103548
TEST=tested downstream
Change-Id: I76bc1bb275c81a69aadc7f03a80b94c297f47781
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3834294
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Crashes of rust executables have a generic signature since the user
crash collector is not able to compute a reasonable signature for them.
This custom panic hook allows passing a signature derived from PanicInfo
to the crash collector.
BUG=b:234093439
TEST=See crrev.com/c/3834930 and crrev.com/c/3836804
Change-Id: Ida7f655d3a2463e8a42602d8e32588195a0ce36b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842808
Commit-Queue: Paramjit Oberoi <psoberoi@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Paramjit Oberoi <psoberoi@google.com>
This CL migrates Tube from directly using a UnixSeqpacket to instead use
a StreamChannel backed by UnixSeqpackets. This CL also migrates users of
the old Tube::new(UnixSeqpacket) function to its renamed counterpart.
Tests are added for new functionality.
This CL enforces that the StreamChannel used by the Tube is backed by a
UnixSeqpacket because the reading and writing behavior of a UnixStream
is different, and it cannot guarantee the same multi-process
concurrent-writers behavior that a UnixSeqpacket can. This is because
the UnixStream does not send data as packets and the size cannot be
queried, so two underlyig writes are required for each Tube write: one
to send a header indicating message size, and one for the actual content
of the sent data. These can be interleaved during concurrent writes,
causing corruption of the Tube's data.
This CL makes the Windows and Unix API closer to each other, with some
differences remaining or added, including Tube::new_from_unix_seqpacket
existing in Unix but necessarily not Windows.
This migration (Tube from UnixSeqpacket to Stream) is intended to move
the Unix Tube API closer to the Windows API, with the eventual goal of
creating a platform-agnostic API for Tube.
Bug: b:231641496
Change-Id: I2422e76b7efa5a20bc40a8d194f5f8390dc71438
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3818253
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
This CL is one of two CLs in a series that migrate the Unix Tube from
using UnixSeqpackets directly to instead use StreamChannels backed by
UnixSeqpackets. This CL adds some pass-through functions to
StreamChannel that are needed by Tube in the follow-up CL, as well as
a new function to create a StreamChannel directly from a UnixSeqpacket.
Additionally, a test is added for the new constructor-like function.
This migration (Tube from UnixSeqpacket to Stream) is intended to move
the Unix Tube API closer to the Windows API, with the eventual goal of
creating a platform-agnostic API for Tube.
Bug: b:231641496
Change-Id: I8d7da6a0e64d38d8f9833ae8e62ec7a2c4cfda5c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3818249
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
The test isn't unix specific anymore, so we ought to move it to
base/src/syslog.rs, however, when moved, it fails with an "Illegal Seek"
error when run in the presubmit (but not in `cargo test`). The cause is
unclear.
BUG=b:228881485
TEST=./tools/dev_container ./tools/presubmit
Change-Id: I76e6595007a3b59f6bbd5a4afae42f911686f3e3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3817974
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Frederick Mayle <fmayle@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
This CL adds tests for Unix Tube: a test for the platform-specific
Tube::new function, and a serialization/deserialization test that
existed previously in Windows and now is shared between platforms.
Bug: b:231641496
Change-Id: Iabbc15f847b995affd0bfd5b304fd70d34b171b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3794509
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>