Don't reuse CID while Android is up
As virtualizationservice has become a lazy AIDL service, it started to
reuse CID, because a new virtualizationservice process always starts
from the default CID 10.
This has caused some flakness to tests because the adb connection to the
VM for a test sometimes goes to another VM that was started for a prior
test - because they both have the same CID 10.
Fixing this issue by introducing a system property
`virtualizationservice.state.last.cid` to keep the last CID value across
the runs of virtualizationservice. Note that the system property is not
persistent; a reboot of the host Android starts from CID 10.
Bug: 196015427
Test: watch TH
Change-Id: I16309aa95e30c95f20381302d2bc1d3d9eae1563
diff --git a/virtualizationservice/src/main.rs b/virtualizationservice/src/main.rs
index 22ddf08..0e1e974 100644
--- a/virtualizationservice/src/main.rs
+++ b/virtualizationservice/src/main.rs
@@ -30,6 +30,8 @@
/// are reserved for the host or other usage.
const FIRST_GUEST_CID: Cid = 10;
+const SYSPROP_LAST_CID: &str = "virtualizationservice.state.last_cid";
+
const LOG_TAG: &str = "VirtualizationService";
/// The unique ID of a VM used (together with a port number) for vsock communication.