Skip to content

vhost_user_media: Worker POLLHUP handling and shmem_unmap fix - #3121

Merged
ser-io merged 3 commits into
google:mainfrom
changyeon-jo:cvd_fleet_camera_options
Sep 24, 2026
Merged

ser-io merged 3 commits into
google:mainfrom
changyeon-jo:cvd_fleet_camera_options

Conversation

@changyeon-jo

@changyeon-jo changyeon-jo commented Aug 30, 2026 •

Copy link
Copy Markdown

Summary

This PR contains standalone fixes and cleanup for vhost_user_media drivers:

  1. Baseline Formatting (Commit 1):

    • Runs cargo fmt on the baseline v4l2_stream_proxy crate so subsequent functional changes remain strictly scoped and free of cosmetic noise.
  2. Shmem Unmap Message len (Commit 2):

    • Sets len to 0 in VhostUserMMap for shmem_unmap in vhu_media/src/lib.rs, with an explanatory comment noting that the frontend (crosvm) removes mappings keyed solely by shm_offset and does not read len.
  3. POLLHUP Handling in Worker Loop (Commit 3):

    • Handles POLLHUP alongside POLLIN in v4l2_stream_proxy/src/worker.rs when polling the video stream FIFO. When a FIFO writer disconnects and the buffer is drained, Linux poll() reports only POLLHUP (without POLLIN). Handling POLLHUP triggers read(), consuming remaining bytes and receiving Ok(0) (EOF) to cleanly transition to WorkerState::Unopened rather than spinning in a 100% CPU poll busy-loop.

Testing

  • bazel test //cuttlefish/host/commands/vhost_user_media/... (Passed)

@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch 7 times, most recently from f947e43 to 0025092 Compare September 1, 2026 17:50

@bridadan bridadan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes! I think the final commit adding multi-instance support could be its own PR, the commits proceeding it are nice standalone fixes that I'd like to see merged.

Comment thread base/cvd/cuttlefish/host/commands/cvd/cli/parser/instance/cf_media_configs.cpp Outdated
Comment thread base/cvd/cuttlefish/host/commands/assemble_cvd/flags.cc Outdated
@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from 0025092 to 1da0933 Compare September 3, 2026 21:45
@changyeon-jo changyeon-jo changed the title Support v4l2_stream_proxy options and fleet launching with media devices vhost_user_media: Add lens facing control, worker POLLHUP handling, and shmem_unmap fix Sep 3, 2026
@changyeon-jo

Copy link
Copy Markdown
Author

Thanks @bridadan! I've updated this PR to only contain the 4 standalone driver and vhost-user fixes. I'll open a separate follow-up PR for the multi-instance fleet configuration and validation changes.

@changyeon-jo

Copy link
Copy Markdown
Author

Thanks for the fixes! I think the final commit adding multi-instance support could be its own PR, the commits proceeding it are nice standalone fixes that I'd like to see merged.

#3136 is created. :)

@bridadan
bridadan requested a review from ser-io September 9, 2026 14:49

@bridadan bridadan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's wait for @ser-io

Comment thread base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs Outdated
@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from 1da0933 to a1fa874 Compare September 10, 2026 20:48
Comment thread base/cvd/cuttlefish/host/commands/vhost_user_media/vhu_media/src/lib.rs Outdated
@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from a1fa874 to 472c349 Compare September 10, 2026 21:39
@changyeon-jo changyeon-jo changed the title vhost_user_media: Add lens facing control, worker POLLHUP handling, and shmem_unmap fix vhost_user_media: Worker POLLHUP handling and shmem_unmap fix Sep 10, 2026
@ser-io

ser-io commented Sep 10, 2026

Copy link
Copy Markdown
Member

Please update the PR summary: #3121 (comment) after your changes.

@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from 472c349 to 8677a45 Compare September 14, 2026 21:16
@ser-io
ser-io enabled auto-merge September 14, 2026 21:20
@changyeon-jo

Copy link
Copy Markdown
Author

Please update the PR summary: #3121 (comment) after your changes.

Missed this comment - summary has been updated.

auto-merge was automatically disabled September 16, 2026 14:35

Head branch was pushed to by a user without write access

@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from b041ed4 to dba29ab Compare September 16, 2026 14:35
@GoogleCuttlefishTesterBot GoogleCuttlefishTesterBot removed the kokoro:run Run e2e tests. label Sep 16, 2026
@ser-io
ser-io disabled auto-merge September 16, 2026 23:14
@ser-io
ser-io added this pull request to the merge queue Sep 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 17, 2026
@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from dba29ab to 6b713ed Compare September 18, 2026 17:46
@changyeon-jo

Copy link
Copy Markdown
Author

@ser-io when you have a moment, could you please add this rebased PR to the merge queue again? Thanks!

@changyeon-jo
changyeon-jo force-pushed the cvd_fleet_camera_options branch from 6b713ed to 8233a0c Compare September 21, 2026 20:58
@changyeon-jo

Copy link
Copy Markdown
Author

@ser-io I've rebased the branch onto the latest main. Could you please let me know why the previous merge queue attempts failed to merge, and whether there is any action I should take on my end?

@ser-io
ser-io enabled auto-merge September 22, 2026 14:37
@ser-io ser-io added the kokoro:run Run e2e tests. label Sep 22, 2026
@GoogleCuttlefishTesterBot GoogleCuttlefishTesterBot removed the kokoro:run Run e2e tests. label Sep 22, 2026
@ser-io ser-io added the kokoro:run Run e2e tests. label Sep 23, 2026
@GoogleCuttlefishTesterBot GoogleCuttlefishTesterBot removed the kokoro:run Run e2e tests. label Sep 23, 2026
@ser-io
ser-io disabled auto-merge September 23, 2026 21:42
@ser-io
ser-io added this pull request to the merge queue Sep 23, 2026
@ser-io
ser-io removed this pull request from the merge queue due to a manual request Sep 23, 2026
@ser-io
ser-io added this pull request to the merge queue Sep 24, 2026
@cjreynol
cjreynol removed this pull request from the merge queue due to a manual request Sep 24, 2026
The frontend (crosvm) removes shared memory mappings keyed solely by
shm_offset, and `len` is not used. Set len to 0 with an explanatory
comment.
When a FIFO writer disconnects and the buffer is drained, Linux poll()
reports only POLLHUP (without POLLIN). Handling POLLHUP ensures read()
is invoked, which consumes any remaining bytes and returns Ok(0) (EOF).
This cleanly transitions the worker to WorkerState::Unopened rather than
spinning in a 100% CPU poll busy-loop.
@ser-io
ser-io force-pushed the cvd_fleet_camera_options branch 2 times, most recently from 8233a0c to 9b6c65a Compare September 24, 2026 13:31
@ser-io ser-io added the kokoro:run Run e2e tests. label Sep 24, 2026
@ser-io
ser-io enabled auto-merge September 24, 2026 13:32
@GoogleCuttlefishTesterBot GoogleCuttlefishTesterBot removed the kokoro:run Run e2e tests. label Sep 24, 2026
@ser-io
ser-io disabled auto-merge September 24, 2026 15:12
@ser-io
ser-io added this pull request to the merge queue Sep 24, 2026
Merged via the queue into google:main with commit ea0f180 Sep 24, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants