The vmm_vhost::Connection type is now used consistently to represent a
vhost-user connection in the places that previously used a SystemStream
(which is either UnixStream or Tube depending on the platform).
This cleans up the vmm_vhost public API and also keeps more of the
internal vhost-user implementation encapsulated inside the vmm_vhost
library.
The conversion to Connection for unix has also been improved to
propagate the error via TryFrom instead of From, resolving a TODO
comment.
Change-Id: Ib02d300a04304242f7be7e1661c0213c25c7a4f1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5874103
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This reverts commit 2744e5fef6.
Reason for revert: This cmd line param is no longer being used
BUG=b:364906315
Original change's description:
> gpu: Add parameter for a custom cursor file
>
> This will be used to display a custom mouse cursor for Surfaces. This CL
> won't change any functionality
>
> BUG=b:362814745
> TEST=builds and presubmits
>
> Change-Id: If4e5a41bdaa92fecf680aa09fe8e2ca154946d07
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5825087
> Reviewed-by: Noah Gold <nkgold@google.com>
> Commit-Queue: Richard Zhang <rizhang@google.com>
> Reviewed-by: Pujun Lun <lunpujun@google.com>
Bug: b:362814745
Change-Id: Ib975f92e96e3adb07e1fa27d1a5e6c870e76881a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5876365
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Make base::max_open_files() return the rlimit64 struct intead of
its rlim_max field.
This will be helpful when changing the soft limit in the following
CL.
BUG=b:329359333
TEST=presubmit
Change-Id: I2738c325f4f1ed19ae021e0b8a50a6a1592c5592
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5872162
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Most callers don't want this functionality, and the ones that do can
easily handle it themselves.
Change-Id: I93cf7fe0237428256b10ff72e87cfd888d5fdd1d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5871724
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The VhostUserListener new() and new_socket() are identical; replace all
of them with new(). The "socket" name was left over from the VVU
cleanup; in the current code, VhostUserListener always listens on a unix
domain socket.
Change-Id: I51b1beeb1c17431e08708e70dc252b78c77e747d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5871723
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Iterate over the Vec of display_ids directly, rather than converting
them into a BTreeSet first, and use a regular `for` loop rather than
`try_for_each()`.
Additionally, the `scanouts.get_mut()` looked up the scanout once, then
the `scanouts.remove()` looked it up again; `remove()` returns the
removed item, so the `get_mut()` lookup can be avoided entirely.
Also avoids a clippy manual_inspect lint in Rust 1.81.
BUG=b:365852007
Change-Id: If0bf16c0d886315a8d81bcb072ff873dd132e062
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5852612
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
The VhostUserStream is set to non_blocking before running handler now.
However, the VhostUserStream is created from connection sockets, so it
does not call accept and handle error. This CL removes the line setting
VhostUserSteam to non_blocking.
Also, this CL fixes several incorrect comments.
BUG=b:365458565
TEST=run manual test
Change-Id: I7803fc4c277559f98be4f0bd93b2bb77564ef93c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5838947
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
The recent changes to make crosvm lock nested disk files is running
afoul of Android Virtualization Framework's SELinux policies. The file
locking doesn't add much value in that environement because all the
shared files are read-only, so add an opt-out for locking to buy us time
to re-engineer the policies.
BUG=b:330911976
Change-Id: I0b35732978e946a2331507d6061729d53955a8d3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5849284
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Some doc comments were being incorrectly interpreted due to missing
indentation (for intentional line contintuations) or line breaks (for
new lines that were intended to be separate paragraphs).
Clippy warns about these as of Rust 1.80:
<https://rust-lang.github.io/rust-clippy/master/index.html#/doc_lazy_continuation>
Fix them along with some other nearby minor formatting cleanups.
TEST=tools/cargo-doc
TEST=tools/clippy # with rust-toolchain 1.80
Change-Id: Ice0b7cc3bd75d9ab08c10107a13f95ca9f87a0a3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5758934
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The disk crate is now responsible for opening the file and handling
options like OVERLAPPED and O_DIRECT.
O_DIRECT is now applied to all nested disk files. For now, OVERLAPPED
contiues to only apply to the root disk file.
BUG=b:330911976
BUG=b:190435784
Change-Id: Ib46a965c0589bf1c1e8e4ae5f0c81747530eff98
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5842394
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
flock is called on the root disk file to make sure nothing is
concurrently modifying a disk (which would appear to the guest as disk
corruption). This CL extends that functionality to all of the nested
files of composite and qcow2 disks.
BUG=b:330911976
Change-Id: I4489222943c3530255ffc52aba5a11aa4bc82f9a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5840920
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
No behavior difference intended. This is prep work to treat nested
DiskFiles consistently, e.g. using flock for them.
BUG=b:330911976
Change-Id: Id887ca21a9d5d186ba4dc77280c1ce4bfec8b319
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5840918
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Modify Transfer3D::new_2d to accept an offset argument, ensuring
it is correctly initialized.
This change ensures the offset is no longer ignored during 2D
transfers to the host, hence it addresses potential issues
that could arise with data transfer alignment.
Change-Id: I83a7436e825e1fa6e44fb46d921dd84a799baa93
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/5785895
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
(cherry picked from commit a3ec3b77dbcfa44defd91775c6ecfc5af605d42c)
Reason for cherry-pick: CL was initially merged to `chromeos` branch by
mistake; never made it to `main` branch.
BUG=None
Test=builds
Change-Id: Ic7f720e59c6f43b3477e891f6da91acc23cde0fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5838083
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Waiting on a `WaitContext` isn't enough, the timer must be ack'd. This
technically isn't needed on Windows, but that is an implementaiton
detail and also people often copy existing usages of APIs and might not
realize this detail.
Change-Id: Ic29151b4871bebacd14c19c6dcb9e35779175c79
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5825225
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Use the `mark_waited` method (non-blocking) instead of `wait`
(blocking).
It is technically possible for a vCPU thread to disable a timer after it
has fired but before the worker successfully calls `wait`. In that case,
the worker would get stuck and be unable process timer events for other
vCPUs and also would be unable to shutdown. I haven't seen this happen
in practice.
Change-Id: I49e18ba525392a08f5dc1e22181876cf6a013173
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5825223
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Sebastian Ene <sebastianene@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
The vhost-user backend currently supports socket creation solely from
UDS paths. To accommodate scenarios requiring the passing of connected
sockets via file descriptors, this change introduces the VhostUserStream
structure implementing VhostUserConnection. The VhostUserStream
constructs directly from a raw file descriptor, dup fd and establishing
a UnixStream for communication.
This change adds a 'fd' option to the vhost-user-fs backend device. This
allows the vhost-user socket to be created either by providing a UDS
path (using the 'socket' option) or by using a raw file descriptor
(using the new 'fd' option).
TEST=tools/dev_container tools/presubmit
BUG=b:361212225
Change-Id: I4912f697b5b9d24c7b0b2281a113047831c844df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5796596
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
CL chromium:5796596 introduces a new mechanism for providing a
vhost-user backend device from a socket file descriptor. This approach
enables the socket to be pre-connected before it is passed.
This CL renames the VhostUserListener trait to VhostUserConnectionTrait
for greater generality supporting chromium:5796596.
BUG=b:361212225
TEST=cargo build
Change-Id: I16baaa7d321d4f617b8663c88544ed87280b39bf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5803224
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
This will be used to display a custom mouse cursor for Surfaces. This CL
won't change any functionality
BUG=b:362814745
TEST=builds and presubmits
Change-Id: If4e5a41bdaa92fecf680aa09fe8e2ca154946d07
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5825087
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Pujun Lun <lunpujun@google.com>
When constructing a Queue from a QueueConfig, require the caller to pass
the corresponding Interrupt, and remove the &Interrupt argument from the
Queue::trigger_interrupt() function. This prevents mismatches of Queue
and Interrupt, especially in the case of a re-activation after a reset
where the old and new Interrupt are not the same.
BUG=b:360926085
Change-Id: I31ad9704d4963e46f7ce1b7b7a43aec1a92e342d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5798666
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Clean up the unnecessary Option<> wrapping the worker thread.
Resolves review comments from https://crrev.com/c/5798107 - no
functional change intended.
Change-Id: Iee3ca099a923da23fe48f10e8a33261180479c85
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5801012
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The WorkerPort takes ownership of the output stream when it is created
in WorkerPort::from_console_port(), so if we stop the worker, we need to
restore the output stream to its original location in ConsolePort.
BUG=b:360926085
Change-Id: I1af5c6edfffc31d620895edb1627e01b9ddf8afe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5801010
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
After stopping all queues in the worker thread, also stop the worker
thread itself so that the Interrupt it contains is dropped.
Previously, the worker thread would hold onto the old (no longer used)
Interrupt instance, even when a new Interrupt was provided by the next
call to activate(). With the change, the worker thread with the old
Interrupt will be cleaned up so the next activate() will cause
ensure_worker_started() to be called again and create a new worker with
the new Interrupt.
BUG=b:360926085
Fixes: 2e277ed5bb ("devices: virtio-console: refactor and consolidate")
Change-Id: Ib57bbb768ab4c211b7e6f408f2c75beee8f08bd8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5798107
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The repeated logic for stopping queues in reset() and virtio_sleep() is
moved into a function so it can be shared.
Change-Id: Ifbab9840293530540d8008b1a677342089e9f393
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5793968
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Require vhost-user backends that implement VhostUserDevice to have a
functional enter_suspended_state() now that all of our devices implement
it.
Also drop the suspended flag in DeviceRequestHandler, since the state of
the device can be derived from the state of the queues.
Change-Id: I8642fdb16c09e18ef0ac3a5da523a71d8fe17b37
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5792080
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
All device backends should implement this.
The only two missing devices (fs and wl) can trivially implement it,
since they have no worker threads aside from the per-queue workers.
Change-Id: Ic7b9f649ff68502212e7f7fd5004f3a05ee0849e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5792079
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Add implementations of snapshot/restore to the two vhost-user device
backends that did not have them yet (fs and wl) - these just return an
error for now, but this allows removing the default implementation
from the VhostUserDevice trait so newly-added devices can't forget to
implement them.
Change-Id: I1137e0b394e7ee51cd46d0b2177625da6cb9d489
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5792078
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This makes it possible to distinguish between the many ProxyDevice
instances.
Previously, the error message did not include the device name:
child device process failed recv: [err]
The new message looks like this:
recv from pcivirtio-console child device process failed: [err]
Change-Id: Ica12de1f3b9927d04a0f7de6177d014949ccca28
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5785310
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This replaces the console backend for the virtio and vhost-user console
devices with a shared implementation.
There is one main worker thread per console device, which handles all
virtio queues for that device, and one thread per port to read from the
input source in a blocking fashion.
BUG=b:354677018
BUG=b:298289666
Change-Id: I376180e26497ed6391a9f49b7d9a5c4d5aafa64f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5739275
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
This allows reusing the same snapshot function as virtio devices, which
provides &mut self.
BUG=b:347782866
Change-Id: I130605d3629253ea4037ebf4e9560ed96be53c19
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5784112
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The vhost-user device frontend was using the default virtio-* name,
which made it easy to confuse with a normal virtio device.
In particular, the snapshot file name uses debug_name() to name the
file, so previously the snapshot for e.g. a vhost-user console device
would be named "pcivirtio-console-0". After this change, a vhost-user
console's snapshot file will be named "pcivu-console-0" instead.
Change-Id: I2d7235af5173877b95152d79b7372c80c3bb64d1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5784414
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Our vhost-user framework now requires opt-in elsewhere for each device,
they need to implement `enter_suspended_state` and advertise the
DEVICE_STATE vhost-user protocol feature, so this change is unlikely to
break anything.
Change-Id: If0848803b57cb77a2748fa4b0ef9a92d2f7f6ce7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5784110
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This makes the vhost-user device backend implementations more similar to
the virtio device backends.
The snapshot format is entirely a backend-specific implementation
detail, so this does not affect vhost-user compatibility with other
devices or frontends.
BUG=b:347782866
Change-Id: I14f6407b4f7c5246b08f5cab85493c65caa2dee2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5777254
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
If the event source descriptor gets a hangup event (for example, for an
input device connected to a socket event source that becomes
disconnected), the input device should stop polling it. Otherwise, the
WaitContext::wait() call in the v_input thread will continually return
the is_hungup event, causing that thread to busy loop forever.
This change removes the input event source from the WaitContext and logs
a warning message in this case. This means there will be no further
input events, but the guest should continue to run normally, and the
input thread will not waste CPU time.
BUG=b:358246547
Change-Id: I3c6f05d072eb60aee531deac14e65bf54c6d6783
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5770547
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
It isn't necessary to convert the names into bytes until the last
moment, and this operation is cheap, since String has a zero-cost
conversion into a byte slice. This simplifies the device setup code.
This also fixes incorrect strings for input devices using the evdev
event source, which previously contained a trailing NUL byte; the virtio
input spec requires that strings do not include a NUL terminator.
Change-Id: I054cc117828e6db989cabbc5890a8aceb09ac26a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5772331
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This replaces the custom SNAPSHOT/RESTORE vhost-user extensions with the
new SET_DEVICE_STATE_FD and CHECK_DEVICE_STATE vhost-user methods.
For now, we keep the custom message types around as a fallback to allow
for a smoother migration for non-crosvm users (there is only one I know
of, so it shouldn't take long).
BUG=b:301269927
Change-Id: Ib3d1d232fdfc92e605c372e778e78d84395704fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5735713
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
To support FUSE_SECURITY_CONTEXT feature, the virtio-fs needs to write
security context passed by guest to /proc/thread-self/attr/fscreate.
This write operation may be invalid for some hosts. If the write
operation failed, guest can not create files/directories in shared
directory.
This CL adds a security_ctx option to virtio-fs. If the option is set
to false, virtio-fs will not enable the FUSE_SECURITY_CONTEXT feature.
The default value is false.
BUG=b:357774649
TEST=run virtio-fs in cuttlefish. Verify file creation in guest
successes.
Change-Id: I51ce965df948c217ab86a6604931c438cd5ee13e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5768058
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
Using #[repr(packed)] alone does not guarantee that the struct fields
will stay in the specified order, and as of a change in Rust 1.80, the
compiler will actually reorder such structs in practice in some cases:
<https://github.com/rust-lang/rust/pull/125360/>
Add "C" to all structs that were previously #[repr(packed)] alone, since
these are all trying to match an externally-defined layout where order
matters. None of these would get reordered in practice today, even with
the Rust 1.80 change, but this ensures they will always stay consistent.
Change-Id: I397fd0bd531a34e0f1726afb830bcd7fcc6a2f05
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5758933
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Vhost-user-fs currently lacks seccomp filter support, which cause
security concerns to put into real usage. This change introduces
virtio-fs device's seccomp policy filter to vhost-user-fs when sandbox
is enabled.
When specified path of socket does not exist for vhost-user device, the
vhost-user device will call socketpair to create a socket. To support
the syscall, the rule allowing socketpair is added to vhost_user.policy.
Also, this CL adds disable-sandbox option for vhost-user-fs-device. The option
is set to false by default, the vhost-user-fs will enter new
mnt/user/pid/net namespace. If the this option is true, the
vhost-user-fs device only create a new mount namespace.
BUG=b:355159487
TEST=run manual tests
TEST=run e2e test in chromium:5746575
Change-Id: I6c18386f690af7b0d2e1550c0b3881d444280a8b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5741356
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
When writeback is enabled, O_APPEND handling is done in kernel so
crosvm's virtiofs device needs to clear the flag when opening a
file. Otherwise, a file may be corrupted because pwrite() ignores
offset for FD with O_APPEND.
This case is already handled in passthrough.rs by update_open_flags(),
but it hasn't covered the case of `create` and `atomic_open` requests.
We should call update_open_flags() to clear O_APPEND for those cases.
In addition, this CL adds tests for checking flags of an FD opened
with atomic_open.
BUG=b:321254986
TEST=download videos and validate the contents
Change-Id: I404b15bf925731141610f5929693117ea2957d72
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5740485
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Add unit tests for FS_IOC_SETPATHXATTR ioctl. Validate handling of valid
and invalid input data. Also, test the path matching and xattr setting
logic.
BUG=b:333641954
TEST=cargo test --package devices --lib -- virtio::fs::passthrough::tests
Change-Id: I753b02fae9e457a02e774f35752d87df0000a693
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5737596
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Add unit tests for FS_IOC_SETPERMISSION ioctl. Validate handling of
valid and invalid input data. Also, test the path matching and
permission setting logic.
BUG=b:333641954
TEST=cargo test --package devices --lib -- virtio::fs::passthrough::tests
Change-Id: Id6f462ab8fcb7b683adddc22363afec84429bfdf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5730457
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Some guests try to reset the device when entering a suspended state.
BUG=b:353650093
Change-Id: I9bff40889b9619a4bae13f1405c27b6e8ede2ae3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5742395
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
There were lots of unwraps in the code. Change the functions to return
results and return errors when possible. Otherwise, expect instead.
BUG=N/A
TEST=presubmit
Change-Id: I218aabefc30e40185eb6855117e85f1ff8bac09a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5704476
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Add snapshot/restore support to vmwdt
Keep track of timer state, if the timer was armed with oneshot mode or
repeating mode, repeating cycle, remaining time, next time interval.
Restore the timer with the correct mode and time.
BUG=b:274145255
TEST=Tested on Pixel Fold. Built virtualizationservice apex and
installed on device. Test was done using Microdroid. Tested by invoking
crosvm located in the virtualizationservice apex. Commands: crosvm
suspend --full SOCKET && crosvm snapshot take PATH SOCKET && crosvm
resume --full SOCKET.
Change-Id: I57385e72d8b7fe7393624d265bb2bed834eeffb9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5619450
Auto-Submit: Elie Kheirallah <khei@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Vmwdt is getting the pid/tid of vCPUs whenever a write happens. Instead,
get the Vcpu PID/TID on VM startup.
BUG=b:274145255
TEST=presubmit
Change-Id: I4f41dd20b807b320b6202d36061b18d4c9aa77df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5703919
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>