crosvm/common/balloon_control
Grzegorz Jaszczyk 8eae8e0d2d crosvm: improve suspend implementation
As part of commit cadc84b32a the crosvm
suspend command has been extended to generating sleep button injection
in order to put VM in suspend state. Additionally the crosvm suspend
command completed after the guest entered proper power state.

Nevertheless in some circumstances above implementation caused issues.
E.g. when the guest with pass-through devices entered run-time device
suspension, triggering a subsequent system suspend request fails and
makes VM inaccessible. It is because before entering system suspension,
devices which entered device run-time suspension needs to be resumed.
Therefore in problematic scenario:
- VmRequest::Suspend was triggered and it resulted with blocking till
  guest entered proper suspend state
- during VM suspension process some pci config write accesses are made,
  which in some cases triggers write_msi_reg-> write_msi_capability->
  add_msi_route, which underneath sends VmIrqRequest::AddMsiRoute
  request
- above VmIrqRequest::AddMsiRoute request can't be satisfied since
  VmRequest::Suspend made the run_control wait loop busy waiting and
  preventing further requests to be processed

In order to fix the above issue, instead of busy waiting directly in the
run_control wait loop for suspend notification, spawn a new thread, which
will generate the acpi power button and start busy waiting for a
notification that the VM actually entered suspend state. This allows to
postpone sending response over the control tube indicating that the
'crosvm suspend ...' command completed and in the same time process
other Vm*Requests.

Mentioned postponement of 'crosvm suspend ..' completion is crucial
since the full system suspension needs to be blocked till VM actually
enters proper suspend state.

BUG=b:248462336
TEST=With a setup where some device is pass-through to the VM and
--force-s2idle flag is used: wait till pass-through device enters
run-time suspend state and trigger "crosvm suspend
/run/vm/vm.<hash>/crosvm.sock" followed by "crosvm resume ..". Also make
sure that full system suspension/resumption doesn't make VM inaccessible
anymore.

Change-Id: Ic23461a78a62d2116cf5674c71d89f4f86ad96c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3944915
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-11-16 21:38:29 +00:00
..
src crosvm: improve suspend implementation 2022-11-16 21:38:29 +00:00
Cargo.toml crosvm: migrate to Rust 2021 edition 2022-03-09 01:16:03 +00:00