Commit graph

72 commits

Author SHA1 Message Date
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
Maciek Swiech
821f544301 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>
2023-03-02 21:07:24 +00:00
Maciek Swiech
2404c5ed44 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>
2023-03-02 20:50:18 +00:00
Shengsong Tan
e32ade11dd crosvm_control: Add vmm swap (enable/disable/swapout) API
Add vmm swap [enable, disable, swapout] API to crosvm_control lib.

BUG=b:265383671
TEST=cq

Change-Id: Ib44b29b2317f3e4661c96ec3ae67b3c408e0245b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4196754
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shengsong Tan <sstan@chromium.org>
2023-01-26 07:47:48 +00:00
Daniel Verkamp
77f645b924 Cargo: update cbindgen and argh
This avoids duplicate versions of clap in the upcoming minijail update.

BUG=None
TEST=tools/presubmit --all

Change-Id: I61a5ee4268dff53b71b2a1f2140b2d00c0e269ba
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133839
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-12 22:05:11 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
Christian Blichmann
9dc9210d3d crosvm_control: Also create a static lib
This is useful for projects that build in lock-step with crosvm and want
to control a VM without having to `dlopen()` or embed
`libcrosvm_control.so`.

TEST=./tools/presubmit --quick
BUG=none

Change-Id: I9407c3e1783f55e399358bdf291a999ee8dc8892
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864925
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Christian Blichmann <cblichmann@google.com>
Tested-by: Christian Blichmann <cblichmann@google.com>
2022-09-01 07:33:29 +00:00
Daniel Verkamp
8930ba079f crosvm: update book and doc links to crosvm.dev
Replaced using this script:

git grep -l 'https://google.github.io/crosvm' \
 | xargs -n1 sed -i \
 -e 's^https://google.github.io/crosvm/doc/^https://crosvm.dev/doc/^g' \
 -e 's^https://google.github.io/crosvm/^https://crosvm.dev/book/^g'

BUG=None
TEST=mdbook build doc/book

Change-Id: I8df4e0bcc1ca1e9044df29998572393c934e29cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3795005
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-29 22:54:01 +00:00