Skip to content

cvd: Pass lens_facing to v4l2_stream_proxy and support single-media fleets - #3136

Open
changyeon-jo wants to merge 2 commits into
google:mainfrom
changyeon-jo:cvd_multi_instance_media
Open

cvd: Pass lens_facing to v4l2_stream_proxy and support single-media fleets#3136
changyeon-jo wants to merge 2 commits into
google:mainfrom
changyeon-jo:cvd_multi_instance_media

Conversation

@changyeon-jo

@changyeon-jo changyeon-jo commented Sep 3, 2026

Copy link
Copy Markdown

Summary

This PR adds multi-instance fleet configuration support for media devices, routes media configurations to specific targeted instances, and passes lens_facing to v4l2_stream_proxy. It is split into two commits:

  1. Commit 1 (run_cvd: Pass lens_facing to v4l2_stream_proxy on launch):

    • Updates run_cvd/launch/vhost_user_media_devices.cpp to pass config.lens_facing to v4l2_stream_proxy on startup, wiring up the driver option added in vhost_user_media: Add lens facing control, worker POLLHUP handling, and shmem_unmap fix #3121.
    • Adds unit test FlagsParserTest.ParseMediaV4l2StreamProxy in flags_parser_test.cc verifying that single-instance v4l2_stream_proxy configurations with lens_facing (e.g. BACK) are correctly parsed and serialized into --media flags.
  2. Commit 2 (cvd: Support single-media fleets and route configs to targeted instances):

    • Per-Instance Targeting: Adds instance property to --media flags and MediaConfig, allowing media devices to target a specific instance index in multi-device fleets without making assumptions about device types.
    • Config Serialization: Updates cf_media_configs.cpp to allow multi-instance fleets where a single instance has media configured (has_media_count <= 1), and serializes the target instance index (:instance=<i>) when launching fleets (cfg.instances().size() > 1).
    • Centralized Validation: Enforces non-empty string validation for input_path and input_fps via CF_EXPECT in host/libs/config/media.cpp (addressing review feedback from vhost_user_media: Add lens facing control, worker POLLHUP handling, and shmem_unmap fix #3121).
    • Assembly: Updates assemble_cvd/flags.cc to assign media configs only to the targeted instance matching config.instance_index.
    • Unit Tests: Adds multi-instance unit tests in flags_parser_test.cc:
      • ParseMediaMultiInstanceSingleMedia: verifies multi-instance single-media fleet JSON parsing targeting instance 1.
      • ParseMediaMultiInstanceFirstInstanceMedia: verifies multi-instance single-media fleet JSON parsing targeting instance 0.
      • ParseMediaMultiInstanceMultipleMediaFails: verifies boundary check that multiple media instances in a fleet are rejected.

Follow-up to / spun off from: #3121
Bug: b/520098369

Testing

  • bazel test //cuttlefish/host/commands/cvd/cli/parser:flags_parser_test (Passed, 35/35 tests across both test suites)
  • bazel build //cuttlefish/host/commands/assemble_cvd:assemble_cvd //cuttlefish/host/commands/run_cvd:run_cvd (Passed)

@changyeon-jo
changyeon-jo force-pushed the cvd_multi_instance_media branch from d943d6e to 2e384b6 Compare September 3, 2026 21:56
@changyeon-jo changyeon-jo changed the title cvd: Support single-media fleets and pass lens_facing to v4l2_stream_proxy cvd: Pass lens_facing to v4l2_stream_proxy and support single-media fleets Sep 3, 2026
- Pass the configured lens_facing string (e.g. FRONT, BACK, EXTERNAL)
  from MediaConfig to the v4l2_stream_proxy process on startup, matching
  the behavior of emulated_camera_mplane and emulated_camera_splane.
- Add FlagsParserTest.ParseMediaV4l2StreamProxy verifying that
  v4l2_stream_proxy configurations including lens_facing are parsed
  and serialized into --media flags correctly.
- Add 'instance' property to --media flags and MediaConfig, allowing
  media devices to target a specific instance index in multi-device fleets.
- Update cf_media_configs.cpp to allow multi-instance fleets where a
  single instance has media configured (has_media_count <= 1), and serialize
  the target instance index (:instance=<i>) when launching fleets.
- Update media.cpp to validate that input_path and input_fps are not empty.
- Update assemble_cvd/flags.cc to assign media configs only to the targeted
  instance matching config.instance_index.
- Add unit tests in flags_parser_test.cc verifying multi-instance single-media
  fleet JSON parsing (targeting instance 1 and instance 0) and rejecting
  multiple media instances in a fleet.

Bug: b/520098369
@changyeon-jo
changyeon-jo force-pushed the cvd_multi_instance_media branch from 2e384b6 to 5262fa5 Compare September 3, 2026 22:01
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.

2 participants