Commit 63caffed authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Commit Bot

Switch to using Parallels native error codes

Dispatcher API has been changed to pass native Parallels error codes to
allow better handling of errors, let's start using them.

Bug: b/168829032
Change-Id: Ic422ddf4848059e0e85121268696ea98796b3f97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2486701Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818797}
parent 423eb1f2
......@@ -32,6 +32,28 @@ namespace plugin_vm {
namespace {
PluginVmLaunchResult ConvertToLaunchResult(int result_code) {
switch (result_code) {
case PRL_ERR_SUCCESS:
return PluginVmLaunchResult::kSuccess;
case PRL_ERR_LICENSE_NOT_VALID:
case PRL_ERR_LICENSE_WRONG_VERSION:
case PRL_ERR_LICENSE_WRONG_PLATFORM:
case PRL_ERR_LICENSE_BETA_KEY_RELEASE_PRODUCT:
case PRL_ERR_LICENSE_RELEASE_KEY_BETA_PRODUCT:
case PRL_ERR_JLIC_WRONG_HWID:
case PRL_ERR_JLIC_LICENSE_DISABLED:
return PluginVmLaunchResult::kInvalidLicense;
case PRL_ERR_LICENSE_EXPIRED:
case PRL_ERR_LICENSE_SUBSCR_EXPIRED:
return PluginVmLaunchResult::kExpiredLicense;
case PRL_ERR_JLIC_WEB_PORTAL_ACCESS_REQUIRED:
return PluginVmLaunchResult::kNetworkError;
default:
return PluginVmLaunchResult::kError;
}
}
// Checks if the VM is in a state in which we can't immediately start it.
bool VmIsStopping(vm_tools::plugin_dispatcher::VmState state) {
return state == vm_tools::plugin_dispatcher::VmState::VM_STATE_SUSPENDING ||
......@@ -473,15 +495,8 @@ void PluginVmManagerImpl::OnStartVm(
case vm_tools::plugin_dispatcher::VmErrorCode::VM_SUCCESS:
result = PluginVmLaunchResult::kSuccess;
break;
case vm_tools::plugin_dispatcher::VmErrorCode::VM_ERR_LIC_NOT_VALID:
result = PluginVmLaunchResult::kInvalidLicense;
break;
case vm_tools::plugin_dispatcher::VmErrorCode::VM_ERR_LIC_EXPIRED:
result = PluginVmLaunchResult::kExpiredLicense;
break;
case vm_tools::plugin_dispatcher::VmErrorCode::
VM_ERR_LIC_WEB_PORTAL_UNAVAILABLE:
result = PluginVmLaunchResult::kNetworkError;
case vm_tools::plugin_dispatcher::VmErrorCode::VM_ERR_NATIVE_RESULT_CODE:
result = ConvertToLaunchResult(reply->result_code());
break;
default:
result = PluginVmLaunchResult::kError;
......
......@@ -22,6 +22,20 @@ class Profile;
namespace plugin_vm {
// Native Parallels error codes.
constexpr int PRL_ERR_SUCCESS = 0;
constexpr int PRL_ERR_DISP_SHUTDOWN_IN_PROCESS = 0x80000404;
constexpr int PRL_ERR_LICENSE_NOT_VALID = 0x80011000;
constexpr int PRL_ERR_LICENSE_EXPIRED = 0x80011001;
constexpr int PRL_ERR_LICENSE_WRONG_VERSION = 0x80011002;
constexpr int PRL_ERR_LICENSE_WRONG_PLATFORM = 0x80011004;
constexpr int PRL_ERR_LICENSE_BETA_KEY_RELEASE_PRODUCT = 0x80011011;
constexpr int PRL_ERR_LICENSE_RELEASE_KEY_BETA_PRODUCT = 0x80011013;
constexpr int PRL_ERR_LICENSE_SUBSCR_EXPIRED = 0x80011074;
constexpr int PRL_ERR_JLIC_WRONG_HWID = 0x80057005;
constexpr int PRL_ERR_JLIC_LICENSE_DISABLED = 0x80057010;
constexpr int PRL_ERR_JLIC_WEB_PORTAL_ACCESS_REQUIRED = 0x80057012;
// The PluginVmManagerImpl is responsible for connecting to the D-Bus services
// to manage the Plugin Vm.
......
......@@ -325,7 +325,8 @@ TEST_F(PluginVmManagerImplTest, LaunchPluginVmInvalidLicense) {
vm_tools::plugin_dispatcher::StartVmResponse start_vm_response;
start_vm_response.set_error(
vm_tools::plugin_dispatcher::VmErrorCode::VM_ERR_LIC_NOT_VALID);
vm_tools::plugin_dispatcher::VmErrorCode::VM_ERR_NATIVE_RESULT_CODE);
start_vm_response.set_result_code(PRL_ERR_LICENSE_NOT_VALID);
VmPluginDispatcherClient().set_start_vm_response(start_vm_response);
MockLaunchPluginVmCallback callback;
......
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