Commit graph

80 commits

Author SHA1 Message Date
Nikita Ioffe
a555cdda96 crosvm_control: add crosvm_client_resume_vm_full api
The crosvm_client_resume_vm function actually just resumes vcpus of the
VM. This is a little bit counter intuitive, but since crosvm_control
library provide api and abi stable interface, we can't change the
implementation without potentially breaking existing clients. Instead,
this patch adds a new crosvm_client_resume_vm_full function which
performs a "full" resume of the vm.

BUG=b:360102915
TEST=tools/presubmit

Change-Id: I28d9a338f24716a62655ba0f7e2db41c148ca0f8
Signed-off-by: Nikita Ioffe <ioffe@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5999729
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-11-08 20:39:02 +00:00
Yuan Yao
18e1454927 bat: Add fake_power/resume_fake_power crosvm_control api
This CL adds two crosvm_control APIs for faking power and resuming
power from fake configuratiion. The APIs are designed for support arcvm
doze mode.

The crosvm_client_fake_power() is used to set battery's fake
configuration. The power status will always be on battery, which means
ac_online=0. Also, the maximum battery capacity that could be read by
guest is set to max_battery_capacity.

The crosvm_client_cancel_fake_power() is used to resume battery from
fake configuration. The battery device will report real host power
status.

BUG=b:353609634
TEST=write C program to call api & test manually

Change-Id: I30513847cfacc211bce885d2ff794fc7ae535c7c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5715936
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2024-10-29 07:04:36 +00:00
Yuan Yao
d88a30a9bc crosvm_control: make validate_socket_path() unsafe
The validate_socket_path() is not a safe function. Checking socket_path
not null is not enough for stating CStr::from_ptr(socket_path) is safe.
The caller also needs to ensure the socket_path points to a
nul-terminated memory and the string size should not exceed isize::MAX.

BUG=b:353609634
TEST=cargo build

Change-Id: Ia32552e5988365c2b2f3f7e522f7e0a979b63809
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5955891
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2024-10-24 09:34:24 +00:00
Daniel Verkamp
ba06509a5c vm_control: fix more wildcard re-exports
Import balloon_control items directly from that crate rather than via
re-exports from vm_control.

This fixes the fuzzer build, which depended on an implicitly imported
type via one of the conditional wildcard imports.

BUG=chromium:69590
TEST=(cd fuzz; cargo build)

Change-Id: I97d5df66741cfb64f600bebd503b73d779888440
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5630345
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-14 22:38:27 +00:00
Daniel Verkamp
247ed73ed1 crosvm_control: remove all conditional compilation
The crosvm_control library's API and ABI should not depend on crosvm
configuration options. If functionality is not available in a particular
build, the library should just provide a stub version of the function
that returns an error, rather than changing the exported symbols or
function prototypes.

BUG=None
TEST=tools/dev_container tools/presubmit
TEST=cargo build --no-default-features -p crosvm_control

Change-Id: I4428d3efe8d52a16ec78998fd83cd7d16b6b7773
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5623295
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2024-06-11 22:28:40 +00:00
Daniel Verkamp
041266d12a vm_control: fix client build without gpu feature
The vm_control client depends on crate imports that were implicitly
getting pulled in by a wildcard pub re-export. Remove the wildcard
import and import only the required types.

BUG=b:344974550
TEST=cargo build -p vm_control
TEST=cargo build -p vm_control --features=gpu
TEST=tools/clippy

Fixes: df8168ad25 ("Remove unused pub re-exports")
Change-Id: I83461203482d0174b8ca85c1cb1aadeb9afd2097
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5623434
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-11 21:23:00 +00:00
Daniel Verkamp
2cb56cf311 Fix redundant references clippy warnings
BUG=b:344974550
TEST=tools/clippy

Change-Id: I335d5972c7604345f5d1f2e7ba37a1ffef162101
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5609081
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-10 20:44:49 +00:00
Daniel Verkamp
52b8e42869 Cargo.toml: avoid "*" versions for external crates
Ensure that every Cargo.toml dependency on a third-party crates.io crate
specifies at least a major version, or a minor version for 0.x crates,
to ensure that if a new major version is published, it cannot cause API
breaks.

The versions are selected to match the ones already in Cargo.lock, so
this should have no functional change, but it will help prevent new "*"
versions from being introduced via copy-and-paste.

For rationale, see the Cargo FAQ:
<https://doc.rust-lang.org/cargo/faq.html#can-libraries-use--as-a-version-for-their-dependencies>

`minijail`, `audio_streams`, and `cras` are left as "*" for now, since
they have unusual situations (imported from a submodule and/or replaced
at build time with ebuild magic).

BUG=None
TEST=tools/dev_container tools/presubmit
TEST=verify Cargo.lock is unchanged

Change-Id: Ifa18199f812f01d2d10bfb4146b3353c1a76527c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5555656
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-05-22 01:01:42 +00:00
Federico 'Morg' Pareschi
2ce370f8ac crosvm_control: Add security key attach command
BUG=b:326838992
TEST=presubmit
TEST=tested manually on a brya DUT with the equivalent vmc patches

Change-Id: I7b62ffeb5e03e6dabc328693a94ab3d16e70567c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5364552
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Morg <morg@google.com>
Commit-Queue: Morg <morg@google.com>
2024-03-19 00:46:07 +00:00
Kaiyi Li
c28067d1d9 Reformat comments
Test: presubmit
Change-Id: I39c261d9985989873b698213c5d8b653fc13757b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5299850
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-02-15 23:30:13 +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
Vikram Auradkar
96b82c0294 clippy: enforce safety doc comment
BUG=b:316168567
TEST=none

Change-Id: I4e0a74e509ed4ef672fb9f334654a50aa5e257f1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5118513
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-12-14 17:46:29 +00:00
Wang Ningyuan
c855a3824b crosvm-control: Add pci-hotplug flag
This CL adds pci-hotplug feature flag to crosvm-control FFI. This flag
is required since otherwise vm_control for crosvm_control target would
be built without pci-hotplug flag.

BUG=b/294777126
TEST=manual VmConciergeClient DBus call workds with crrev/c/4798333

Change-Id: Iad4a7f47185025709bb2ae5029d42a06df8f555b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5098244
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
2023-12-07 08:20:29 +00:00
maciek swiech
9941e3188b crosvm_control: fix typo
s/occured/occurred

BUG=None
TEST=None

Change-Id: I53674ba93a3f56fd414113f86421e235dddf260e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4950776
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: maciek swiech <drmasquatch@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-10-18 17:34:18 +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
Wang Ningyuan
ae01cc74ce crosvm_control: Add API for add/remove tap device
This CL adds the add and remove of tap device to the crosvm_control API.

TEST=presubmit tests.
BUG=b:294777126

Change-Id: I4d2388bf785b72388ede5245cb6ebbe1f9331b3d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4846022
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
2023-09-10 03:26:30 +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
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
7912625a3c balloon: rename WSS to WS pt 2
remove 'old' pre-transition function definitions

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=emerge-volteer crosvm && emerge-volteer vm_host_tools

Change-Id: I50bbe777185948fcfe265236da43c0e47d7e762b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4718766
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-08-03 21:28:24 +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
Daniel Verkamp
bd1f66df63 crosvm_control: require vm_control balloon feature
crosvm_control unconditionally imports vm_control::BalloonControlCommand
which is only available when vm_control has the "balloon" feature
enabled. Declare this dependency in crosvm_control/Cargo.toml.

Fixes building crosvm_control with --no-default-features.

BUG=None
TEST=cargo build -p crosvm_control --no-default-features

Change-Id: I0f7a956318bd144fcbe9e09ee8319e992df87d5e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4736333
Reviewed-by: maciek swiech <drmasquatch@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-08-01 20:22:56 +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
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
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
David Stevens
53dbfeaaf3 crosvm_control: Remove temporary swap disable API
Delete temporary crosvm_client_swap_disable_vm2 API.

BUG=None
TEST=None

Change-Id: I10f9166e3f5f12d11b0618582ee959e82000900d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4664190
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2023-07-10 04:36:31 +00:00
David Stevens
f3bc60560e crosvm_control: Update primary swap disable API
Update crosvm_client_swap_disable_vm to the new argument format. The
temporary crosvm_client_swap_disable_vm2 function will be removed in a
followup change, after downstream clients stop using it.

BUG=None
TEST=None

Change-Id: Ice624eaaacec7910a00e09a4b6e94a0635ecf7dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4664189
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2023-07-07 05:23:20 +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
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
maciek swiech
5fea452007 balloon: missing #[repr(C)]
the BalloonWssConfigFfi struct was missing a #[repr(C)]
annotation, causing the generated header file to not include the struct
definition. this patch also removes a couple unneeded constants.

BUG=None
TEST=built crosvm_control, checked generated header

Change-Id: Ic02c2145d16143257f5096d4811a4012bb827d69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4607224
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-06-13 18:05:33 +00:00
maciek swiech
d1612ed53c balloon: permit variable number of WSS bins
for ease of initial implementation the number of WSS bins was hard-coded
to 4, however the WSS spec and kernel driver permit any number of bins
between 2-16. this patchset introduces a crosvm run flag which allows to
override the default 4 bins.

the protobuf-encoded WSS report will scale the number of bins correctly
in the return value, however the C crosvm_control_* API will always use
an array of 16 buckets, with a `num_bins` parameter that indicates how
many of them are actually valid. this has been done to preserve safety
across the ffi boundary.

this patchset also removes the sending of an initial WSS config. the
coordinating program (e.g. concierge et al.) is responsible for sending
the config to the guest after boot via the crosvm_control_* API. this is
largely due to the fact there may be various desirable configs for
varying scenarios and it does not make sense to have a baked-in default
config anymore.

BUG=b/278118696
TEST=https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-variable-bins

Change-Id: Ifaef2933a13a59d8d2580b5a9e283568fe6e86cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4577421
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-06-05 19:47:09 +00:00
Vikram Auradkar
0e1c85f293 clippy: Disallow new_without_default
BUG=b:283512997
TEST=none

Change-Id: If10b73f0cd686ff1a1a17e4aa3260f01e1ee8db5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546662
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-05-22 21:14:06 +00:00
maciek swiech
fac9000051 balloon: use protos for registered events
since the RegisteredEvent model is effectively an external API, switch
to using protobuf as a more formal/stable means of communicating
messages. also introduces exporting the registered_events.proto file as
part of crosvm_control build, alongside the currently existing header
file.

this patch also introduces feature-gating for registered_events and
protos so as not to bring in too many third party dependencies for a
base build.

BUG=b/278117550
TEST=run bzImage locally
TEST=sidecar program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-proto

Change-Id: I5d91d87f7807effc125352caf5c75eee2593f70d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-05-22 19:28:45 +00:00
Shintaro Kawamura
ca6adae33c crosvm_control: add swap status/trim command support
SwapStatus, SwapState, SwapStateTransition, SwapMetrics are directly
contained into crosvm_control.h

SwapState is translated as C++ enum.

SwapStateTransition::time_ms is now u64 because u128 does not support
repr(C).

Changed usize in the structs to u64 because usize is translated as
uintptr_t.

BUG=b:265386761
TEST=cargo build -p crosvm_control

Change-Id: Ia9df56d40c1884067a712620e0fc797e07af77a2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4486549
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-08 01:37:43 +00:00
Daniel Verkamp
6eec4b7768 Fix cargo doc warnings from Rust 1.68
Some type parameters in <> were being mis-parsed as HTML tags.

BUG=b:276487055
TEST=tools/cargo-doc # with rust 1.68.2

Change-Id: Iaa9ec6cf94a6084cfdf323bb04c643396a320889
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485758
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-04-28 17:22:01 +00:00
Junichi Uekawa
810d131d67 crosvm: Uprev cbindgen dependency
Match version available in Debian.

BUG=b:265082456
TEST=build

Change-Id: I8fc3b65fb8bb6cc3f7e512921d96c8cbbc4291b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364561
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-04-26 00:26:32 +00:00
Maciek Swiech
f4c5cd8e42 balloon: return balloon_actual with wss
balloon size is useful for balloon policies using working set size, so
we return the balloon-device cached balloon size. unless there is some
error in adjustement of the balloon, this should reflect that real
balloon size and saves having to query the guest an additional time.

BUG=b/278119213
TEST=run bzImage

Change-Id: I7c6b558358b8db099a737430e8431997bb110b2b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428532
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Maciek Swiech <drmasquatch@google.com>
2023-04-17 21:32:23 +00:00
Maciek Swiech
7ac2aa0704 crosvm_control: add SAFETY comments
per
https://std-dev-guide.rust-lang.org/documentation/safety-comments.html,
adding safety comments to unsafe functions and blocks.

BUG=None
TEST=None

Change-Id: Ie38a8a559aec2ad7ce7b911439f3f943a68fc013
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4414430
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Maciek Swiech <drmasquatch@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-12 19:52:21 +00:00
Maciek Swiech
86df65f6d2 balloon: working set size config command
this patch adds the crosvm_control command (and internal implementation)
to send a new WSS config command to a guest balloon driver. included is
a refactor of how wss op notifications are dispatched in the balloon
device.

BUG=b/271891148
TEST=run bzImage
TEST=socket-pinger program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger

Change-Id: Id9696b0e82b3ba54d87cd0928070c55da9a77d1f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4415596
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-04-11 19:36:14 +00:00
Daniel Verkamp
7182457d19 crosvm_control: make all pub functions unsafe
These all deal with raw pointers passed as parameters, so they should
not be safe functions.

Fixes new clippy warning not_unsafe_ptr_arg_deref in Rust 1.68.

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: I4f3f49ebdbb5d9afb2bf5e4ee53ced13021285b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391114
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-11 02:18:23 +00:00
Daniel Verkamp
668b0bad59 crosvm_control: remove unnecessary references
Fixes clippy warnings in Rust 1.68

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: I2a88639edb058a07c9944337712530b4ea7abffa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391104
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-11 02:06:21 +00:00
Maciek Swiech
61bf707120 balloon: bring into WSS spec compliance
for wss, s/intervals/config, add new field to track bytes for ANON and
PAGE memory.

BUG=b:271757427, b:273212204
TEST=crosvm run bzImage

Cq-Depend: 4404310
Change-Id: I62696135d1e3af9219ba819f112a1ed128e39600
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405307
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-04-07 20:39:08 +00:00
Maciek Swiech
eebc110fbf balloon: implement wss reporting virtio-balloon extensions
this patch implements the virtio-balloon extensions proposed in
go/roziere - namely adding the Working Set Size vqueues and listener on
the wss vqueue. in addition we add a crosvm_control command which allows
a user to request that the balloon device send a request to the driver
to produce a WSS report, similar to asking for balloon stats.

BUG=b:271757427,b:273212204
TEST=sidecar process, available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger
TEST=deploy to DUT, restart termina and arcvm

Change-Id: I45753f523aae97d14bfc5dcbad5ddfcb70d10beb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4260158
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-04-05 22:23:04 +00:00
George Burgess IV
4f2ba33100 crosvm_control: explain why we need rerun-if-changed; remove nop one
These lines were originally inserted as a workaround, but now that the
`rerun-if-env-changed` lines being emitted by this build.rs have been
found, this workaround has been promoted to a bugfix. :)

build.rs is implicitly `rerun-if-changed`, so that bit can be removed.

BUG=b:275376804
TEST=CQ

Change-Id: I480c33f52fc27252263adb297b65d913f78a3030
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4402291
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: George Burgess <gbiv@chromium.org>
2023-04-05 14:16:00 +00:00
George Burgess IV
c8b89e9fee crosvm_control: add rerun-if-changed blocks
These are a workaround for b/275376804.

BUG=b:275376804
TEST=Built with these. Changes to src/lib.rs cause build.rs to run.

Change-Id: I89d1f340fd53a90d9ed327517c52c85f86565426
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4385870
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: George Burgess <gbiv@chromium.org>
2023-03-30 23:58:30 +00:00
Kameron Lutes
6c6966ecfc crosvm_control: Add Build Time C Compilation Check
Adds a build time compilation check for the generated crosvm_control.h

BUG=b:271789981
TEST=CQ, apply crrev/4237140 and observe build failure due to C compile
error

Change-Id: I57867894a975aa0a48f989051bb4243bf97f57e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4333206
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-03-16 00:01:44 +00:00
Maciek Swiech
d7bfa2dc54 crosvm: reland socket control mechanism
crrev.com/v/4237140 was reverted in crrev.com/c/4310064 due to the
generated header file not defining the RegisteredEvent type. along with
re-reverting the original cl (and corresponding bugfix cl) this patch
introduces a RegisteredEventFfi type which mirrors the original
RegisteredEvent type but should be exposed in the generated header file.

BUG=b:269609274
TEST=sidecar process (patch: crrev.com/c/4276642)
TEST=cargo build, header file inspection

Change-Id: I4a17163e36eb466a540a72d2bb4356419739c974
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4311831
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-03-10 18:49:13 +00:00
Shin Kawamura
0ce2557fc5 Revert "balloon: add event registration mechanism for sidecar processes."
This reverts commit 2404c5ed44.

Reason for revert: This fails to build crosvm C interface and blocking ChromeOS CQ.

Original change's description:
> balloon: add event registration mechanism for sidecar processes.
>
> this patch introduces a mechanism for so-called 'sidecar processes' to
> register as event listeners, consuming events that are generated in
> various parts of crosvm. in this patch we focus on events that enable
> roziere cooperative ballooning, but lay the groundwork for a more
> general framework.
>
> the general idea is that a sidecar process would open a listening socket
> and register the path with crosvm for a specific event. crosvm will pass
> along a handle to a registered event tube to the appropriate device (or
> other internal component) which would then be responsible for passing
> along events. once events arrive back in the crosvm control loop, an
> attempt is made to dispatch the events to any registered sockets.
>
> BUG=b:269609274
> TEST=sidecar program that performs registration and receives events
>
> Change-Id: Iaff41aad8f862ed99a104c75623caaabc53e9e88
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237140
> Commit-Queue: Maciek Swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

Bug: b:269609274
Change-Id: I135e0d55bb296cf591548b7bd4feffc7ff9f3447
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4310064
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2023-03-06 06:51:35 +00:00
Maciek Swiech
d4565a3cf3 Revert "crosvm_control: split into inner and outer crates"
This reverts commit 821f544301.

Reason for revert: breaks builds and is not terribly important at the moment

Original change's description:
> crosvm_control: split into inner and outer crates
>
> since the crosvm_control crate is build as a cdylib, the functions are
> not able to be used from other rust code. this patch moves all actual
> implementation into an inner crosvm_control_rust crate, and has the
> outer crosvm_control crate import and expose all of the inner code.
>
> Change-Id: Ib05d5df8bb138680f3e77a8837b1103854c0b316
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4276641
> Commit-Queue: Maciek Swiech <drmasquatch@google.com>
> Reviewed-by: Dennis Kempin <denniskempin@google.com>

Change-Id: I2fb1b8b6337b58d69074e63b5ed81771402e616f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4305342
Auto-Submit: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-03-02 23:02:52 +00:00