Commit c13b5162 authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

arcvm: Start arc-create-data job before starting crosvm

The job creates /home/root/<hash>/android-data which crosvm will
export to the guest via virtio-fs in the near future.

This CL depends on platform2's chromium:2134800.

BUG=b:151683475
TEST=try, arc.Boot.vm

Change-Id: I1c337740ee726e3acc689fb4a1c112ee9a1e7bbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135055
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarLong Cheng <lgcheng@google.com>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756912}
parent 2835acc5
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
namespace arc { namespace arc {
namespace { namespace {
constexpr const char kArcCreateDataJobName[] = "arc_2dcreate_2ddata";
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";
...@@ -484,6 +485,26 @@ class ArcVmClientAdapter : public ArcClientAdapter, ...@@ -484,6 +485,26 @@ class ArcVmClientAdapter : public ArcClientAdapter,
std::move(callback).Run(false); std::move(callback).Run(false);
return; return;
} }
VLOG(1) << "Starting arc-create-data";
const std::string account_id =
cryptohome::CreateAccountIdentifierFromIdentification(cryptohome_id_)
.account_id();
chromeos::UpstartClient::Get()->StartJob(
kArcCreateDataJobName, {"CHROMEOS_USER=" + account_id},
base::BindOnce(&ArcVmClientAdapter::OnArcCreateDataJobStarted,
weak_factory_.GetWeakPtr(), std::move(params),
std::move(callback)));
}
void OnArcCreateDataJobStarted(UpgradeParams params,
chromeos::VoidDBusMethodCallback callback,
bool result) {
if (!result) {
LOG(ERROR) << "Failed to start arc-create-data job";
std::move(callback).Run(false);
return;
}
// TODO(pliard): Export host-side /data to the VM, and remove the call. Note // TODO(pliard): Export host-side /data to the VM, and remove the call. Note
// that ArcSessionImpl checks low disk conditions before calling UpgradeArc. // that ArcSessionImpl checks low disk conditions before calling UpgradeArc.
base::ThreadPool::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
namespace arc { namespace arc {
namespace { namespace {
constexpr const char kArcCreateDataJobName[] = "arc_2dcreate_2ddata";
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";
...@@ -452,6 +453,30 @@ TEST_F(ArcVmClientAdapterTest, UpgradeArc_StartArcVmProxyFailure) { ...@@ -452,6 +453,30 @@ TEST_F(ArcVmClientAdapterTest, UpgradeArc_StartArcVmProxyFailure) {
EXPECT_TRUE(arc_instance_stopped_called()); EXPECT_TRUE(arc_instance_stopped_called());
} }
// Tests that UpgradeArc() handles arc-create-data startup failures properly.
TEST_F(ArcVmClientAdapterTest, UpgradeArc_StartArcCreateDataFailure) {
SetValidUserInfo();
StartMiniArc();
// Inject failure to FakeUpstartClient.
InjectUpstartStartJobFailure(kArcCreateDataJobName);
UpgradeArc(false);
EXPECT_TRUE(GetStartConciergeCalled());
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
EXPECT_FALSE(arc_instance_stopped_called());
// Try to stop the VM. StopVm will fail in this case because
// no VM is running.
vm_tools::concierge::StopVmResponse response;
response.set_success(false);
GetTestConciergeClient()->set_stop_vm_response(response);
adapter()->StopArcInstance(/*on_shutdown=*/false);
run_loop()->Run();
EXPECT_TRUE(GetTestConciergeClient()->stop_vm_called());
EXPECT_TRUE(arc_instance_stopped_called());
}
// Tests that UpgradeArc() handles StartConcierge() failures properly. // Tests that UpgradeArc() handles StartConcierge() failures properly.
TEST_F(ArcVmClientAdapterTest, UpgradeArc_StartConciergeFailure) { TEST_F(ArcVmClientAdapterTest, UpgradeArc_StartConciergeFailure) {
SetValidUserInfo(); SetValidUserInfo();
......
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