File tree Expand file tree Collapse file tree
base/cvd/cuttlefish/host/commands/cvd/cli/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,10 +72,26 @@ Result<void> CvdDeviceRestartCommandHandler::Handle(
7272 std::vector<std::string> subcmd_args = request.SubcommandArguments ();
7373 CF_EXPECT (ConsumeFlags (options.Flags (), subcmd_args));
7474
75- auto [instance, unused ] =
75+ auto [instance, group ] =
7676 CF_EXPECT (selector::SelectInstance (instance_manager_, request),
7777 " Unable to select an instance" );
7878
79+ const auto & instances = group.Instances ();
80+ if (!instances.empty () && instance.Id () == instances[0 ].Id ()) {
81+ bool other_active = false ;
82+ for (const auto & inst : instances) {
83+ if (inst.Id () != instance.Id () && inst.IsActive ()) {
84+ other_active = true ;
85+ break ;
86+ }
87+ }
88+ CF_EXPECTF (
89+ !other_active,
90+ " Restarting the first instance (ID: {}) is not allowed "
91+ " while other instances are running. Restart the entire group instead." ,
92+ instance.Id ());
93+ }
94+
7995 CF_EXPECT (
8096 instance.Restart (std::chrono::seconds (options.wait_for_launcher_seconds ),
8197 std::chrono::seconds (options.boot_timeout_seconds )));
You can’t perform that action at this time.
0 commit comments