This code is unused and untested, while simultaneously making the rest
of the virtio device code more complex. Remove it.
BUG=b:276993009
TEST=tools/dev_container tools/presubmit
Change-Id: I9d44f92419c6912d1735043404d4f64efc95bba4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4676076
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
There is only one implementor right now and it seems unlikely we'll need
to support multiple vhost-user frontend implementations in the future.
Note that there are a few other very similar looking traits like
VhostUserSlaveReqHandler (used for backend implementations) and
VhostUserBackend (also used for backend implementations, but at a
different abstraction level).
The documentation of the traits was moved to the implementations. In
some cases there were redundant docs and so I made a judgement call on
which to keep.
Change-Id: Ib69270160c375c900fd9e3356cb387b78e4983be
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553724
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This abstraction doesn't add much value and makes the `accept` call
dangerous (if `accept` is called after it returns `Some`, then it will
panic).
Change-Id: I0c749fccef582128bb66eb95132103427e2abf58
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4827925
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
The Req trait and related code relied on transmuting arbitrary u32
values into an enum that might not be one of the valid enum branches;
this has always been undefined behavior in Rust, and now it is actually
causing failures at runtime (tests compiled with Rust 1.71.1 in release
mode crash, since the compiler intentionally emits an illegal
instruction for the transmute in a test).
Rework the code so instead of transmuting it first and checking for the
is_valid() function later, we require Req to implement TryFrom<u32> and
make VhostUserMsgHeader::get_code() return a Result so that callers must
check that the code is indeed valid.
Ideally, this code should be refactored so that the VhostUserMsgHeader
is checked once when it is received rather than each time get_code() is
called, but that would be a larger change, so it is left as a potential
future cleanup.
BUG=b:297923761
TEST=cargo test --release -p vmm_vhost # w/rust-toolchain = 1.71.1
TEST=tools/dev_container tools/presubmit
Change-Id: I8d24dd9d81ee107f9ab43ea7bf68145c380364db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4824412
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
0x0002_0000 is now standardized as VHOST_USER_PROTOCOL_F_XEN_MMAP[1].
Renumber SHARED_MEMORY_REGIONS to an available value to avoid
interoperability problems with other vhost-user implementations.
(It would be nice if VHOST_USER_PROTOCOL_F_SHARED_MEMORY was
standardised, to avoid this problem in future!)
[1]: f21e95ee97
TEST=run crosvm vhost-user-gpu device with cross domain
Change-Id: I56c36e5ef75b68fd4244dee1206a2cd1bee7c452
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4727935
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The vmm handler code does not need to check that the queue index is in
range. This is already checked in two places already: the generic
VirtioDevice code will not produce invalid indexes, and the backend
vhost-user device must be prepared to handle invalid indexes by
returning an error.
Removing the max_queue_num parameter will help in cleaning up the
VhostUserVirtioDevice QueueSizes mechanism.
BUG=b:262291811
TEST=tools/presubmit --all
TEST=boot x86_64 Linux from a vhost-user block device
Change-Id: Ia44cb916aedadf0fbdecec8f0bf0d0299cc5816b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4103911
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
- The remaning DataInit are all left due to limitations of the
current stable version of zerocopy
- Only 5 files still use DataInit
- DataInit is marked as deprecated to prevent future introduction
- Other mentions of DataInit across the repository are cleaned up
TEST=CQ
BUG=b:204409584
FIXED=b:204409584
Change-Id: Id7126e58cff63eaa67138de429375382a3ffbc55
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4680289
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
VhostUserMsgHeader is a generic type and requires updated zerocopy
to be able to derive AsBytes. Everything else in this folder is
cleaned up.
TEST=CQ
BUG=b:204409584
Change-Id: Ic86dd577969cb79648898fa3071a262824faeef7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679845
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
This change creates a new type (QueueConfig) that represents a queue
configuration before it has been activated. The QueueConfig::activate
function serves the same purpose as the previous Queue::activate, but
now it also returns the Queue type, which now always represents an
actively running queue.
BUG=b:290268617
TEST=tools/dev_container tools/presubmit
Change-Id: I502ac6b29bf9f0cfc33ef15f6fb7fe482214eafd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4111872
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Previously this effort is blocked by VhostUserInflight having
different type layout (padding) on different bit length archs.
However, unlike i686, armv7 have same data layout and padding
as aarch64 and x86_64, so it's not an issue for our supported
architectures.
bitflags crate is upreved to 2.3.2. New version is already
vendored in cros cargo vet.
TEST=CQ
BUG=b:204409584
Change-Id: I51701550a4cf297dc739344d2895972a9c6f6cc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679841
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The size check didn't seem more useful than a sanity check. This limit
is being removed because new IPC messages for snapshotting will exceed
this limit signficantly.
BUG=b:287515956
TEST=e2e_tests and presubmits
Change-Id: I8246d1ee0e7815d2b1950d1f78a2b93579e59f86
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4646712
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
* Creates a RESTORE message that the vmm sends to the device
* Starts up the worker on the vhost user VMM side if the device is
activated
* Rewires up irqfds and doorbell events (ie. queue_evts)
* Restore vrings on the device process side
* Log error from restoring devices, which will making debugging
e2e_tests easier
Unlike non-vhost user virtio devices, vhost user devices won't have
their queues and fds rewired on "wake". Instead it will happen on
"restore".
BUG=b:280607404
TEST=e2e_tests snapshot_vhost_user pass. presubmits
Change-Id: I0221dff1448e33d8b82bda48a151f94f90c691d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4618095
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
This CL also:
* re-hooked up wake and sleep calls
* Introduce VirtioDevice::is_vhost_user so we can easily branch logic
between vhost user and non-vhost user devices
* Fixed a conflict resolution mistake where "wake" would stop non-queue
workers
BUG=b:280607404
TEST=ran snapshot_vhost_user_root e2e_tests
Change-Id: I5abee92a0445c9575c0775502930ea16ead2fb83
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4607767
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Worker will return a struct used to help restart the Worker
* Extend unit test for sleep and wake
* replace VirtioDevice::stop call with Suspendable::sleep in
VirtioPciDevice
BUG=b:280607609
TEST=e2e_test, presbumits
TEST=with e2e_test, added println! around the code to make sure it works
as expected
Change-Id: I0372f01b70a79693607435d3b6d9e60fb479e3e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4522150
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
* Created IPC message for sleep in vmm_vhost
* Save active virtqueue states in the device process
* Removed unused queues field in Worker
BUG=b:280607608
TEST=presubmits and e2e_test
Change-Id: I18350d8e687e4e46d812679d45b90e54d098abf9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4522139
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
This is a new major version, and requires some code changes.
Change-Id: I294ce3604aad6e6dc5f50e33246b690e883c1e36
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4481294
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
We are down to only 30 `unsafe impl DataInit` across our repo now!
TEST=CQ
BUG=b:204409584
Change-Id: I1b6cf95b2a15eac194f3b464330009fd898a0bfa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4356907
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This will be necessary for the next CL, which introduces a closure that
cannot be make generic. Additionally the handler is used at a low
frequency and this limits the amount of generated code (2 generic
parameter leads to a potential explosion of monomorphized methods).
BUG=b:217480043
TEST=send data between the host and a VM connected to a vhost-user vsock device using socat.
TEST=send data between a VVU vsock device inside a device VM and another guest using socat.
Change-Id: Ie5946772a5f21f2c0dd289875a562abbccff6db4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4222843
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Thie effort is splitted into multiple CLs, to reduce change size
and also make bisecing breakages easier.
TESTED=CQ only
BUG=b:204409584
Change-Id: Ie90f171bd5f74b732df3129e94733f3b34621092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4210751
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
data_model is probably going away in the future, but
until we can release it as pre-release alpha for internal
efforts.
(context: https://fxbug.dev/114169)
BUG=b:173630595
TEST=compile
Change-Id: Ie13ec3ab9083d315c78a035b532132296a8fb651
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082333
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This lint has been renamed (identity_conversion -> useless_conversion),
but the original reason for allowing the lint is gone now, so we can
just remove the line entirely.
BUG=b:260784028
TEST=tools/clippy
Change-Id: If673848eaaa989970d5f18d2e0b3dac3c55abd23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064708
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
When vhost-user front-end send a vhost-user message via Unix domain
socket, a message header is sent first with optional attached files.
Then, a message body is sent as a separate packet if necessary.
However, the existing implementation blocks only before a
message header coming and assumed that the message body is ready when
the header comes. So, there was a race and `handle_request` could return
`EAGAIN`.
This CL splits SlaveReqHandler::handle_request() into recv_header() and
process_message() so a caller can wait between the header and the
additional payload.
On VVU, we shouldn't wait before receiving the payloads because the
proxy device forwards a header and its message body together. So we
check the protocol in needs_wait_for_payload().
BUG=b:237891754
TEST=Run vhost-user block on Linux
TEST=Run vhost-user block on Windows
TEST=Run VVU block on Linux
Change-Id: I35af3eb0e706cb005bf697397698e01e272b0704
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Add a vhost protocol feature flag for shared memory region support. This
is necessary to avoid sending the GET_SHARED_MEMORY_REGIONS message to
backends which don't support it.
BUG=b:252901073
TEST=crosvm device wl
Change-Id: I044926e982526c3c76063b5386cab0db72524707
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3951472
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Remove unused method.
BUG=none
TEST=cargo test --all-features in vmm_vhost for both Linux and Windows
Change-Id: I7fb7fb343f1742c2bea80b4031d43821f7437db6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863048
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Some structs in vmm_vhost have `error` field and expose `set_failed` to
allow callers to invalidate an instance. However, `set_failed` is not
used in crosvm at all. In addition, the `error` field cannot be modified
any private methods in vmm_vhost. This means that the callers can manage
the error states entirely.
So this CL removes the `error` fields and `set_failed` methods to make
it clearer that the callers have responsibilities of error handling.
BUG=none
TEST=cargo test --all-features in vmm_vhost
TEST=cargo test --all-features --target=x86_64-pc-windows-gnu in vmm_vhost
Change-Id: Idf478790a0a75282a4c504456d93604f7369c015
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863046
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Adds a new message that can be used to map GPU memory via Vulkano.
BUG=b:244622199
TEST=presubmit & downstream
Change-Id: I4018cfda7573d4df2d89225060d5d61c8ac5d3d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924935
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Current implementation does not allow hot-resizing feature to be used in
vhost-user block devices because the backend device cannot notify the
frontend that the device configuration has changed. Fix this by adding
and establishing the backend to frontend vhost-user message connection to
the vhost-user block backend, send the HANDLE_CONFIG_CHANGE_MSG to the
frontend, and send interrupt to the guest kernel from the frontend
device when receiving the message.
BUG=b:191845881
TEST=cargo run devices -s /path/to/socket.sock --block ...
cargo run run --vhost-user-blk /path/to/vhost-sock,
cargo run disk resize 0 $SIZE /path/to/socket.sock
Change-Id: Ifab75d65c429dfcea5e632b899f014278a6e6750
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3859218
Commit-Queue: Keita Suzuki <suzukikeita@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Morg <morg@chromium.org>
Current implementation of vhost-user backend devices cannot directly
send vhost-user messages from the backend to the frontend since the
established connection is stored directly to `VhostShmemMapper`. This
limits the messages that could be sent to memory share-related messages.
To overcome this limitation, introduce struct `VhostBackendReqConnection`
which exposes the required backend to frontend requests and keeps track of
the underlying transport (struct `Slave`), and refactor `Slave` out from
current VhostShmemMapper.The state of the connection is managed using enum
`VhostBackendReqConnectionState`.
This patch also moves the timing of when `BackendReqHandler` is created in
the frontend to when `VhostUserProtocolFeatures::SLAVE_REQ` is negotiated
when creating VhostUserHandler.
BUG=b:191845881
TEST=run ./tools/run_tests
Change-Id: I90235a527d58067f73a509907b4cefc09516f562
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3856036
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Brings up the master request handler on Windows. To stay within the
existing protocol, PackedTube was introduced, which is able to transmit
a Tube via a RawDescriptor.
BUG=b:221882601
TEST=presubmit & cargo test & tested downstream
Change-Id: Ibd4c2f55c42738392beed5b15b8d445e47890627
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3856828
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Since specifying module with absolute paths (`crate::`) is preferred over
relative path (`super::`), replace all of them except `super::*` in
`tests` modules.
BUG=none
TEST=cargo test --all-features in vmm_vhost
Change-Id: I90d4906c02505395358c8722bcbb7d0bb3024733
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863044
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Make tools/health-check cover third_party/vmm_vhost, as we are
maintaining vmm_vhost by ourselves and we don't pull the upstream
changes so frequently unlike other third_party components.
This CL includes:
* updates in scripts under /tools, and
* the auto-gerated changes by `./tools/fmt --nightly`
BUG=b:239937122
TEST=cargo check
Change-Id: I12956a60bb24764ffb541261c7fb3f09eb974dd8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863043
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
The existing flags assume unix libc read = 1, write = 2. On Windows we
have read = 4, write = 2. We can implement the conversion between
base::Protection and VhostUserShmemMapMsgFlags to keep the protocol
itself separate from the platform flags.
BUG=b:221882601
TEST=presubmit & tested downstream
Change-Id: I6fe69df679926b240f7d02dfbbf0704bbca5a5b0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3860646
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Tested-by: Idan Raiter <idanr@google.com>
The `buf_lens` vector was created only to be destroyed in the next line.
Just use `sum()` on the buf iterator.
BUG=None
TEST=tools/presubmit --all
Change-Id: Iddfa4f783b6eda326b9dbb9c6a1f443b7976ca2c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858688
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Ran clippy with features that are enabled downstream. Those features
will be enabled upstream in later cls when crosvm starts building.
BUG=b:213146388
TEST=presubmit
Change-Id: I67cb74127a349b572e573c350d69d1611533d961
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3793690
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
Support backend request channels (i.e. slave_req_fd) with vvu. The
backend channel is proxied with the same virtqueue as the frontend
channel, so this requires muxing and demuxing the messages in the proxy
and device handler respectively. Supporting this in the device handler
requires making the backend channel a vmm_vhost Endpoint rather than a
plain File, to allow the platform-specific Connection to construct the
proper Endpoint.
BUG=b:201745804
TEST=launch sibling VM on manatee
Change-Id: Ibada1764fc74ed759f59fc5f483bb17e1b269abd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765017
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
A listener is responsible for managing and cleaning up its own
resources, but this can cause problems when jailing device processes.
Typically, the listener is created in the parent thread and then passed
to the device thread so the device thread does not require the
capabilities to allocate the listener's resources. However, when cleanup
time comes, the listener in the child is still responsible for
destroying the resources created by the parent, which may require extra
capabilities. For instance, for a vhost-user socket the listener is
expected to remove the socket file, but we don't necessarily want the
child to be able to remove files from the filesystem...
Fix this by adding a new method, take_parent_process_resources(), that
can be called prior to creating the child process by the parent in order
to obtain the resources that the parent needs to cleanup when the child
process exits. The resources are presented in the form of an opaque box
and must be kept by the parent until the child process exits. After
that, dropping the box will free the resources that we don't want the
child to clean up.
If we are not creating a child process, then the method is simply not
called and the listener will cleanup the resources itself.
BUG=b:218223240
TEST=vhost-user console device gets properly cleaned up.
Change-Id: I7b8c4b700a868f4fd100c45f0e577fddfe8bb216
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762972
Reviewed-by: Morg <morg@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Add support for shared memory regions to vhost-user. This is adding
support for a front-end message to query for necessary shared memory
regions plus back-end message to support mapping/unmapping files from
the shared memory region.
go/vvu-shared-memory
BUG=b:201745804
TEST=compiles
Change-Id: I35c5d260ee09175b68f6778b81883e0070ee0265
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716344
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Make Listener type depend on Endpoint, instead of Endpoint type
depending on Listener. This will allow Endpoints to be used for the
slave_req_fd.
BUG=b:201745804
TEST=compiles
Change-Id: I1a0732bf7477a4e768f348f78e352a3b53607633
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716342
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
The existing code confuses the length of the request with the length of
the reply in recv_reply_with_payload. This makes it impossible to use
for any requests where the reply differs in size. Fix this by
determining payload size after reading the reply header.
BUG=b:201745804
TEST=compiles
Change-Id: Iec21918e45b81d299f3178e7893e146cbd4c7db7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716343
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
The run_with_listener() method can now be made generic and be used for
both the socket and VVU handlers.
BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works.
Change-Id: Ic1ae286e573383d6b66c8a406227d6cf51cbd578
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3592633
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>