Commit 31d9542a authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

arcvm: Make sure Concierge is running before talking to it

ARCVM uses Concierge to throttle crosvm's CPU usage. Unlike
session_manager which always outlives Chrome, Concierge may start
after Chrome is started. Previously, if SetArcVmCpuRestriction
is called before Concierge fully starts, the operation failed
with the following errors:

ERROR:object_proxy.cc(632)] Failed to call method: org.chromium.VmConcierge.SetVmCpuRestriction: object_path= /org/chromium/VmConcierge: org.freedesktop.DBus.Error.ServiceUnknown: The name org.chromium.VmConcierge was not provided by any .service files
ERROR:arc_util.cc(57)] Failed to call SetVmCpuRestriction

This CL fixes the error.

BUG=b:139095697
TEST=Start ARCVM, verify /var/log/chrome/chrome no longer has
 the errors.

Change-Id: I6e1caf28bbe0307525ee750b3da3008d884435cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808240Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697288}
parent 20584e72
......@@ -15,6 +15,7 @@
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/concierge_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/dbus/session_manager/session_manager_client.h"
#include "components/arc/arc_features.h"
#include "components/exo/shell_surface_util.h"
......@@ -61,10 +62,15 @@ void OnSetArcVmCpuRestriction(
LOG(ERROR) << "SetVmCpuRestriction for ARCVM failed";
}
void SetArcVmCpuRestriction(bool do_restrict) {
void DoSetArcVmCpuRestriction(bool do_restrict, bool concierge_started) {
if (!concierge_started) {
LOG(ERROR) << "Concierge D-Bus service is not available";
return;
}
auto* client = chromeos::DBusThreadManager::Get()->GetConciergeClient();
if (!client) {
LOG(WARNING) << "ConciergeClient is not available";
LOG(ERROR) << "ConciergeClient is not available";
return;
}
......@@ -78,6 +84,17 @@ void SetArcVmCpuRestriction(bool do_restrict) {
base::BindOnce(&OnSetArcVmCpuRestriction));
}
void SetArcVmCpuRestriction(bool do_restrict) {
auto* client = chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
if (!client) {
LOG(WARNING) << "DebugDaemonClient is not available";
return;
}
// TODO(wvk): Call StartConcierge() only when the service is not running.
client->StartConcierge(
base::BindOnce(&DoSetArcVmCpuRestriction, do_restrict));
}
void SetArcContainerCpuRestriction(bool do_restrict) {
if (!chromeos::SessionManagerClient::Get()) {
LOG(WARNING) << "SessionManagerClient is not available";
......
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