Fix threading bugs

- Move sCreateLock to VirtualMachine, use it to guard VM
  create/load/delete, since these can all race with each other in
  complicated ways (e.g. deleting files while we're in the process of
  creating them).

- Add a per-VM lock to protect mutable state, with a separate one for
  callback-related state.

- Document lock ordering, add @GuardedBy to fields & methods as appropriate.

- Use the existence of the VM directory, rather than the config file
  within it, to detect if a VM of a given name exists. Delete the
  directory if creation fails.

- Make the immutability of mExtraApks explicit.

- Extract various helper functions, especially for checking the VM is
  in the expected state.

- Add checking VM is running to connectVsock (fixing a possible NPE).

- Other random refactorings.

Bug: 193471517
Test: atest MicrodroidTests MicrodroidHostTests
Change-Id: Ie32090426fcf7a42aa82eba7b48f62bc12cfd479
2 files changed
tree: cebb6e660f4ea9b201f719709dd856975b2bc5a1
  1. apex/
  2. apkdmverity/
  3. authfs/
  4. avmd/
  5. compos/
  6. demo/
  7. docs/
  8. javalib/
  9. launcher/
  10. libs/
  11. microdroid/
  12. microdroid_manager/
  13. pvmfw/
  14. rialto/
  15. tests/
  16. virtualizationservice/
  17. vm/
  18. vmbase/
  19. vmclient/
  20. zipfuse/
  21. .clang-format
  22. .gitignore
  23. Android.bp
  24. OWNERS
  25. PREUPLOAD.cfg
  26. README.md
  27. TEST_MAPPING
README.md

Virtualization

This repository contains userspace services related to running virtual machines on Android, especially protected virtual machines. See the getting started documentation and Microdroid README for more information.