Commit 060a170c authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Make "End process" button in task manager force kill Plugin VM

This CL updates the task manager so that the "End process" button will
force kill Plugin VMs, instead of attempting to gracefully shut them
down (which can be done via the shelf context menu).

Bug: 1059152
Change-Id: I407ff4248625f8510e951227ec2ece66948e4c87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087328Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarJulian Watson <juwa@google.com>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748076}
parent d6cd4223
......@@ -158,11 +158,19 @@ void PluginVmManager::RemoveVmStartingObserver(
vm_starting_observers_.RemoveObserver(observer);
}
void PluginVmManager::StopPluginVm(const std::string& name) {
void PluginVmManager::StopPluginVm(const std::string& name, bool force) {
vm_tools::plugin_dispatcher::StopVmRequest request;
request.set_owner_id(owner_id_);
request.set_vm_name_uuid(name);
if (force) {
request.set_stop_mode(
vm_tools::plugin_dispatcher::VmStopMode::VM_STOP_MODE_KILL);
} else {
request.set_stop_mode(
vm_tools::plugin_dispatcher::VmStopMode::VM_STOP_MODE_SHUTDOWN);
}
// TODO(juwa): This may not work if the vm is STARTING|CONTINUING|RESUMING.
chromeos::DBusThreadManager::Get()->GetVmPluginDispatcherClient()->StopVm(
std::move(request), base::DoNothing());
......@@ -469,6 +477,8 @@ void PluginVmManager::StopVmForUninstall() {
vm_tools::plugin_dispatcher::StopVmRequest request;
request.set_owner_id(owner_id_);
request.set_vm_name_uuid(kPluginVmName);
request.set_stop_mode(
vm_tools::plugin_dispatcher::VmStopMode::VM_STOP_MODE_SHUTDOWN);
chromeos::DBusThreadManager::Get()->GetVmPluginDispatcherClient()->StopVm(
std::move(request), base::BindOnce(&PluginVmManager::OnStopVmForUninstall,
......
......@@ -37,7 +37,7 @@ class PluginVmManager : public KeyedService,
// TODO(juwa): Don't allow launch/stop/uninstall to run simultaneously.
void LaunchPluginVm();
void StopPluginVm(const std::string& name);
void StopPluginVm(const std::string& name, bool force);
void UninstallPluginVm();
// Seneschal server handle to use for path sharing.
......
......@@ -153,7 +153,7 @@ TEST_F(PluginVmManagerTest, LaunchPluginVmShowAndStop) {
EXPECT_FALSE(SeneschalClient().share_path_called());
EXPECT_EQ(plugin_vm_manager_->seneschal_server_handle(), 0ul);
plugin_vm_manager_->StopPluginVm(kPluginVmName);
plugin_vm_manager_->StopPluginVm(kPluginVmName, /*force=*/true);
task_environment_.RunUntilIdle();
EXPECT_TRUE(VmPluginDispatcherClient().stop_vm_called());
......
......@@ -27,7 +27,7 @@ void PluginVmProcessTask::Kill() {
plugin_vm::PluginVmManager::GetForProfile(
ProfileManager::GetActiveUserProfile());
if (plugin_vm_manager)
plugin_vm_manager->StopPluginVm(vm_name_);
plugin_vm_manager->StopPluginVm(vm_name_, /*force=*/true);
}
Task::Type PluginVmProcessTask::GetType() const {
......
......@@ -119,7 +119,7 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) {
crostini::kCrostiniDefaultVmName, base::DoNothing());
} else if (app_id() == plugin_vm::kPluginVmAppId) {
plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm(
plugin_vm::kPluginVmName);
plugin_vm::kPluginVmName, /*force=*/false);
} else {
LOG(ERROR) << "App " << app_id()
<< " should not have a stop app command.";
......
......@@ -34,7 +34,7 @@ void InternalAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name,
apps::BuiltInAppName::kPluginVm);
plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm(
plugin_vm::kPluginVmName);
plugin_vm::kPluginVmName, /*force=*/false);
return;
}
app_list::AppContextMenu::ExecuteCommand(command_id, event_flags);
......
......@@ -140,7 +140,7 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id,
->StopVm(crostini::kCrostiniDefaultVmName, base::DoNothing());
} else if (item().id.app_id == plugin_vm::kPluginVmAppId) {
plugin_vm::PluginVmManager::GetForProfile(controller()->profile())
->StopPluginVm(plugin_vm::kPluginVmName);
->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
} else {
LOG(ERROR) << "App " << item().id.app_id
<< " should not have a stop app command.";
......
......@@ -58,7 +58,7 @@ void InternalAppShelfContextMenu::ExecuteCommand(int command_id,
DCHECK_EQ(internal_app->internal_app_name, apps::BuiltInAppName::kPluginVm);
if (command_id == ash::STOP_APP) {
plugin_vm::PluginVmManager::GetForProfile(controller()->profile())
->StopPluginVm(plugin_vm::kPluginVmName);
->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
return;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment