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( ...@@ -158,11 +158,19 @@ void PluginVmManager::RemoveVmStartingObserver(
vm_starting_observers_.RemoveObserver(observer); 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; vm_tools::plugin_dispatcher::StopVmRequest request;
request.set_owner_id(owner_id_); request.set_owner_id(owner_id_);
request.set_vm_name_uuid(name); 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. // TODO(juwa): This may not work if the vm is STARTING|CONTINUING|RESUMING.
chromeos::DBusThreadManager::Get()->GetVmPluginDispatcherClient()->StopVm( chromeos::DBusThreadManager::Get()->GetVmPluginDispatcherClient()->StopVm(
std::move(request), base::DoNothing()); std::move(request), base::DoNothing());
...@@ -469,6 +477,8 @@ void PluginVmManager::StopVmForUninstall() { ...@@ -469,6 +477,8 @@ void PluginVmManager::StopVmForUninstall() {
vm_tools::plugin_dispatcher::StopVmRequest request; vm_tools::plugin_dispatcher::StopVmRequest request;
request.set_owner_id(owner_id_); request.set_owner_id(owner_id_);
request.set_vm_name_uuid(kPluginVmName); request.set_vm_name_uuid(kPluginVmName);
request.set_stop_mode(
vm_tools::plugin_dispatcher::VmStopMode::VM_STOP_MODE_SHUTDOWN);
chromeos::DBusThreadManager::Get()->GetVmPluginDispatcherClient()->StopVm( chromeos::DBusThreadManager::Get()->GetVmPluginDispatcherClient()->StopVm(
std::move(request), base::BindOnce(&PluginVmManager::OnStopVmForUninstall, std::move(request), base::BindOnce(&PluginVmManager::OnStopVmForUninstall,
......
...@@ -37,7 +37,7 @@ class PluginVmManager : public KeyedService, ...@@ -37,7 +37,7 @@ class PluginVmManager : public KeyedService,
// TODO(juwa): Don't allow launch/stop/uninstall to run simultaneously. // TODO(juwa): Don't allow launch/stop/uninstall to run simultaneously.
void LaunchPluginVm(); void LaunchPluginVm();
void StopPluginVm(const std::string& name); void StopPluginVm(const std::string& name, bool force);
void UninstallPluginVm(); void UninstallPluginVm();
// Seneschal server handle to use for path sharing. // Seneschal server handle to use for path sharing.
......
...@@ -153,7 +153,7 @@ TEST_F(PluginVmManagerTest, LaunchPluginVmShowAndStop) { ...@@ -153,7 +153,7 @@ TEST_F(PluginVmManagerTest, LaunchPluginVmShowAndStop) {
EXPECT_FALSE(SeneschalClient().share_path_called()); EXPECT_FALSE(SeneschalClient().share_path_called());
EXPECT_EQ(plugin_vm_manager_->seneschal_server_handle(), 0ul); EXPECT_EQ(plugin_vm_manager_->seneschal_server_handle(), 0ul);
plugin_vm_manager_->StopPluginVm(kPluginVmName); plugin_vm_manager_->StopPluginVm(kPluginVmName, /*force=*/true);
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
EXPECT_TRUE(VmPluginDispatcherClient().stop_vm_called()); EXPECT_TRUE(VmPluginDispatcherClient().stop_vm_called());
......
...@@ -27,7 +27,7 @@ void PluginVmProcessTask::Kill() { ...@@ -27,7 +27,7 @@ void PluginVmProcessTask::Kill() {
plugin_vm::PluginVmManager::GetForProfile( plugin_vm::PluginVmManager::GetForProfile(
ProfileManager::GetActiveUserProfile()); ProfileManager::GetActiveUserProfile());
if (plugin_vm_manager) if (plugin_vm_manager)
plugin_vm_manager->StopPluginVm(vm_name_); plugin_vm_manager->StopPluginVm(vm_name_, /*force=*/true);
} }
Task::Type PluginVmProcessTask::GetType() const { Task::Type PluginVmProcessTask::GetType() const {
......
...@@ -119,7 +119,7 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) { ...@@ -119,7 +119,7 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) {
crostini::kCrostiniDefaultVmName, base::DoNothing()); crostini::kCrostiniDefaultVmName, base::DoNothing());
} else if (app_id() == plugin_vm::kPluginVmAppId) { } else if (app_id() == plugin_vm::kPluginVmAppId) {
plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm( plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm(
plugin_vm::kPluginVmName); plugin_vm::kPluginVmName, /*force=*/false);
} else { } else {
LOG(ERROR) << "App " << app_id() LOG(ERROR) << "App " << app_id()
<< " should not have a stop app command."; << " should not have a stop app command.";
......
...@@ -34,7 +34,7 @@ void InternalAppContextMenu::ExecuteCommand(int command_id, int event_flags) { ...@@ -34,7 +34,7 @@ void InternalAppContextMenu::ExecuteCommand(int command_id, int event_flags) {
DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name, DCHECK_EQ(app_list::FindInternalApp(app_id())->internal_app_name,
apps::BuiltInAppName::kPluginVm); apps::BuiltInAppName::kPluginVm);
plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm( plugin_vm::PluginVmManager::GetForProfile(profile())->StopPluginVm(
plugin_vm::kPluginVmName); plugin_vm::kPluginVmName, /*force=*/false);
return; return;
} }
app_list::AppContextMenu::ExecuteCommand(command_id, event_flags); app_list::AppContextMenu::ExecuteCommand(command_id, event_flags);
......
...@@ -140,7 +140,7 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id, ...@@ -140,7 +140,7 @@ void AppServiceShelfContextMenu::ExecuteCommand(int command_id,
->StopVm(crostini::kCrostiniDefaultVmName, base::DoNothing()); ->StopVm(crostini::kCrostiniDefaultVmName, base::DoNothing());
} else if (item().id.app_id == plugin_vm::kPluginVmAppId) { } else if (item().id.app_id == plugin_vm::kPluginVmAppId) {
plugin_vm::PluginVmManager::GetForProfile(controller()->profile()) plugin_vm::PluginVmManager::GetForProfile(controller()->profile())
->StopPluginVm(plugin_vm::kPluginVmName); ->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
} else { } else {
LOG(ERROR) << "App " << item().id.app_id LOG(ERROR) << "App " << item().id.app_id
<< " should not have a stop app command."; << " should not have a stop app command.";
......
...@@ -58,7 +58,7 @@ void InternalAppShelfContextMenu::ExecuteCommand(int command_id, ...@@ -58,7 +58,7 @@ void InternalAppShelfContextMenu::ExecuteCommand(int command_id,
DCHECK_EQ(internal_app->internal_app_name, apps::BuiltInAppName::kPluginVm); DCHECK_EQ(internal_app->internal_app_name, apps::BuiltInAppName::kPluginVm);
if (command_id == ash::STOP_APP) { if (command_id == ash::STOP_APP) {
plugin_vm::PluginVmManager::GetForProfile(controller()->profile()) plugin_vm::PluginVmManager::GetForProfile(controller()->profile())
->StopPluginVm(plugin_vm::kPluginVmName); ->StopPluginVm(plugin_vm::kPluginVmName, /*force=*/false);
return; 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