Skip to content

cvd: Support media devices in multi-instance fleets - #3136

Open
changyeon-jo wants to merge 1 commit into
google:mainfrom
changyeon-jo:cvd_multi_instance_media
Open

changyeon-jo wants to merge 1 commit 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

Adds support for media devices in multi-instance fleets launched via cvd create --config_file=.... Previously, any media block in a multi-instance config was rejected (TODO(b/520098369)).

  • Single-media fleets: cf_media_configs.cpp now allows multi-instance fleets where at most one instance has media configured (has_media_count <= 1), and serializes the target instance index (:instance=<i>) into the --media flag when the fleet has more than one instance.
  • Per-instance routing: Adds an instance property to --media / MediaConfig. assemble_cvd/flags.cc assigns media configs only to the instance matching config.instance_index.
  • Validation: host/libs/config/media.cpp enforces non-empty input_path and input_fps via CF_EXPECT (review feedback from vhost_user_media: Worker POLLHUP handling and shmem_unmap fix #3121).
  • Unit tests (flags_parser_test.cc):
    • ParseMediaMultiInstanceSingleMedia: media on instance 1.
    • ParseMediaMultiInstanceFirstInstanceMedia: media on instance 0.
    • ParseMediaMultiInstanceMultipleMediaFails: more than one instance with media is rejected.

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

Testing

  • bazel test //cuttlefish/host/commands/cvd/cli/parser:flags_parser_test (Passed)
  • 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
@changyeon-jo
changyeon-jo force-pushed the cvd_multi_instance_media branch from 2e384b6 to 5262fa5 Compare September 3, 2026 22:01

@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.

Other than my one question everything LGTM

flag += ":lens_facing=" + device.lens_facing();
}
if (cfg.instances().size() > 1) {
flag += ":instance=" + std::to_string(i);

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.

For existing devices or configuration options, is this how they handle addressing which instance the value applies to when specified using CLI flags? Is there a precedent for this? @ser-io

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good question. I didn't find any precedent for addressing individual instances inside a repeatable flag. I'd like to move this PR to the pattern displays already use:

  • Add an InstancesMedia proto to launch_cvd.proto (per-instance lists of the same MediaDevice shape as load_config.proto), with --media_binproto/--media_textproto flags, the same way --displays_binproto/--displays_textproto work.
  • The JSON parser emits --media_binproto, which lifts the single-instance restriction. The JSON schema doesn't change.
  • Plain --media returns an error when num_instances > 1. Today it copies the same devices to every instance, so two instances read from one FIFO or share one /dev/videoN. It's also an error to combine it with --media_*proto.
  • :instance=<i> goes away.

One open question for @ser-io @bridadan: do you know of any users or CI that launch multi-instance fleets with --media today? The new error would break them. If there are some, the fallback is to keep duplicating emulated cameras and only reject FIFO- and device-backed types.

- 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 5262fa5 to af18290 Compare September 26, 2026 18:08
@changyeon-jo changyeon-jo changed the title cvd: Pass lens_facing to v4l2_stream_proxy and support single-media fleets cvd: Support media devices in multi-instance fleets Sep 26, 2026

This branch has not been deployed

No deployments
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.

3 participants