Separate creation and starting of VMs.
Bug: 199127239
Test: atest VirtualizationTestCases
Change-Id: I2cb436c2acd6b4830aab0a044ed03fb688459fe0
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index dd8e54f..22304f1 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -82,7 +82,7 @@
)
.context("Failed to find VirtualizationService")?;
- let vm = service.startVm(&config, Some(&log_fd)).context("Failed to start VM")?;
+ let vm = service.createVm(&config, Some(&log_fd)).context("Failed to create VM")?;
let vm_state = Arc::new(VmStateMonitor::default());
let vm_state_clone = Arc::clone(&vm_state);
@@ -98,6 +98,8 @@
);
vm.registerCallback(&callback)?;
+ vm.start()?;
+
let cid = vm_state.wait_for_start()?;
// TODO: Use onPayloadReady to avoid this
diff --git a/compos/compos_key_cmd/compos_key_cmd.cpp b/compos/compos_key_cmd/compos_key_cmd.cpp
index 874a208..eb11d92 100644
--- a/compos/compos_key_cmd/compos_key_cmd.cpp
+++ b/compos/compos_key_cmd/compos_key_cmd.cpp
@@ -213,7 +213,7 @@
appConfig.memoryMib = 0; // Use default
LOG(INFO) << "Starting VM";
- auto status = service->startVm(config, logFd, &mVm);
+ auto status = service->createVm(config, logFd, &mVm);
if (!status.isOk()) {
return Error() << status.getDescription();
}
@@ -224,7 +224,7 @@
return Error() << status.getDescription();
}
- LOG(INFO) << "Started VM with cid = " << cid;
+ LOG(INFO) << "Created VM with CID = " << cid;
// We need to use this rather than std::make_shared to make sure the
// embedded weak_ptr is initialised.
@@ -235,6 +235,12 @@
return Error() << status.getDescription();
}
+ status = mVm->start();
+ if (!status.isOk()) {
+ return Error() << status.getDescription();
+ }
+ LOG(INFO) << "Started VM";
+
if (!mCallback->waitForStarted()) {
return Error() << "VM Payload failed to start";
}