Commit 78a154ba authored by Edman Anjos's avatar Edman Anjos Committed by Commit Bot

arcvm: Start arc-keymasterd job during arcvm startup

arc-keymasterd should run while ARCVM runs in order to serve the
Keymaster HAL service.

This change starts arc-keymasterd in the per board feature flow,
ensuring the service is stopped and restarted if it's already running.

The change https://crrev.com/c/2153037 enables the D-Bus policies needed
and must land before this one.

      && autoninja -C out/Default components_unittests
      && out/Default/components_unittests --gtest_filter='ArcVm*'
             - verify `status arc-keymasterd` says it is running

Bug: b:153278258
Test: gn gen out/Default --args='target_os = "chromeos"' \
Test: manual - deploy chrome to an eve-arc-r device and sign in
Change-Id: Ib79c0e407c3724cc9511162103b1196b09a66fe5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153038
Commit-Queue: Edman Anjos <edman@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761105}
parent 7c2ea37d
...@@ -47,7 +47,11 @@ ...@@ -47,7 +47,11 @@
namespace arc { namespace arc {
namespace { namespace {
// The "_2d" in job names below corresponds to "-". Upstart escapes characters
// that aren't valid in D-Bus object paths with underscore followed by its
// ascii code in hex. So "arc_2dcreate_2ddata" becomes "arc-create-data".
constexpr const char kArcCreateDataJobName[] = "arc_2dcreate_2ddata"; constexpr const char kArcCreateDataJobName[] = "arc_2dcreate_2ddata";
constexpr const char kArcKeymasterJobName[] = "arc_2dkeymasterd";
constexpr const char kArcVmServerProxyJobName[] = "arcvm_2dserver_2dproxy"; constexpr const char kArcVmServerProxyJobName[] = "arcvm_2dserver_2dproxy";
constexpr const char kArcVmPerBoardFeaturesJobName[] = constexpr const char kArcVmPerBoardFeaturesJobName[] =
"arcvm_2dper_2dboard_2dfeatures"; "arcvm_2dper_2dboard_2dfeatures";
...@@ -459,10 +463,33 @@ class ArcVmClientAdapter : public ArcClientAdapter, ...@@ -459,10 +463,33 @@ class ArcVmClientAdapter : public ArcClientAdapter,
<< (result ? "stopped" : "not running?"); << (result ? "stopped" : "not running?");
should_notify_observers_ = true; should_notify_observers_ = true;
// Always run the |callback| with true ignoring the |result|. |result| can
// be false when the proxy job has already been stopped for other reasons, // Make sure to stop arc-keymasterd if it's already started. Always move
// but it's not considered as an error. // |callback| as is and ignore |result|.
std::move(callback).Run(true); chromeos::UpstartClient::Get()->StopJob(
kArcKeymasterJobName, /*environment=*/{},
base::BindOnce(&ArcVmClientAdapter::OnArcKeymasterJobStopped,
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void OnArcKeymasterJobStopped(chromeos::VoidDBusMethodCallback callback,
bool result) {
VLOG(1) << "OnArcKeymasterJobStopped: arc-keymasterd job "
<< (result ? "stopped" : "not running?");
// Start arc-keymasterd. Always move |callback| as is and ignore |result|.
VLOG(1) << "Starting arc-keymasterd";
chromeos::UpstartClient::Get()->StartJob(
kArcKeymasterJobName, /*environment=*/{},
base::BindOnce(&ArcVmClientAdapter::OnArcKeymasterJobStarted,
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void OnArcKeymasterJobStarted(chromeos::VoidDBusMethodCallback callback,
bool result) {
if (!result)
LOG(ERROR) << "Failed to start arc-keymasterd job";
std::move(callback).Run(result);
} }
void OnConciergeStarted(UpgradeParams params, void OnConciergeStarted(UpgradeParams params,
......
...@@ -36,6 +36,7 @@ namespace arc { ...@@ -36,6 +36,7 @@ namespace arc {
namespace { namespace {
constexpr const char kArcCreateDataJobName[] = "arc_2dcreate_2ddata"; constexpr const char kArcCreateDataJobName[] = "arc_2dcreate_2ddata";
constexpr const char kArcKeymasterJobName[] = "arc_2dkeymasterd";
constexpr const char kArcVmServerProxyJobName[] = "arcvm_2dserver_2dproxy"; constexpr const char kArcVmServerProxyJobName[] = "arcvm_2dserver_2dproxy";
constexpr const char kArcVmPerBoardFeaturesJobName[] = constexpr const char kArcVmPerBoardFeaturesJobName[] =
"arcvm_2dper_2dboard_2dfeatures"; "arcvm_2dper_2dboard_2dfeatures";
...@@ -359,8 +360,8 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc) { ...@@ -359,8 +360,8 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc) {
} }
// Tests that StartMiniArc() still succeeds even when Upstart fails to stop // Tests that StartMiniArc() still succeeds even when Upstart fails to stop
// the job. // the arcvm-server-proxy job.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopJobFail) { TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcVmServerProxyJobFail) {
// Inject failure to FakeUpstartClient. // Inject failure to FakeUpstartClient.
InjectUpstartStopJobFailure(kArcVmServerProxyJobName); InjectUpstartStopJobFailure(kArcVmServerProxyJobName);
...@@ -369,6 +370,26 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopJobFail) { ...@@ -369,6 +370,26 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopJobFail) {
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called()); EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
} }
// Tests that StartMiniArc() fails if Upstart fails to start arc-keymasterd.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcKeymasterJobFail) {
// Inject failure to FakeUpstartClient.
InjectUpstartStartJobFailure(kArcKeymasterJobName);
StartMiniArcWithParams(false, {});
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() succeeds if Upstart fails to stop arc-keymasterd.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopArcKeymasterJobFail) {
// Inject failure to FakeUpstartClient.
InjectUpstartStopJobFailure(kArcKeymasterJobName);
StartMiniArc();
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() fails when Upstart fails to start the job. // Tests that StartMiniArc() fails when Upstart fails to start the job.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_Fail) { TEST_F(ArcVmClientAdapterTest, StartMiniArc_Fail) {
// Inject failure to FakeUpstartClient. // Inject failure to FakeUpstartClient.
......
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