Commit c1aeee4e authored by Jae Hoon Kim's avatar Jae Hoon Kim Committed by Commit Bot

Try installing Plugin VM DLC if dispatcher fails to launch.

If Plugin VM was installed prior to DLC support being added, PluginVM will fail to launch as the rootfs components will be removed.

This CL updates the launch flow to attempt installing the Plugin VM DLC if the dispatcher fails to launch.
This also allows us to recover from unexpected errors where the DLC module might get uninstalled or fail to be updated.

BUG=b:150867372
TEST=out/Default/unit_tests && out/Default/browser_tests # with PluginVM filters

Change-Id: I9ed6287bf1a35d38778003e8f629166fa5b8dfc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090619
Auto-Submit: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748093}
parent 2de330b6
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
namespace { namespace {
constexpr char kPitaDlc[] = "pita";
chromeos::ConciergeClient* GetConciergeClient() { chromeos::ConciergeClient* GetConciergeClient() {
return chromeos::DBusThreadManager::Get()->GetConciergeClient(); return chromeos::DBusThreadManager::Get()->GetConciergeClient();
} }
...@@ -120,7 +118,7 @@ void PluginVmInstaller::StartDlcDownload() { ...@@ -120,7 +118,7 @@ void PluginVmInstaller::StartDlcDownload() {
dlc_download_start_tick_ = base::TimeTicks::Now(); dlc_download_start_tick_ = base::TimeTicks::Now();
chromeos::DlcserviceClient::Get()->Install( chromeos::DlcserviceClient::Get()->Install(
dlc_module_list_, GetPluginVmDlcModuleList(),
base::BindOnce(&PluginVmInstaller::OnDlcDownloadCompleted, base::BindOnce(&PluginVmInstaller::OnDlcDownloadCompleted,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
base::BindRepeating(&PluginVmInstaller::OnDlcDownloadProgressUpdated, base::BindRepeating(&PluginVmInstaller::OnDlcDownloadProgressUpdated,
...@@ -566,10 +564,7 @@ void PluginVmInstaller::SetDriveDownloadServiceForTesting( ...@@ -566,10 +564,7 @@ void PluginVmInstaller::SetDriveDownloadServiceForTesting(
PluginVmInstaller::PluginVmInstaller(Profile* profile) PluginVmInstaller::PluginVmInstaller(Profile* profile)
: profile_(profile), : profile_(profile),
download_service_( download_service_(
DownloadServiceFactory::GetForKey(profile->GetProfileKey())) { DownloadServiceFactory::GetForKey(profile->GetProfileKey())) {}
auto* dlc_module_info = dlc_module_list_.add_dlc_module_infos();
dlc_module_info->set_dlc_id(kPitaDlc);
}
GURL PluginVmInstaller::GetPluginVmImageDownloadUrl() { GURL PluginVmInstaller::GetPluginVmImageDownloadUrl() {
const base::Value* url_ptr = const base::Value* url_ptr =
......
...@@ -175,7 +175,6 @@ class PluginVmInstaller : public KeyedService, ...@@ -175,7 +175,6 @@ class PluginVmInstaller : public KeyedService,
State state_ = State::NOT_STARTED; State state_ = State::NOT_STARTED;
std::string current_download_guid_; std::string current_download_guid_;
base::FilePath downloaded_plugin_vm_image_archive_; base::FilePath downloaded_plugin_vm_image_archive_;
dlcservice::DlcModuleList dlc_module_list_;
// Used to identify our running import with concierge: // Used to identify our running import with concierge:
std::string current_import_command_uuid_; std::string current_import_command_uuid_;
// -1 when is not yet determined. // -1 when is not yet determined.
......
...@@ -139,14 +139,14 @@ void PluginVmManager::LaunchPluginVm() { ...@@ -139,14 +139,14 @@ void PluginVmManager::LaunchPluginVm() {
// Launching Plugin Vm goes through the following steps: // Launching Plugin Vm goes through the following steps:
// 1) Start the Plugin Vm Dispatcher (no-op if already running) // 1) Start the Plugin Vm Dispatcher (no-op if already running)
// -- If starting the dispatcher fails, try installing the PluginVM DLC.
// 2) Call ListVms to get the state of the VM // 2) Call ListVms to get the state of the VM
// 3) Start the VM if necessary // 3) Start the VM if necessary
// 4) Show the UI. // 4) Show the UI.
UpdateVmState(base::BindOnce(&PluginVmManager::OnListVmsForLaunch, UpdateVmState(base::BindOnce(&PluginVmManager::OnListVmsForLaunch,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
base::BindOnce(&PluginVmManager::LaunchFailed, base::BindOnce(&PluginVmManager::InstallPluginVmDlc,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr()));
PluginVmLaunchResult::kError));
} }
void PluginVmManager::AddVmStartingObserver( void PluginVmManager::AddVmStartingObserver(
...@@ -298,6 +298,31 @@ void PluginVmManager::OnListVms( ...@@ -298,6 +298,31 @@ void PluginVmManager::OnListVms(
} }
} }
void PluginVmManager::InstallPluginVmDlc() {
chromeos::DlcserviceClient::Get()->Install(
GetPluginVmDlcModuleList(),
base::BindOnce(&PluginVmManager::OnInstallPluginVmDlc,
weak_ptr_factory_.GetWeakPtr()),
chromeos::DlcserviceClient::IgnoreProgress);
}
void PluginVmManager::OnInstallPluginVmDlc(
const std::string& err,
const dlcservice::DlcModuleList& dlc_module_list) {
if (err == dlcservice::kErrorNone) {
UpdateVmState(base::BindOnce(&PluginVmManager::OnListVmsForLaunch,
weak_ptr_factory_.GetWeakPtr()),
base::BindOnce(&PluginVmManager::LaunchFailed,
weak_ptr_factory_.GetWeakPtr(),
PluginVmLaunchResult::kError));
} else {
// TODO(kimjae): Unify the dlcservice error handler with
// PluginVmInstaller.
LOG(ERROR) << "Couldn't intall PluginVM DLC after import: " << err;
LaunchFailed();
}
}
void PluginVmManager::OnListVmsForLaunch(bool default_vm_exists) { void PluginVmManager::OnListVmsForLaunch(bool default_vm_exists) {
if (!default_vm_exists) { if (!default_vm_exists) {
LOG(WARNING) << "Default VM is missing, it may have been manually removed."; LOG(WARNING) << "Default VM is missing, it may have been manually removed.";
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_uninstaller_notification.h" #include "chrome/browser/chromeos/plugin_vm/plugin_vm_uninstaller_notification.h"
#include "chrome/browser/chromeos/vm_starting_observer.h" #include "chrome/browser/chromeos/vm_starting_observer.h"
#include "chromeos/dbus/concierge/concierge_service.pb.h" #include "chromeos/dbus/concierge/concierge_service.pb.h"
#include "chromeos/dbus/dlcservice/dlcservice_client.h"
#include "chromeos/dbus/vm_plugin_dispatcher/vm_plugin_dispatcher.pb.h" #include "chromeos/dbus/vm_plugin_dispatcher/vm_plugin_dispatcher.pb.h"
#include "chromeos/dbus/vm_plugin_dispatcher_client.h" #include "chromeos/dbus/vm_plugin_dispatcher_client.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -84,6 +85,9 @@ class PluginVmManager : public KeyedService, ...@@ -84,6 +85,9 @@ class PluginVmManager : public KeyedService,
// The flow to launch a Plugin Vm. We'll probably want to add additional // The flow to launch a Plugin Vm. We'll probably want to add additional
// abstraction around starting the services in the future but this is // abstraction around starting the services in the future but this is
// sufficient for now. // sufficient for now.
void InstallPluginVmDlc();
void OnInstallPluginVmDlc(const std::string& err,
const dlcservice::DlcModuleList& dlc_module_list);
void OnListVmsForLaunch(bool default_vm_exists); void OnListVmsForLaunch(bool default_vm_exists);
void StartVm(); void StartVm();
void OnStartVm( void OnStartVm(
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chromeos/dbus/dlcservice/dlcservice_client.h"
#include "chromeos/tpm/install_attributes.h" #include "chromeos/tpm/install_attributes.h"
#include "components/exo/shell_surface_util.h" #include "components/exo/shell_surface_util.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -177,4 +178,11 @@ std::string GetIdFromDriveUrl(const GURL& url) { ...@@ -177,4 +178,11 @@ std::string GetIdFromDriveUrl(const GURL& url) {
return spec.substr(id_start, first_ampersand - id_start); return spec.substr(id_start, first_ampersand - id_start);
} }
dlcservice::DlcModuleList GetPluginVmDlcModuleList() {
dlcservice::DlcModuleList dlc_module_list;
auto* dlc_module_info = dlc_module_list.add_dlc_module_infos();
dlc_module_info->set_dlc_id("pita");
return dlc_module_list;
}
} // namespace plugin_vm } // namespace plugin_vm
...@@ -14,6 +14,10 @@ namespace aura { ...@@ -14,6 +14,10 @@ namespace aura {
class Window; class Window;
} // namespace aura } // namespace aura
namespace dlcservice {
class DlcModuleList;
} // namespace dlcservice
class Profile; class Profile;
class GURL; class GURL;
...@@ -87,6 +91,9 @@ void RemoveDriveDownloadDirectoryIfExists(); ...@@ -87,6 +91,9 @@ void RemoveDriveDownloadDirectoryIfExists();
bool IsDriveUrl(const GURL& url); bool IsDriveUrl(const GURL& url);
std::string GetIdFromDriveUrl(const GURL& url); std::string GetIdFromDriveUrl(const GURL& url);
// Used during communication with |DlcserviceClient|.
dlcservice::DlcModuleList GetPluginVmDlcModuleList();
} // namespace plugin_vm } // namespace plugin_vm
#endif // CHROME_BROWSER_CHROMEOS_PLUGIN_VM_PLUGIN_VM_UTIL_H_ #endif // CHROME_BROWSER_CHROMEOS_PLUGIN_VM_PLUGIN_VM_UTIL_H_
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