Commit graph

127 commits

Author SHA1 Message Date
Wang Ningyuan
3fd003cefc e2e_tests: Use distinct tap name for each e2e test
In e2e tests, error 16 is thrown when a tap device is created when its
name is shared with another tap device. This makes the test flaky.
Distinct tap name is needed.

TEST=./tools/dev_container ./tools/presubmit crosvm_tests_x86_64
BUG=b:333090169

Change-Id: I205f69a81ef1f15c3a50c6aae5bcbcd80c30c99e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5453013
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-04-16 02:17:42 +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
Dennis Kempin
0a8b257591 Disable flaky test: host_to_guest_snapshot_restore
BUG=b:333090177
TEST=None

Change-Id: I63038ebc0d4e2b3c3c2eb79d6e502e05e0f95201
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5429055
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2024-04-05 20:14:43 +00:00
Dennis Kempin
f0fca21ffb Disable flaky tests
Flakyness is getting significant enough that CQ runs
with 3 retries are no longer passing.

BUG=b:333090069
BUG=b:333090169
BUG=b:333090177
TEST=None

Change-Id: I2409421be27f14cf6b25af30913c1b232a0a92f8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5429051
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-04-05 19:07:19 +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
917e1f4641 guest_under_testing: uprev PREBUILT_VERSION
It looks like r13 of the prebuilt uploaded does not include the change
made in https://crrev.com/c/5190792 . This CL updates the prebuilt
with the CL as well as the updates made so far.

BUG=b:295256641
TEST=tools/dev_container tools/presubmit all

Change-Id: I795762089ae8aaa42ab34ad9e9cf393429c237cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5351685
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2024-03-08 05:56:38 +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
Wang Ningyuan
e93ce109e8 crosvm: Delay hotplug until PCIe slot is not busy
If a PCI device is hot plugged into a PCIe slot with pending hot unplug
events unhandled by the guest OS, the new device may not be discovered
by the guest. Therefore, crosvm shall not reuse the PCIe slots until
guest indicates the previous events are handled. This is achieved by
  Prioritize vacant ports if available.
  If all ports are busy, wait for command completion asynchornously
  before sending hotplug signal.
An e2etest for the edge case is added.

BUG=b:325997618
TEST=./tools/dev_container ./tools/presubmit
TEST=tast run ${DUT} network.ARCIPv6Connectivity (downstream chromeOS on
a DUT with 2 ethernet adapters, ref: b:324979531)

Change-Id: I66d4ee9c88dd6c703491c1af440bc7160e8ff91b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5316598
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-03-06 11:49:13 +00:00
Wang Ningyuan
6b00bc162b e2e_tests: Add PCIe hotplug support
Currently the guest kernel does not properly support PCIe hotplug: when
a PCI device is hotplugged, PCI_EXP_SLTCTL_CCIE is not sent to notify
the hardware that hotplug is completed. This is solved by enabling the
kernel flags.

BUG=b:325997618
TEST=./tools/dev_container ./tools/presubmit

Change-Id: I6d22fbd94fb420dab3b21c87cedccccbe015d7df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5332332
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
2024-03-05 04:16:26 +00:00
Hikaru Nishida
c3a24eeb28 uprev prebuilt version
Update prebuilts to reflect the recent updates on guest_under_test images:
- crrev/c/5308635
- crrev/c/5190792

BUG=b:295256641
TEST=tools/dev_container tools/presubmit all

Change-Id: I06910645d4a6507989bc7289e59e754be773ccca
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5300045
Reviewed-by: David Stevens <stevensd@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
2024-02-21 08:58:03 +00:00
Hikaru Nishida
9510142a7c Specify patch version of e2e_test kernels explicitly
Specify patch version explicitly to improve the reproducibility of
e2e_test image generation. This patch version is determined based on r11
of the prebuilt images, which is the currently used version at this
point.

BUG=b:295256641
TEST=./tools/dev_container ./tools/presubmit

Change-Id: I6e91ce88bec4827168a61c682c3de9f0e94e4c70
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5308635
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
2024-02-20 04:13:58 +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
Hikaru Nishida
481d24e461 guest_under_test: Apply virtio-pvclock guest kernel patch for testing
BUG=b:295256641
TEST=make clean-all && make kernel

Change-Id: I7197b7a29f160fe19fcbc1c5fa53043e58088927
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5190792
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
2024-01-29 08:37:47 +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
Takaya Saeki
29ee984466 e2e_tests: Revert unnecessary version bump of anyhow/libc crates
https://crrev.com/c/5188024 bumped the version of anyhow and libc. That
broke ChromiumOS build, since we forgot to bump the versions on
ChromiumOS side. This CL fixes the build failure by reverting the
version bump. Although we also can upgrade the versions on the
ChromiumOS, they are not mandate version dump so we just revert them.

BUG=None
Test=./tools/dev_container ./tools/presubmit

Change-Id: Ie47b7219402d73493679cac3330fb958601086df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5223988
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Takaya Saeki <takayas@chromium.org>
2024-01-23 18:43:01 +00:00
Hikaru Nishida
a3cad48f93 e2e_tests: Add a helper to read guest clocks
BUG=b:295256641
TEST=make rootfs
TEST=./tools/dev_container ./tools/presubmit crosvm_tests_mingw64
TEST=./tools/dev_container ./tools/presubmit crosvm_tests_x86_64

Change-Id: I07c4ec76b4a3d3ca31b26551393befbd7907678b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5188024
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
2024-01-22 11:24:14 +00:00
Elie Kheirallah
ba5a79a9d9 e2e_tests: drop VM before doing a restore.
Some flakes are being observed, which could be calling drop on a newly
booting VM.

BUG=b:316594255
TEST=presubmit

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

Snapshot directory contents:

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

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

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

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

BUG=b:268093674

Change-Id: Ic16980629ff9321bee19f56f6e8e50f214492a7d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4739910
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2024-01-16 21:42:29 +00:00
Hikaru Nishida
cbdf02884c e2e_tests: Update use_local_build.sh to include the initrd env var
Fixup/improvement of crrev/c/5151636

BUG=b:295256641
TEST=make -C e2e_tests/guest_under_test x86_64_initramfs
TEST=source e2e_tests/guest_under_test/use_local_build.sh
TEST=cargo test --package e2e_tests -- boot

Change-Id: I94c092c87434bbd59aea25be456b9160f2882065
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5190791
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-15 01:52:27 +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
Dennis Kempin
4cba337895 e2e_tests: Clarify documentation on running modified guest
The process only works with cargo test. Not with run_tests.

BUG=b:301351266
TEST=None

Change-Id: Iaf20c01e32746d263dab297b2f13adea568e1b98
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5123311
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-12-14 23:22:36 +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
Joe Hattori
547aa2aaf5 e2e_tests: scsi: Add test cases for discard operations.
The current scsi integration test does not include test cases for the
block discard operation. Because of the lack of the test case, it could
not catch some bugs caused by other CLs (https://crrev.com/c/5019243).

This adds a test function in the e2e_tests crate for the discard
operation.

BUG=b:300042376
TEST=./tools/run_tests --dut=vm -E 'test(test_scsi)'

Change-Id: Ia7ec3850fdf493371fab8fc102d4bf7f978da696
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075901
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-12-01 12:07:56 +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
Zihan Chen
8821e8f414 jail: Generate fresh syscall frequency table
Syscall frequency table is updated with real-world data collected
from typical use cases of crostini and arcvm combined with upstream
benchmark suite.

FIXED=b:258316090
BUG=b:258316090

Change-Id: I4d832a4fc1f9c78dfa753071eea1fe1fad16f096
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068402
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-29 00:45:52 +00:00
Daniel Verkamp
b0406736ed net_util, devices: refactor platform-specific net code
The validate_and_configure_tap() and virtio_features_to_tap_offload()
functions already effectively did nothing on Windows, since the
implementations of these for Slirp were not provided. These functions
are moved to sys so the Linux-specific TAP interfaces are no longer
needed in TapTCommon.

The get_ifreq() function is only called internally inside the
implementation of the Linux Tap struct; it does not need to be part of
the TapT trait at all.

The MacAddress <-> sockaddr interop is only needed on Linux, and the
conversion can be moved into the get_mac_address and set_mac_address
implementations for Linux.

With these changes, net_sys is used only on Linux, so it can be
conditionally compiled and not included in non-Linux builds at all.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I3419a3bdb1470c4d72588fe19e43fabcdfe4e451
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046598
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 19:23:56 +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
5172482b39 crosvm: add generic --vhost-user frontend option
Deprecate the existing --vhost-user-* device-specific frontend options
and replace them with a single --vhost-user option that takes the device
type as one of its arguments.

This simplifies the device setup code significantly; there is now a
single list of vhost_user frontend devices that can be created in one
loop instead of scattering device-type-specific creation all over the
create_virtio_devices() function.

The DeviceType names are normalized for this new --vhost-user option as
well - when relevant, they use the full name rather than abbreviating it
inconsistently (for example, "blk" is now known as "block", which
matches the option used with `crosvm devices`). A few special cases are
handled with serde renames (such as "p9" -> "9p"), but all other device
types use the default serde kebab-case naming.

BUG=b:262291811
TEST=connect to `crosvm devices` and virtiofsd with --vhost-user

Change-Id: I75e9442f73af122ccfda9731331cde5c238b88fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5030974
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-11-21 19:14:01 +00:00
Dennis Kempin
5cf0a98827 dev_container: Build new container without riscv
Also adds lld, which will be used in a follow-up to improve
linking performance.
Since debian has had a stable release since then, we also
need to upgrade a few library versions in the testvm.

Swap tests that require userfaultfd were able to run without
root before. In the latest version of debian we need to configure
for unprivileged access.
Since this is the case for glinux workstations as well, let's
mark those tests as root-only and let them execute via sudo.

BUG=b:304875018,b:256905223
TEST=presubmit

Change-Id: Ied0b34e248990378a7864b4a394aa21d8f824f71
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013631
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Shin Kawamura <kawasin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-11-20 18:34:35 +00:00
Zihan Chen
60a419217c e2e_tests/benches: Add gimp benchmark for disk performance
Gimp plugin initializing, loading and file batch processing are
plausible real-world operations to run under crosvm, and can be
easily measured in an automated gui-less fasion. These operations
mainly stress small file disk performance.

BUG=b:181105093

TEST=./tools/bench gimp

Change-Id: I5891771a031f5843df4aebdfede8ae9b7ed53977
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4994843
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-11-14 18:37:11 +00:00
Vikram Auradkar
41d4b92cef tools: remove link run_test2
BUG=b:308883445
TEST=none

Change-Id: I6fe0dbf90ebaee2cd0d1585a0b3f02e1761f3826
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5027694
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-11-14 01:21:43 +00:00
Norman Bintang
8e86372078 e2e_tests: Add tests for vhost user snd
BUG=b:309032358
TEST=./tools/run_tests --dut=host

Change-Id: I599c235effd7edcec4fa4341bb7e8db04ab91321
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5004931
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Norman Bintang <normanbt@chromium.org>
2023-11-09 00:46:21 +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
Joe Hattori
c892748785 devices: virtio: scsi: Support multiple SCSI devices
Currently crosvm allows only one SCSI device. This commit enables crosvm
to handle multiple SCSI devices. Each LogicalUnit contains a disk image,
and each controller contains all the LogicalUnits.

BUG=b:300042376
TEST=guest with multiple SCSI devices boots and FIO works on all
devices
TEST=./tools/run_tests2 --dut=vm -E 'test(test_scsi)'

Change-Id: I67653e9b7656e867277afbea24987cdefa9da0fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4964673
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-11-06 01:27:43 +00:00
Joe Hattori
d3dff927db devices: virtio: scsi: Implement controlq
Currently crosvm's virtio-scsi implementation only handles requests from
the request queues. This commit handles requests in the controlq and
also implements a sub-action of MAINTENANCE IN command.

The control requests contain operations such as async task cancellation,
LUN reset, asynchronous notifications. The sub-action REPORT SUPPORTED
TASK MANAGEMENT FUNCTIONS reports the supported actions, and we
currently implement LOGICAL UNIT RESET and TARGET RESET.

BUG=b:300042376
TEST=sg_opcodes --tmf /dev/sda
TEST=sg_reset -d /dev/sda
TEST=cargo t -p devices
TEST=./tools/run_tests2 --dut=vm -E 'test(test_scsi)'

Change-Id: Ie1015d7e78c02cb46e5f20ac724838fc91dff4fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4958314
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-11-01 01:29:48 +00:00
Joe Hattori
572481fd08 jail: seccomp: Add seccomp policy file of scsi device for arm and aarch64
Currently x86_64 is the only architecture with scsi seccomp policy
file. This commit introduces the policy for aarch64 and arm devices.
From this commit, vm.Fio.scsi_* tast tests should pass.

BUG=b:300042376
TEST=tools/presubmit
TEST=./tools/run_tests2 --dut=vm -E 'test(test_scsi_mount)'
TEST=tast run $DUT vm.Fio.scsi_*

Change-Id: Ia3071d6aebe2bd427ea75a448e6208185eecbb04
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4987210
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-10-31 10:41:24 +00:00
Joe Hattori
429c10ceda e2e_tests: Add the sg3-utils packages to the test rootfs.
`sg3-utils` is the package needed for `sg_reset`, `sg_opcodes`, and
other `sg_*` commands, which sends SCSI commands to devices. This commit
adds the package to the test rootfs so that `sg_*` commands can be used
in the e2e_tests in later commit (cf. https://crrev.com/c/4958314).

BUG=b:300042376
TEST=./run_guest.sh boots a guest with the `sg_*` commands installed.

Change-Id: I644d7bda3eab054ea8e88b1e78edcf6df659a259
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4974876
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
2023-10-25 09:32:30 +00:00
Joe Hattori
c0c64df051 e2e_tests: scsi: Add test for scsi devices.
This commit implements an e2e test for virtio-scsi implementation. The
test checks if mounting a scsi device inside the guest shell succeeds.

BUG=b:300042376
TEST=tools/presubmit

Change-Id: Ib34d1e3aabcb941a3aec3dce8d6f0ac8a27d50dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4876531
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
2023-10-25 03:16:50 +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
Elie Kheirallah
790bfedf7d devices: vhost: allow non-JSON vhost-user device snapshots
Snapshot was doing a `from_slice`, which deserializes the result of
another snapshot. However, not all vhost-user devices live in crosvm
and, and those devices won't necessarily return a similar struct.
Switching to `to_value` will require a Vec<u8> as a return, and not a
`JSON`, which should be easier to adopt for other devices.

This error was encountered in AOSP when testing Mac80211_hwsim. Snapshot
returns a Vec<u8>, however the snapshot would fail, unable to snapshot
the slice. The fix was tested in AOSP and was confirmed working.
Encoutered as part of b/295028005

Bug: N/A
Test: Tested in AOSP && presubmit
Change-Id: I17dd0befa7ae95be5b014eed5ae27413ebf338b8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4897963
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-10-02 17:25:26 +00:00
Keiichi Watanabe
b167696d2b e2e_tests: Document on qemu-user-static for upload_prebuilts.sh
BUG=none
TEST=read

Change-Id: Id43b8c60c4f632b5f374da558b7cba0f600f361f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4895764
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-09-27 03:12:17 +00:00
Joe Hattori
37ff62374d e2e_tests: Add configs for virtio-scsi support.
Currently the guest kernel for the e2e test does not support virtio-scsi
driver. This commit changes the `common.config` file to make the guest
kernel support virtio-scsi driver so we'll be able to add scsi e2e tests.

BUG=b:300042376
TEST=virtio-scsi e2e test CL (CL:4876531) worked with the kernel locally

Change-Id: Ic38dd7744df59049ed6d17b346df974d1b34aa1e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4882199
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-09-27 02:20:04 +00:00
Zihan Chen
2505dd5bb7 e2e_tests/guest_under_test: Fix Makefile
I break the Makefile in crrev.com/c/4787727, this cl fixes it.

TEST=make clean && make

Change-Id: I931d2bfa8c6dfa2ce218a67a59e8cd52a682b259
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4883337
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-09-22 02:36:11 +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
Frederick Mayle
7337acac75 e2e_tests: enable vhost-user snapshot-restore test
Had to tweak the assert because the queue snapshot no longer has an
"activated" field.

The first `vm` created wasn't dropped until the very end of the test and
then the shutdown would hang (didn't debug why). Added a scope so that
everything from the first VM is dropped before we attempt the restore.

Change-Id: I9e3a10dbe08045d581742645d8305ba1951530cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4875223
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
2023-09-19 00:27:55 +00:00
Frederick Mayle
907a3a31ec e2e_tests: add pmem device to suspend-resume test
For more coverage.

BUG=b:266514902

Change-Id: I9ec4e391d3012b733d6809f6b219b96e0699635b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4868581
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-09-15 20:23:37 +00:00
Frederick Mayle
88c41512dd e2e_tests: refactor suspend-resume vm config creation
Change-Id: Iffa653fd229183c04203d821325b5d5a559fe72f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4868580
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-09-15 20:23:37 +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