Commit graph

39 commits

Author SHA1 Message Date
Daniel Verkamp
3b767d235d crosvm device: add --socket-path and --fd, deprecate --socket
Similar to the recent `crosvm device fs` change c32a063c84
("vmm_host: support creating VhostUserStream from socket fd"), allow
the --fd option to use an existing connected socket from an already open
file descriptor.

Additionally, add the --socket-path option to replace --socket.

This matches the vhost-user backend program conventions:
<https://qemu-project.gitlab.io/qemu/interop/vhost-user.html#backend-program-conventions>

The old --socket option continues to be supported while callers
transition to the new --socket-path option.

Unfortunately, the argh crate does not support flattening option structs
(https://github.com/google/argh/issues/15), so it is not possible to
share the common device options currently; they are just duplicated in
the Options struct for each device.

`crosvm device net` is not updated yet, since it supports multiple
vhost-user backends in one instance and uses non-standard argument
parsing.

Change-Id: I873de8c81e41dfdf7939878b2fd572cc62a2a099
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5877432
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2024-09-24 22:10:51 +00:00
Yuan Yao
34ed5bc4d8 device: fs: add vhost-user-fs e2e test
Add unit tests for vhost-user-fs device mount, verifying successful
mounting of vhost-user fs device with sandbox abled. Test without
sandbox is not prepared, since the vhost-user-fs device need to run as
root.

A new test scenario(mount_rw) has been added to e2e test. This scenario
mounts virtiofs in the guest, then verifies data by reading from the
host's shared directory. It also creates a file in the guest, writes
data to it, and has the host verify the written data. This scenario is
tested using both in-process virtiofs and vhost-user-fs devices.

Additionally, the copy_file functionality has been refactored into a
separate scenario that runs on both virtio-fs and vhost-user-fs devices.

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

Change-Id: Icc09355fee1aae464b98fa153a98cbdd4a9e117d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5746575
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2024-08-05 10:23:03 +00:00
Daniel Verkamp
8c2a5647d1 rust-toolchain: update to Rust 1.77.2
This also upgrades the dev_container to package the new Rust version.

A few final clippy fixes are included as well.

BUG=b:344974550
TEST=tools/clippy

Change-Id: Iab4253e9cd88fdae989bb5b5170040b6af85baca
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5609084
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-18 18:21:17 +00:00
Daniel Verkamp
ac6fe3e31c Avoid clippy::blocks_in_conditions warnings
Assign the result of function calls that take closures to an
intermediate variable rather than matching on it directly to simplify
the complexity from clippy's point of view.

BUG=b:344974550
TEST=tools/clippy

Change-Id: I0e4b4201b59d8bd972c1f18e65bfd501893d58e5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5617618
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2024-06-11 00:18:47 +00:00
Junnan Wu
fb579f5eb4 e2e: console: add e2e test for virtio-console
Add three e2e test cases for virtio-console with
multiport feature.

1. Verify portname in testVM.
2. Verfiy output log from testVM in each port
3. Verify output log from testVM in each port
and verfiy modified input log from HostVM

For case3, we need to prepare a backend monitor service,
which is used to get tx message from out fifo,
change them to uppercase and send rx message to in fifo.

BUG=b:339817865
TEST=tools/run_tests --dut=vm --no-parallel -vv
    -E 'package(e2e_tests) & test(vhost_user_console)'

Signed-off-by: Junnan Wu <junnan01.wu@samsung.com>
Change-Id: I23633a3454e470a67a9c92f760048e69afd39a4c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5534197
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-05-24 00:13:39 +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
Daniel Verkamp
0c30d7e642 cmdline: make pmem config field optional
Fixes backward compatibility with old config files.

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

Change-Id: I86e7a17fa83d247b2592f9d45b4d1f83bb56f5ff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5545761
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2024-05-17 02:08:04 +00:00
Keiichi Watanabe
e2782a1b14 devices: pmem: Add --pmem flag to replace pmem-device and rw-pmem-device
Currently, we have two separate virtio-pmem flags that take key-value
pairs: --pmem-device and --rw-pmem-device.
Since the acceptable key-value pairs are same as the ones for --block,
`--rw-pmem-device=foo.img,ro=true` is accepted although it doesn't make
any sense.

So, we introduce --pmem flag that don't share the set of key-value pairs
with virtio-blk. Also, we don't need read-only flag and rw flag
separately.

The old flags should be removed once all the downstream usages are
removed.

BUG=b:340780535
BUG=b:255223604
TEST=start  VM with --pmem
TEST=start  VM with --pmem-device

Change-Id: I8e3837d396dfa452093f927db3b3460c5949a923
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5538833
Reviewed-by: Hung Nguyen <hungmn@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2024-05-16 08:29:48 +00:00
Frederick Mayle
c64b320d35 e2e_tests: wait for restore to complete before sending commands
I can't reproduce the test flake, but I suspect the issue is that, in
the test infa machines, the restore is slow enough that it causes the 5
second timeout for sending a command to the guest to fail.

Instead of immediately proceeding with the test, wait for the restore
work to finish first. This allows us to use a longer timeout and also
should make it more obvious which step of the test is slow and/or flaky.

BUG=b:333090069
TEST=./tools/run_tests --dut=host --filter-expr="test(snapshot_restore) | test(suspend_resume)" --run-root-tests --no-unit-tests --repetitions 100

Change-Id: I75ad900dcd080d4fa76ceca14974ac044b41e7d5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5446126
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-04-11 15:51:23 +00:00
Hikaru Nishida
5fe672aaf4 e2e_test: Add a test for virtio-pvclock behavior
BUG=b:295256641
TEST=tools/dev_container tools/presubmit all

Change-Id: Ie8009bedd5265c35ee5724767d324c6a821fb511
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5151637
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
2024-03-13 09:05:25 +00:00
Hikaru Nishida
1641c55bcc e2e_tests: print prebuilt revision on initialize_once
Make it easy to tell which prebuilt revision is used for the run.

BUG=b:295256641
TEST=CQ

Change-Id: Ib62d0539a248abe83291c4cec8085f929f159b2b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5343248
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
2024-03-07 05:09:04 +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
Daniel Verkamp
90911a659a Cargo.lock: update to shlex 1.3
This is only used by the e2e_tests, so it should not affect most
downstream projects.

BUG=b:321994092

Change-Id: I42bc550c273d68960174bcf577ea0555cb22ef12
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5232209
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-01-24 23:11:36 +00:00
Hikaru Nishida
ae075a5591 e2e_test: Update instructions to use locally built kernel/rootfs images
Fix the outdated documentation and scripts.

TEST=make -C e2e_tests/guest_under_test rootfs kernel
TEST=source e2e_tests/guest_under_test/use_local_build.sh
TEST=cargo test --package e2e_tests -- boot

Change-Id: Ie787296759234adf7b9e770e0da984aa3639f280
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5151636
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2024-01-05 04:50:21 +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
Dennis Kempin
73aed77b49 Run rustfmt on whole codebase with nightly enabled
Nigthly is enabled as part of https://crrev.com/c/4950268
This change contains the formatting changes resulting from the switch.

BUG=b:302055317
TEST=dev_container presubmit format --no-delta

Change-Id: Idaf2b8bae2e09c624b19d9cd3dd5fc8e4d099b3c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5067088
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-11-29 18:41:29 +00:00
Daniel Verkamp
2e137a4d81 e2e_tests: add VmConfig::with_vhost_user() helper
Change-Id: I3bb814989906abf451a02572e6e162e8c03785f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5039154
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-11-21 19:30:51 +00:00
Daniel Verkamp
c1c833ace6 e2e_tests: refactor from_env for clarity and clippy fixes
This fixes "unused return value of `std::result::Result::<T, E>::map_or`
that must be used" warnings with Rust 1.73 and also makes the code
easier to understand.

Change-Id: Id028a0859db6a7b6670e1ed6f9c9cc443a2e7c61
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5007729
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-11-07 18:39:51 +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
Zihan Chen
5db1e3c1fc e2e_tests: Add postgres benchmark
Add a preliminary version of pgbench running in e2e_tests
facilities. It currently does nothing with the benchmark result.

TEST=Can pass and produce results with `./tools/bench postgres`

BUG=b:257303497

Change-Id: If2f06cb0a9c91f5d7240094bacf86fc681062127
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4763144
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-09-20 19:00:15 +00:00
Zihan Chen
7a62cb0465 e2e_tests: Support program parsing guest command output
Delegate has been restructured to support this change, and sadly
Win64 compile exclusion has to be reintroduced to avoid compiling
this binary on Windows.

Now e2e_tests can explicitly obtain result (including stdout/stderr/
exit code/signal) from command ran in test guests.

BUG=b:257303497

Change-Id: Ibcd773b69cca9708a8dacb34cc870ca527fa32c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4787727
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-09-19 22:27:35 +00:00
Shintaro Kawamura
0b0baa608a e2e_tests: add e2etests for vmm-swap
e2e tests confirming:

* crosvm swap command succeeds
* vmm-swap feature does not break guest memory content

BUG=b:293383846
TEST=./tools/run_tests2 --dut=vm -E 'rdeps(e2e_tests) & test(swap)'

Change-Id: Ia612663987a254a4a49b394474ed2d5bc01887a3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722410
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-09-15 08:00:05 +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
Zihan Chen
befcb64a8e e2e_tests: Allow rootfs to be compressed and/or rw
Test fixtures can now automatically create required temporary or
uncompressed raw disk images from provided url to be used as rootfs
image. This allow tests with rw rootfs requirement to be executed
repeatedly.

TEST=run postgres test with new options

BUG=b:257303497

Change-Id: If0537945beb427d15be0bec2f7a7d18daf595070
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4776167
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-08-15 23:03:19 +00:00
Shintaro Kawamura
b83a5989d9 e2e_tests: abort testing as soon as crosvm exits on booting
If crosvm fails at the early stage of setup, opening to_guest fifo
blocks forever and it takes 20 seconds to timeout.

Opening to_guest fifo should be wrapped by timeout as well as
from_guest.

Check the crosvm process status periodically to abort testing earlier.

With this change, the total e2etest execution for failure case is
reduced to 0.2s from 20s.

There is better way without panicking on timeout; interrupt the blocked
open(2) for fifo by pthread_kill(). However it is too much since this is
just a test. panicking is welcome.

BUG=b:293383846
TEST=./tools/run_tests2 --dut=vm -E 'rdeps(e2e_tests)'

Change-Id: I8735a77201f930162113efa98d655f77be8d259d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4721027
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-07-28 04:27:26 +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
Daniel Verkamp
4bd4358aa4 Remove all remaining --features=direct code
BUG=b:279663365
TEST=tools/dev_container tools/presubmit

Change-Id: Iaa0b8176a54982044137b112039bf04f1e183c4e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4713506
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Grzegorz Jaszczyk <jaszczyk@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
2023-07-25 17:55:10 +00:00
Zihan Chen
8b39118abe e2e_tests: Add test to verify booting custom artifacts work
A hand-made initramfs and an updated kernel that supports initramfs
are uploaded alongside this CL. This test is added for the sole
purpose of letting the CQ to continously verify specifying custom
artifacts in e2e_tests is not broken. At its current speed, it's
not the slowest e2e tests we have.

TEST=CQ

BUG=b:257303497

Change-Id: I19baf495ce8af4805f76f16a5f831f86959d41a8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4697698
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-07-21 00:24:28 +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
Richard Zhang
dc8d88fd80 e2e_test: virtio_pci_device: Add test for cold restore
Currently, cmds cannot be sent to the guest on cold restore
boot, so some
investigation is needed. However, this still provides a useful coverage
test for cold restoring.

This CL also updates VirtioPciDevice so that cold restore won't break
for vhost user devices by returning early for sleep
and wake if the device has not been activated.

BUG=b:280607404
TEST=snapshot_vhost_user_root test passes

Change-Id: I28a12dbb6f0f009b8253c5f679dd9963b3fd12b4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4609418
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2023-06-20 17:30:04 +00:00
Zihan Chen
8f5225c042 e2e_tests: Allow TestVM to run with custom artifacts
TestVM can now be configured to run on specific local or remote
kernel, initrd and rootfs images. This allow us to broaden e2e test
coverages to more diverse use cases.

TESTED=Relevant test case passed CQ and locally

BUG=b:257303497
BUG=b:181105093

Change-Id: I1270a189105af89259371f54b7df227b3efae380
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4451468
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-06-14 22:22:38 +00:00
Richard Zhang
84ab00303e e2e_tests: snapshot vhost user tests
This test will spin up block and net vhost user device processes. This
test will be used as a smoke test and won't run during presubmits

Also refactor functions that can be shared into the fixture crate.

BUG=b:281115884
TEST=ran test. Also verified messages get sent to vhost user devices

Change-Id: Ic7e78a8ed71290fd3c42f9e15bf59a238623c49e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4519650
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2023-05-15 21:11:42 +00:00
Dylan Reid
1ae4e549e5 tests: Add riscv imports where needed
In working towards enabling unit tests, import the correct arch defines
for riscv64 where needed.

TEST=from dev container run:
```
cargo nextest run --workspace --no-default-features \
--exclude tpm2 \
--exclude tpm2-sys \
--exclude libvda \
--exclude libva \
--exclude ffmpeg \
--exclude vmm_vhost \
--exclude system_api \
--exclude gpu_display \
--color=always \
--no-run \
--target riscv64gc-unknown-linux-gnu
```

Change-Id: Ia7853de8ee0a11a5fdb716546a146f892229b0cb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4501091
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-03 16:50:25 +00:00
Daniel Verkamp
0bea3a3376 Cargo.toml: remove crosvm-direct binary
Remove the extra [[bin]] from Cargo.toml, as it is no longer used by the
chromeos-base/crosvm ebuild.

The "direct" feature is kept for now, since some of the functionality
behind that flag may still be useful (and should be moved to separate
features rather than "direct" eventually).

BUG=b:276993009
TEST=cargo build
TEST=tools/dev_container tools/presubmit

Change-Id: I78269d94913a216ebfb7f22ddc58d9cfdb6a6791
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4436629
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:54:48 +00:00
Dennis Kempin
6392b09a21 e2e_tests: Use virtio-console to speed up tests
Running all tests on a local workstation would take ~4-5s currently,
switching to virtio-console will significantly speed up the VM boot
and reduces the runtime to ~2-3s.

BUG=b:256652981
TEST=presubmit

Change-Id: I4ee87c9be4955d9dd89f30a72c91a1af96edf862
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4312801
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-08 23:16:38 +00:00
Dennis Kempin
2bc7c926cc e2e_tests: retry instead of thread::sleep in vhost tests
Adds a few utilities to that allow us to retry closures and
wait for child processes with timeouts.
These are used to repeatedly try reading from vsocks instead of
sleeping to wait for them to be available.
This is faster and more reliable.

BUG=b:256652981
TEST=presubmit

Change-Id: I2a4c74e8c1f9b8413f7afa22cce8248e74d07092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4316911
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-03-08 23:10:06 +00:00
Zihan Chen
9c9fbdc24c e2e_tests: Add strace and log settings to fixture
This allowes fixture to read these settings from env and thus allow
scripts to pass in desired testing configs without requiring a
custom-built rust test harness.
Test command below run in dev container with strace package installed
can produce debug level logs and separate per-process strace results
in designated files.

TEST=CROSVM_CARGO_TEST_E2E_WRAPPER_CMD="strace -ff --output=/workspace/stracetest" CROSVM_CARGO_TEST_LOG_LEVEL_DEBUG=1 CROSVM_CARGO_TEST_LOG_FILE=/workspace/logtest.log ./tools/bench boot

BUG=b:258316090

Change-Id: I5b0eb373802722075242e33027585d702da77e59
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4297485
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-03-02 22:07:33 +00:00
Zihan Chen
2524a185b6 e2e_tests: Restructure for initial benchmark support
- Restructured to share fixture between tests and benches
- Add bench script to run benchmark target

BUG=b:257303497
BUG=b:258316090
TEST=cargo clean && ./tools/build_release && ./tools/bench boot

Change-Id: I0ea3295839889e570032e03eec033d99b7b8e553
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064114
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-23 22:11:48 +00:00