cvd: Support media devices in multi-instance fleets - #3136
changyeon-jo wants to merge 1 commit into
Conversation
d943d6e to
2e384b6
Compare
2e384b6 to
5262fa5
Compare
bridadan
left a comment
There was a problem hiding this comment.
Other than my one question everything LGTM
| flag += ":lens_facing=" + device.lens_facing(); | ||
| } | ||
| if (cfg.instances().size() > 1) { | ||
| flag += ":instance=" + std::to_string(i); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
InstancesMediaproto tolaunch_cvd.proto(per-instance lists of the sameMediaDeviceshape asload_config.proto), with--media_binproto/--media_textprotoflags, the same way--displays_binproto/--displays_textprotowork. - The JSON parser emits
--media_binproto, which lifts the single-instance restriction. The JSON schema doesn't change. - Plain
--mediareturns an error whennum_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
5262fa5 to
af18290
Compare
Summary
Adds support for media devices in multi-instance fleets launched via
cvd create --config_file=.... Previously, anymediablock in a multi-instance config was rejected (TODO(b/520098369)).cf_media_configs.cppnow 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--mediaflag when the fleet has more than one instance.instanceproperty to--media/MediaConfig.assemble_cvd/flags.ccassigns media configs only to the instance matchingconfig.instance_index.host/libs/config/media.cppenforces non-emptyinput_pathandinput_fpsviaCF_EXPECT(review feedback from vhost_user_media: Worker POLLHUP handling and shmem_unmap fix #3121).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)