Commit graph

291 commits

Author SHA1 Message Date
Daniel Verkamp
2c96bed807 Cargo.toml: Remove unused data_model deps
Several crates still declared a dependency on data_model despite not
using any imports from it.

BUG=b:312312646
TEST=tools/dev_container tools/presubmit

Change-Id: I63a67696c205f684b1e4ac8bdad4de5f294b63dc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5370964
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-03-13 20:00:26 +00:00
Hikaru Nishida
80f14ee450 virtio/pvclock: Support Linux hosts
BUG=b:295256641
TEST=cargo build -F pvclock
TEST=cargo test -p devices -F pvclock -- pvclock
TEST=cargo test -p e2e_tests -- suspend
TEST=tools/dev_container tools/presubmit all
TEST=crrev/c/5151637

Change-Id: I57fe8ece5a205decb36ef7863d8e5c4f4f4c6bde
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4576848
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2024-03-13 09:05:17 +00:00
Hikaru Nishida
0c5a475111 Respond to PvClockCommand even before the device activation
Spawn a stub_worker thread as a part of the device initialization to
avoid blocking PvClockCommand request when the device is not activated
yet. After this change, the requester of PvClockCommand can expect the
response from the device even if the device is not active. This can
happen when the guest kernel does not support the PvClock device and
because of that the device is not activated (from the virtio device
perspective).

BUG=b:295256641
TEST=cargo test -p devices -- pvclock
TEST=cargo test -p e2e_tests -- suspend

Change-Id: I0efc10bbf0e1125bf2df9208e1d6bcc341867a7e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5312037
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2024-03-13 09:05:17 +00:00
Frederick Mayle
7eb27dd45b vm_memory: support lz4 compression for RAM snapshot
RAM snapshot size and overall snapshot time for a basic ubuntu VM right
after login:

  * no compression:  619M 0.8s
  * lz4 compression: 175M 1.2s

BUG=b:320753724
TEST=crosvm snapshot take --compress-memory /tmp/crosvm-snapshot /tmp/crosvm-control

Change-Id: I5dff9fe8744847fea872ad78347ac5f7d8b957e3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5190788
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2024-03-08 22:51:26 +00:00
Pujun Lun
f1bcfe1475 everywhere: enable setting mouse mode thru CLI.
Example command:
crosvm gpu set-mouse-mode <control_socket_path> \
    --display-id=0 \
    --mouse-mode=relative

This enables the Windows implementation to toggle mouse capture
mode (touchscreen <-> relative). It will have no effect if the
specified "display-id" doesn't point to an existing guest display
associated with an in-use host display.

BUG=b:324087519
TEST=presubmit

Change-Id: I9e513eb692d4b9cba66eb1e629ab8f7018645059
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5319794
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-03-04 22:17:23 +00:00
Frederick Mayle
fc2cc0f521 add buffering to serde_json::from_reader/to_writer callers
Using serde_json on unbuffered readers/writers is slow.

Change-Id: Ie22f09e317d86d44263805e6f850ee96c0f0aa04
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5325901
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2024-02-27 18:29:57 +00:00
Noah Gold
4b5f031e48 vm_control: switch to Boxed raw fragments.
Turns out impl Trait in return position means we only get *one* concrete
return type for all branches. In a future CL we'll have multiple return
types, so paradoxically, we'll have to think inside the Box.

BUG=b:326170473
TEST=builds

Change-Id: If759995d47e717adfeae6153f81f9940062e1e4e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5320337
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2024-02-23 01:04:58 +00:00
Noah Gold
cbf9381c58 vm_control: snapshot fragments use IO traits.
The current SnapshotReader/Writer interface returns Files for raw
fragments. When we add snapshot encryption, we will need to return an
encrypting or decrypting streaming wrapper, and this won't be a File.
This CL changes the interface to return impl Read or impl Write. As
part of that, we also had to make a significant safety change to
how memory snapshots are taken.

Memory snapshots used to be written with FileReadWriteVolatile. This is
because we assume GuestMemory is always mutably borrowed by the guest,
and it is UB to have aliased references in Rust. While formally
undefined, the rough reasoning for this is that LLVM optimizations
assume noalias on mutable references, and if that is violated at
runtime, optimizations can result in changed behavior. In the snapshot &
restore case though, we know the guest is not running because its VCPUs
are stopped, so its mutable reference can be ignored (temporal overlap
for aliasing is required for UB to occur). Luckily for us, the host code
will never alias guest memory because up until this CL, we assumed that
was never safe.

Credit: thanks to fmayle@, who originally proposed using Read/Write in this
manner in a CL that added snapshot compression.

BUG=b:326170473
TEST=builds

Change-Id: Iafd9175f684bc197329a0f5aae57685f5cfd677e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5313630
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2024-02-22 20:48:37 +00:00
Ryan Neph
d93be8c65f vm_control: enable fixed_blob_mapping + noncoherent-dma
Certain platforms use the noncoherent-dma feature to appropriately
consider the guest PAT's memory type (caching mode) when configuring the
effective memory type in SLAT, instead of simply ignoring it in favor of
the host PAT.

Dynamic blob mapping has already integrated support for noncoherent-dma
upon setting up each mapped blob's memory region (e.g. KVM memslot),
but fixed_blob_mapping merged while naively ignoring the feature.

Now, we respect the feature when setting up the shared/prepared memory
region (appropriately passing the new MemCacheType enum through to the
hypervisor).

BUG=b:246334944
TEST=tools/presubmit
TEST=(in venus-enabled VM w/ noncoherent-dma) `deqp-vk -n dEQP-VK.memory*` passing
TEST=(in venus-enabled VM w/ noncoherent-dma) Hollow Knight, Portal 2,
Valheim, CS:Source all look fine.

Change-Id: Ia31763c80765a42a1932bfb347ffa57a2faf6fab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5285309
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-02-16 00:09:55 +00:00
Ryan Neph
abcdbd3493 gpu: add fixed_blob_mapping to elide per-blob vMMU mapping setup
Before this change, each guest synchronous virtio-gpu
VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB submission would provoke crosvm's
hypervisor thread to perform a costly vMMU guestPA->hostVA mapping
(configure a new kvm memslot).

With this change, the entire Virtio-GPU PCI BAR address space can
optionally be pre-configured to a single vMMU mapping. Then, subsequent
RESOURCE_MAP_BLOB requests are handled by mmap() of the blob's exported
fd (dma-buf, shmem, ...) in the hypervisor process to a fixed hostVA
within an unused portion of the vMMU's pre-mapped region corresponding
to the blob's guestPA in the virtio-gpu device's BAR.

The new option is disabled by default, since this is not yet compatible
with the exposure of host dma_bufs to a PCI-passthrough device via
virtio-iommu + vfio. Those features are currently mutually exclusive
(i.e. PCI-Passthrough GPU must continue to use per-blob vMMU mappings
for now).

BUG=b:246334944
TEST=tools/presubmit
TEST=(in linux VM + venus): vkcube
TEST=(in linux VM + virgl): apitrace replay <opengl-game-trace-file>

Change-Id: Ibdd9ad8c12651cb7d31dd8648be9da17cc01cba3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5255761
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2024-02-08 00:04:57 +00:00
Ryan Neph
b07b17ed71 vm_control: log an error when mapping incompatible VmMemorySource
Make this cause of a failed "fixed mapping" attempt obvious when
inspecting the logs. This shouldn't be seen in production and is here
for developers that attempt to enable an incompatible VmMemorySource
type before it can be supported.

BUG=b:246334944
TEST=tools/presubmit

Change-Id: Ief32abc85d0aa07d4507a1d53f0ba55becca5e0f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5255759
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-02-08 00:04:57 +00:00
Ryan Neph
b4a32656d9 vm_control: inline request_register_memory proc into register_memory
Inline a procedure that has only a single caller.

BUG=b:246334944
TEST=tools/presubmit

Change-Id: Ib727090c710162d16bdf4acf05e5b94c0e80e16a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5255758
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2024-02-08 00:04:57 +00:00
Noah Gold
87cfdaca23 devices: improve failure logging for snapshotting.
A device failing to wake up is a pretty generic error. This CL adds the
device's debug label so it's easier to understand which device is
failing.

BUG=None
TEST=builds

Change-Id: I35d67cd356b95f3b4875ae1fe3bf358c0cc329fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5271324
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2024-02-06 18:36:21 +00:00
Zhenyu Wang
53c8fb14bf devices: apply new noncoherent attribute for GPU mem's cache info
On Intel, new noncoherent DMA mem flag can be set to allow KVM to
recognize guest cache setting for EPT, which allows WC attribute to be
applied to ensure guest memory access is synchronized in noncoherent DMA.

Unlike previous POC for new device attribute, this uses new added flag
for mem slot.

BUG=b:316337317
TEST=cargo build and run GPU workload

Change-Id: If16d61031bdb2cf0252a57e99d4b6725a89dd38a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5171312
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Stanisław Kardach <skardach@google.com>
2024-01-26 23:27:58 +00:00
Frederick Mayle
b488863647 devices: SnapshotReader/Writer abstraction + new snapshot format
Instead of building up one big json value, we pass around a "writer"
object that allows writing out fragments of the snapshot and nested
namespacing. The snapshot fragments can use different serialize formats
if desired, e.g. the RAM snapshot uses a raw binary file.

Snapshot directory contents:

     213 .../bus0/ACPIPMResource-0
     299 .../bus0/cmos-0
       2 .../bus0/i8042-0
     542 .../bus0/pci-config-io-port-0
     234 .../bus0/serial-0
     234 .../bus0/serial-1
     234 .../bus0/serial-2
     235 .../bus0/serial-3
     536 .../bus1/pci-config-mmio-0
    3.5K .../bus1/pcivirtio-balloon-0
    6.1K .../bus1/pcivirtio-block-0
    1.7K .../bus1/pcivirtio-rng-0
     536 .../bus1/pci-virtual-config-mmio-0
     569 .../bus1/PvPanic-0
    5.3K .../irqchip
    8.0G .../mem
      52 .../mem_metadata
    6.5K .../vcpu/vcpu0
    6.6K .../vcpu/vcpu1
    6.5K .../vcpu/vcpu2
    6.5K .../vcpu/vcpu3

For now, the new abstractions are not used in `BusDevice` or any layers
beyond `BusDevice`, so each device is still a monolithic JSON file.

`PciConfigIo::debug_label` was modified so that it can't change at
runtime.

Based on some light testing, this seems to reduce the snapshot time for
a particular ubuntu VM config from 14s to 13s.

BUG=b:268093674

Change-Id: Ic16980629ff9321bee19f56f6e8e50f214492a7d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4739910
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2024-01-16 21:42:29 +00:00
Ludovic Barman
cd04b6198d Upgrade gdbstub and gdbstub_arch.
gdbstub 0.6.3 -> 0.7.0
gdbstub_arch 0.2.4 -> 0.3.0

There is small change in API, see src/crosvm/gdb.rs. `read_addrs` now returns a `usize` instead of a `()`.

This change is needed to submit this AOSP topic: https://android-review.git.corp.google.com/c/platform/external/crosvm/+/2879249

BUG=b:286979636

TEST=tools/presubmit --all

Change-Id: I124d65e673c5943070c2bb5e39e3a7e5506e5528
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5146447
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-04 02:06:22 +00:00
Frederick Mayle
7005f04e34 vm_control: fix vcpu restore response check
In this case, `recv` returns `Result<Result<(), Error>, RecvError>` and
we only checked the `RecvError` error, actual vCPU restore errors were
ignored.

BUG=b:316912197
TEST=Added `anyhow::bail!` line to the vCPU restore and observed that restoring no longer gets stuck

Change-Id: I51a5e3ff90a9248a7eb5790394143fa0188b2955
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5146882
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2024-01-02 21:26:18 +00:00
Vikram Auradkar
2768f223ee clippy: enforce safety block comments
BUG=b:316174930
TEST=none

Change-Id: I5c7811b2c548155aa003e4b71a54bbc16e2f2588
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5120567
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-12-14 18:21:54 +00:00
Noah Gold
45be65a0c7 hypervisor: stop restoring TSC offset snapshot.
The TSC itself is saved/restored as a MSR by most hypervisors
(e.g. KVM), so we generally don't need to also save/restore the
TSC offset*; in fact, this could desync TSC and lead to guest time
warping because the TSC offset cannot be set directly (it has to
use a host TSC reference moment). However, some hypervisors need
to use the TSC offset to fix up timekeeping in concert with
virtio-pvclock.

This CL does several things to resolve these issues:
1. Stop always restoring TSC offset.
2. Provide a new method for hypervisors to implement their own
   behavior with TSC offset & restoring timekeeping.
3. Take a common host TSC reference moment and provide it to the
   timekeeping restore method.

* We later discovered KVM's pvclock seems to not be working correctly if
  we stop restoring the TSC offset. It seems that setting TSC_KHZ via
  the KVM API somehow fixes the issue as well. Further investigation is
  needed to understand why. For the time being we're going to keep the
  existing TSC offset restore behavior.

Thanks to colindr@ for a ton of help debugging & understanding the
underlying timekeeping problem and hypervisor oddities.

BUG=b:311314468
TEST=tested on WHPX.

Change-Id: Ib2196085061f57931362b3d5da2383bc5e1abbe7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5042037
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-11-22 23:04:24 +00:00
A. Cody Schuffelen
3210820847 Convert ScmSocket to a struct
On MacOS there is no MSG_NOSIGNAL, but there is SO_NOSIGPIPE which is
set as a socket option. This changes ScmSocket from a trait to a wrapper
type that can guarantee SO_NOSIGPIPE is set once on every relevant
socket before it is used in situations that can produce signals.

The biggest wrinkle is that setsockopt can produce errors, which makes
the conversion into ScmSocket a case that can possibly error. Not all
places that accept sockets were prepared to return errors.

Bug: b/309020556
Change-Id: I079bbaf8803e137ca7c0e0ebe60e63de5df59cc0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5021438
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-11-22 05:47:15 +00:00
A. Cody Schuffelen
9776cbb257 Remove some platform-specific re-exports from base::
base::Pid is explicitly added since every platform has a process id
type.

Bug: 233233301
Test: tools/dev_container ./tools/presubmit
Change-Id: Id0d54fe06981c1dcbdee3f73b1241af74a26300f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909061
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-10-30 23:48:49 +00:00
Vikram Auradkar
87d6de735c base: service_ipc: Add and use MultiPartMesgPipe
Messages to/from service are multipart - variable length message
follows fixed length header. MultiPartMessage ensures that
(Header, Message) pair is read/written by one call from one thread.

Bug: 269191436
Test: flat run emulator
Change-Id: Icaf43ad99049f2b593aa20462ec1410d2db6b8a1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4973856
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
2023-10-27 04:23:56 +00:00
Kaiyi Li
5fa838fdfc vm_control: gpu: remove kiwi feature
Change-Id: I12af995a2fd9daff0b2ff00f54bb9b053bd16d1e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4869237
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-10-24 23:19:03 +00:00
Elie Kheirallah
52b23100a8 devices: bus: Add debug logs for devices and bus.
Change bus logs from info to debug.
Add debug logs for each device on sleep, snapshot, wake, restore.
Add info log at top level snapshot and restore.

BUG=N/A
TEST=boot crosvm, snapshot. Shut down, boot with restore.
TEST=boot crosvm with --log-level=debug, snapshot. Shut down, boot with restore.

Change-Id: I67263a5745dac6647dbe689aa3b97c8f43555593
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4954726
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-10-19 20:45:16 +00:00
A. Cody Schuffelen
4748c54b95 Rename "unix" to "linux" in code and docs
$ for DIR in $(find . -name "unix"); do mv $DIR $(echo $DIR | sed "s/unix/linux/"); done
$ for FILE in $(find . -name "unix.rs"); do mv $FILE $(echo $FILE | sed "s/unix/linux/"); done
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/mod unix/mod linux/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/([^o][^s])::unix/\1::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix::/use linux::/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/sys::unix/sys::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix as platform/use linux as platform/g" {}

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I2c8acb14d77a5588dab4eae124f4a9afbb9025f5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909060
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-10-11 01:15:07 +00:00
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.

This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.

Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt

md files manually updated to fix line lengths.

Renaming `unix` modules to `linux` will be done in a later CL.

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-10-11 00:43:29 +00:00
lunpujun
9c0457d2f5 Add support for 2k and 4k resolution.
We used to cap the guest resolution at 1080p. We are experimenting with
higher resolutions, gated by the feature flag enable_4k_uhd_resolution.
Two places need to change:

1. The virtual display size should be capped at 3840x2160 instead if the
   feature is enabled. This size is used as the guest resolution.
2. guest_dpi_manager should provide the recommended DPI for the newly
   added resolutions. It is fine not to check the feature flag there
   since the BSS knows whether or not to use those values.

get_virtual_display_size() may be called by validate_gpu_config(), which
happens very early and the process variants are not yet written to the
static variable PROCESS_INVARIANTS, so we can't use the macro
phenotype!. As a workaround, we load the process variants and read the
flag by ourselves. In the long term, the BSS should be specifying the
virtual display size when launching KiwiVM, so we should be able to get
rid of This workaround.

Bug: 276352265
Test: Ran GPG with the feature enabled/disabled, and verified that the
      resolution is capped at 4k UHD when it is enabled.
Change-Id: I3ec06deda1aa5b7fe89dde5bca426248b93b3ecf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4804797
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2023-09-15 21:39:55 +00:00
Wang Ningyuan
ce6ef2b36a vm_control: Expose do_net_add without hotplug
This CL defines do_net_add/remove with the same function signature when
pci-hotplug feature flag is disabled. This allows crosvm_control to be
unaware of the pci-hotplug flag.

TEST=presubmit tests.
BUG=b:294777126

Change-Id: I4c6a3b96c01ecea9f9f01dcd1c7f65ca042a5664
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4851835
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
2023-09-10 03:22:30 +00:00
Wang Ningyuan
9c031a9840 vm_control: Factor net tap removal to vm_control
This CL factors out do_net_remove to vm_control from main.rs.
do_net_remove sends a VmRequest to remove a tap device.

Test= presubmit tests.
Bug=b:294777126

Change-Id: I82e2741a044b1144f04424deacc905fbe079560c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4846021
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
2023-09-10 03:17:36 +00:00
Daniel Verkamp
41f57f8f89 Apply nightly rustfmt import style
As usual, some unsorted and grouped imports have appeared.

Change-Id: I79b51e4c52cee38f5b8c238e46dfe3193c753554
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4847980
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-06 22:13:26 +00:00
Kaiyi Li
688d41b1f2 gpu_display: remove unused Windows code
Change-Id: I0f5a090a6934a1b03d0866252478091963591d1f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4804794
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-08-30 18:14:49 +00:00
Noah Gold
a1e0d46704 gpu_display: guest -> host input event dispatch.
virtio-input devices can receive events from the guest. Primarily this
is used controlling the numlock, capslock, and scroll lock lights. For
KiwiMouse, we'll be using LED 0 (the numlock LED) to allow the guest to
signal whether the mouse should be captured.

We need the capture information to be communicated from the virtio-input
device to SurfaceInput, but some of the plumbing is missing. Currently
we only support host -> guest data, and not the other way around (at
least in gpu_display_win). This CL adds a route for data to flow from
virtio-input to the gpu_display_win Surface via the
the GPU device worker & GpuDisplay::handle_event_device.

Bug: 239991275
Test: ran emulator & verified events were arriving in
on_handle_event_device as expected.

Change-Id: I7ab8e5ec51f7aa655b2cb44fe38483103388b53d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4719210
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-08-30 18:14:49 +00:00
Daniel Verkamp
4be56406b6 Remove target_arch = "x86" checks
crosvm has never actually supported running on a 32-bit x86 host, only
x86-64. Remove the cfg(target_arch = "x86") checks throughout the tree
to make this clear (and to simplify the code).

This doesn't affect the code running inside the guest, which can still
be a 32-bit x86 operating system if launched via --bios, for example.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: Ifd888db54c58ec8a5fcf840871ef564771d9066b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4794387
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-08-18 23:36:47 +00:00
David Stevens
5ae896b392 balloon: add optional response to adjust
Add the option to wait for a balloon adjustment to successfully
complete. To allow the client to handle failures by re-adjusting the
balloon, this command bypasses the queuing logic in BalloonTube.

This new feature is used by vm_concierge in crrev/c/4744519.

BUG=b:259503518
TEST=cargo test -p vm_control --features balloon
TEST=repeat-test.sh -r 300 -- kohaku arc.Swap

Change-Id: Ib9a990cdfc4001d6294e654776ac0b130ebc94e2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4744559
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2023-08-16 04:44:01 +00:00
Judy Hsiao
72b1801216 devices: pci: remove AC97 codes
Remove the AC97 codes on crosvm as it's replaced by virtio-snd

BUG=b:281092802
BUG=b:237681055
TEST=./tools/run_tests

Change-Id: Id7390930c355f7bcfe19f5e62bd678c31f79551e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4747399
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@google.com>
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
2023-08-11 03:29:31 +00:00
maciek swiech
98ad43515a balloon: change intervals and thresholds to u32
kernel stores these values as u32 isntead of u64, so to prevent needless
casting change to use the same type in crosvm's balloon device.

BUG=b/285581266
TEST=cargo build && cargo build --no-default-features && cargo build --features registered_events
TEST=cargo build -p crosvm_control --features registered_events
TEST=cros_sdk emerge-volteer crosvm && cros_sdk emerge-volteer vm_host_tools

Change-Id: I7672063851f5044b1adf39042ee3b98b478829ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4724907
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-08-09 19:31:25 +00:00
maciek swiech
32f8711cf7 Reland "Reland "balloon: rename WSS to WS""
This reverts commit 2aea504a65.

Reason for revert: missed run-time flag migration, fixed this time around and tested more thoroughly

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
TEST=cros deploy && restart vm_concierge on DUT
TEST=cros deploy && vmc start borealis && (borealis) DISPLAY=:0 steam

Original change's description:
> Revert "Reland "balloon: rename WSS to WS""
>
> This reverts commit cf1c3cd755.
>
> Reason for revert: The command line change will break existing
> usage of the CLI flag
>
> Original change's description:
> > Reland "balloon: rename WSS to WS"
> >
> > This reverts commit 94dc10b57c.
> >
> > Reason for revert: relanding changes with fully implemented types
> >
> > BUG=b/288432539
> > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
> >
> > Original change's description:
> > > Revert "balloon: rename WSS to WS"
> > >
> > > This reverts commit 1eb1106537.
> > >
> > > Reason for revert: headers generated by cbindgen do not compile as expected downstream
> > >
> > > Original change's description:
> > > > balloon: rename WSS to WS
> > > >
> > > > as the working set feature approaches acceptance at the spec-level, we
> > > > are keeping up with nomenclature changes.
> > > >
> > > > BUG=b/288432539
> > > > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > > >
> > > > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > >
> > > BUG=b/288432539
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > >
> > > Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> >
> > BUG=b/288432539
> >
> > Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
>
> BUG=b/288432539
>
> Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: I657f648aec0fc4f4551cf3c109c5ecedcdddbcb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4733877
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-08-01 20:26:39 +00:00
Dennis Kempin
2aea504a65 Revert "Reland "balloon: rename WSS to WS""
This reverts commit cf1c3cd755.

Reason for revert: The command line change will break existing
usage of the CLI flag

Original change's description:
> Reland "balloon: rename WSS to WS"
>
> This reverts commit 94dc10b57c.
>
> Reason for revert: relanding changes with fully implemented types
>
> BUG=b/288432539
> TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
>
> Original change's description:
> > Revert "balloon: rename WSS to WS"
> >
> > This reverts commit 1eb1106537.
> >
> > Reason for revert: headers generated by cbindgen do not compile as expected downstream
> >
> > Original change's description:
> > > balloon: rename WSS to WS
> > >
> > > as the working set feature approaches acceptance at the spec-level, we
> > > are keeping up with nomenclature changes.
> > >
> > > BUG=b/288432539
> > > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > >
> > > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> >
> > BUG=b/288432539
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> >
> > Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
>
> BUG=b/288432539
>
> Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> Commit-Queue: maciek swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-28 22:34:54 +00:00
Noah Gold
6971a71eb3 vm_control: BalloonTube fixes for Windows.
After integrating downstream, we found a couple of adjustments that were
worth making:
* Bug: get_read_notifier wasn't used on the Tube, so it wouldn't ever
  wake up when added to the wait context.
* Feature: an adjust request has no reply, so having to specify a
  response id doesn't make sense since we don't actually want the reply
  routed anywhere (in some cases, we have no where to route it).

BUG=b:291684465
TEST=builds.
TEST=tested downstream.

Change-Id: Idfb1bd4d28ad26f1df3fd6d543df43cf84938975
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4718769
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-07-28 22:32:37 +00:00
Wang Ningyuan
6b1a35298c crosvm: virtio-net device hotplug
This CL implements PCI hotplug feature for virtio-net device. The
feature is controlled by pci-hotplug feature flag and pci-hotplug-slots
runtime flag. No behavior change to crosvm unless pci-hotplug-slots flag
is set to a nonzero value.

BUG=b:243767476
TEST=tools/presubmit
TEST=e2e_test::tap_hotplug for TAP device hotplug and removal
TEST=manual test for TAP device hotplug and removal with swap

Change-Id: I5a60314293ef8a27981d7b550a61822491c254bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4473610
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Shin Kawamura <kawasin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Jason Iman <jasongustaman@chromium.org>
2023-07-27 04:35:26 +00:00
maciek swiech
cf1c3cd755 Reland "balloon: rename WSS to WS"
This reverts commit 94dc10b57c.

Reason for revert: relanding changes with fully implemented types

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools

Original change's description:
> Revert "balloon: rename WSS to WS"
>
> This reverts commit 1eb1106537.
>
> Reason for revert: headers generated by cbindgen do not compile as expected downstream
>
> Original change's description:
> > balloon: rename WSS to WS
> >
> > as the working set feature approaches acceptance at the spec-level, we
> > are keeping up with nomenclature changes.
> >
> > BUG=b/288432539
> > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> >
> > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
>
> BUG=b/288432539
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
>
> Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> Commit-Queue: maciek swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 21:48:44 +00:00
maciek swiech
94dc10b57c Revert "balloon: rename WSS to WS"
This reverts commit 1eb1106537.

Reason for revert: headers generated by cbindgen do not compile as expected downstream

Original change's description:
> balloon: rename WSS to WS
>
> as the working set feature approaches acceptance at the spec-level, we
> are keeping up with nomenclature changes.
>
> BUG=b/288432539
> TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
>
> Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: maciek swiech <drmasquatch@google.com>

BUG=b/288432539
No-Presubmit: true
No-Tree-Checks: true
No-Try: true

Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 19:55:38 +00:00
maciek swiech
1eb1106537 balloon: rename WSS to WS
as the working set feature approaches acceptance at the spec-level, we
are keeping up with nomenclature changes.

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events

Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-07-25 21:27:03 +00:00
Wang Ningyuan
1ba428004e devices: PCI hotplug ResourceCarrier definition
This CL defines the ResourceCarrier. A ResourceCarrier is created on the
crosvm main process, take resources needed for configuring target PCI
device, then sent to a separate process. In that process, the device is
converted to the target type with the resources. virtio-net on linux is
the only currently supported type.

TEST=tools/presubmit
BUG=b:243767476

Change-Id: I21edeadb6543c2cc989df7430fc734c94c5132ea
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4615384
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-07-24 06:24:52 +00:00
Junichi Uekawa
8d83d0d1c1 crosvm: Rename to open_file_or_duplicate.
open_file does not always open_file. It reuses given fd when it points
to a special path /proc/self/fd/XX.

BUG=b:291832160
TEST=build

Change-Id: If821834e3adbc457616c71e5b8425962286245e7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4706830
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2023-07-24 01:30:27 +00:00
David Stevens
326afd881e balloon: don't wait for replies in the control loop
Instead of synchronously waiting for balloon stat responses in the
control loop, add the balloon tube to the wait context and handle the
responses asynchronously. This allows us to get rid of the 100ms timeout
on stat requests, which in turn means we can get rid of the id field in
stat/wss messages because there are no longer "stale" requests.

The fact that balloon stat requests will no longer timeout may require
that clients handle timeouts themselves, instead of relying on a
hardcoded timeout in the crosvm implementation. This adds a new function
to crosvm_control to allow getting the balloon stats with a timeout.

BUG=b:259503518
TEST=test run DUT multivm.*
TEST=cargo test -p vm_control

Change-Id: I89c72d13e28527e432041de53cf8eda25f630bea
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4651166
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-07-21 08:03:38 +00:00
Daniel Verkamp
587d5fab3d vm_control: move send_recv_event test to base
This test is unrelated to vm_control; it is testing base::Event and
base::Tube functionality, so move it next to the existing Tube tests.

The test module was also in the middle of the file for some reason,
which caused clippy warnings in Rust 1.71.

Change-Id: I52858e71df8aa3e092b3b7d12e1232454b61c4d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4684827
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-07-13 19:59:28 +00:00
David Stevens
5006e9601a swap: Truncate the swap file gradually
Truncating a large file can result in a significant amount of IO for
updating the filesystem metadata. When swap is disabled because an app
is being launched, this IO ends up competing with the IO needed to
launch the app, resulting in significant latency.

When disabling swap because of an app launch, cleaning up the swap file
is not high priority. However, when disabling swap because of low disk
space, the swap file needs to be cleaned up immediately. As such, make
the slow cleanup of the swap file an extra parameter to disabling swap.

BUG=b:288989607
TEST=tast run -buildbundle=crosint DUT arc.SwapAppLatency
TEST=cargo test -p swap --features enable

Change-Id: Icab2a55cdb9350cbb9e380583a31b546bd8e23cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4653111
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Shin Kawamura <kawasin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-07-05 02:17:32 +00:00
Elie Kheirallah
26326dd080 crosvm: add suspended flag to crosvm run
Add --suspended flag to crosvm run to start up a suspended VM.
For the VM to resume, need to run "crosvm resume --full $VM_SOCKET"

BUG=b:285933044
TEST=presubmit
TEST=start a VM with --suspended flag. Then, send resume command and
validate the VM is working.

Change-Id: I1674e4098491555bd4ccd16f84fe4109619469c1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4615561
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-06-27 19:32:13 +00:00
Elie Kheirallah
5a91dd8d2b vm_control: sleep/wake devices when VM gets suspended/resumed
Currently commands Suspend and Resume to the VM will only sleep the
Vcpus but not devices. This results in a partial suspend/resume since
devices can still be running and potentially modifying the env (filling
up buffers, modifying variables). The aim of this CL is to put the
devices to sleep when the VM is put in suspended mode, and to wake the
devices when the VM goes back to resumed mode.
Added new flag to `suspend` and `resume` commands: `--full`
which does a full VM suspend.
Added new VmRequest: SuspendVm, ResumeVm.
Added suspend/resume test that also suspends/resumes devices, thus
doing a Full VM suspend/resume.
Also now tracking the state of devices before sleep, just like Vcpus

BUG=N/A
TEST=presubmit, e2e_tests
TEST=boot a VM, suspend, resume

Change-Id: Ia13fbdf7bb6765dd20bd3c67af5212e9c842b824
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4616827
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-06-27 19:31:41 +00:00