Avoid the possibility of tests reusing the same socket path by using a
known unique directory from tempfile::tempdir().
BUG=b:274145919
TEST=tools/dev_container tools/presubmit
Change-Id: I883e223617fb465cdfbff5a45509098487b62b3b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4348699
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Replace use of env::temp_dir() with tempfile::tempdir() to ensure each
test gets a unique temporary directory name. This avoids test failures
when running multiple tests simultaneously.
BUG=b:274145919
TEST=tools/dev_container tools/presubmit
Change-Id: Iac3a248d52830f3efafd8a954d1cc9633f71f301
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4350606
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This changes the default for tools/presubmit, which will also change
the default for Luci.
Added a few tips into tools/run_tests to clarify that --dut=vm is
the default and how to manage the vm.
BUG=b:273335986
TEST=dev_container --podman presubmit --no-delta
Change-Id: I0b4f5026838c10585342efa935e10dca070aa131
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346976
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The SafeDescriptor type manages the lifetime of the file descriptor,
which simplifies the socket wrappers (each wrapper no longer needs to
manually implement Drop to close the descriptor, for example).
Also remove unneeded RawFd-related functions, replacing them with
RawDescriptor and SafeDescriptor equivalents.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I634a19922ec24d06071b21247c79761cfc21a79a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4322266
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
A new mount is required by borealis VM to store precompiled cache
downloaded by the guest to store in the host. Note that the
downloaded caches will be validated before usage.
Further details at go/borealis-shaders-stable.
BUG=b:267113203
TEST=`vmc launch borealis`
Change-Id: Id6c13765d9d1522962824eeb1f26044db0e8edf3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4306415
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Max Lee <endlesspring@google.com>
This change tweaks the `--restore` flag to be compatible with the
(upcoming) vCPU restore code. Restoring the vCPUs requires them to have
been started (otherwise we'll essentially deadlock), so now we do the
following:
* Tell the vCPUs to start in a suspended state.
* Wait for vCPU init to finish.
* Perform the restore.
* Tell the vCPUs to start running.
I've left the Windows half unimplemented because there are some missing
pieces + I expect a lot of churn in this area and so it will probably be
less work overall to port the restore code once the Linux half is
actually working.
BUG=b:269174485
Change-Id: I07588e887789498a951d9427391415afcb646e96
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4343614
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Add an option to dump the crosvm-generated devicetree blob. This option
can be helpful in understanding what devices are reported to the guest
VM and help diagnose issues related to improper devicetree.
Bug: 249043819
Change-Id: Id18ddf0838520c84f648ed8584db2ef8235ed636
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 7acecab0b1d4f0428b71823f0e2982d385213279)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346951
Commit-Queue: Steven Moreland <smoreland@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Move generic implementation of BlockedSignal to base sys.
Change-Id: I459ca424a633dc3fc2a5dec625dde8e5878132c0
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 5f51fa4ae3b979972d273dff4c224c1999b6e641)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346950
Reviewed-by: Dennis Kempin <denniskempin@google.com>
If the input to ioctl_expr is a u8, it cannot be implicitly upcast to
u32. Cast the inputs, not the output, to IoctlNr.
Change-Id: I2bce639bd13f49c92fadedb146ef09171b7128ef
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 585dbff782e96d0531734d37ec2dae958f6ff6c1)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346949
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Today, it supports only loading ELF64 images. This change
allows to accept both ELF32 and ELF64 images.
BUG=b:261538125
TEST=cargo test -p kernel_loader -p aarch64
Change-Id: I54d125226abdfa21047f5590006e69e83a1b3fc5
Signed-off-by: Sahitya Tummala <quic_stummala@quicinc.com>
(cherry picked from commit 1abc72e6fea6d00d9e025251e354aa862f9e12e9)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346948
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Qualcomm has developed a wrapper program which uses CrosVM's libdevices
crate. Some Qualcomm products use 128 as virtio block queue size and
some of them use 256 depending on the memory constraints.
Number of virtqueues per device may also vary on different products.
This change lets virtio block new() function accept arguments that
specifies virt queue size and number of virt queues.
Qualcomm's wrapper program calls new() method with required number of
queues and queue size at runtime.
When they are not provided at runtime, they get their default values.
(cherry picked from commit 777d6aeeb07b505d0d76dcab881bd25b09796547)
Change-Id: I8613633630fd1d0e285a117d2778db26c97e651f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346947
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Gunyah hypervisor supports virtio-mmio transport only in some
products on which CrosVM is also used. Qualcomm has developed
a wrapper program which uses CrosVM's libdevices crate.
Gunyah hypervisor has some optimizations for how virtio-mmio
register access are handled. Normally they are synchronous access -
meaning any access of virtio-mmio register by a guest will cause
a fault, which requires blocking the guest VCPU until the access
can be served by CrosVM running in a different VM. Since that could
induce long delays for guest (esp since the OS in which CrosVM is
hosted is considered untrusted), Gunyah hypervisor caches all
virtio-mmio registers in its address space.
Any read access is handled without requiring intervention from CrosVM.
Write access is handled asynchronously - i,e a write will cause
hypervisor to updates its copy of the register, unblock the guest vcpu
and simultaneously notify CrosVM about the update.
By the time CrosVM gets to notice the update, guest could have
progressed lot more.
This works reasonably well for many devices and registers.
One problem case is writes to VIRTIO_MMIO_INTERRUPT_ACK, which signals
the guest having seen an interrupt. CrosVM seems to rely on synchronous
handling of this register write. Any attempts to kick guest via signal
method of 'struct Interrupt' (devices/src/virtio/interrupt.rs) skips
sending a kick if prior kick is "not yet" acknowledged, which fails
if writes to VIRTIO_MMIO_INTERRUPT_ACK is asynchronous.
This patch introduces a 'async_intr_status' flag in signal method which allows
the kick to be always delivered to guest independent of the status of
acknowledgement of prior kicks. Hypervisor will queue kick requests and
deliver another kick after current kick is processed.
Its expected that only the Qualcomm wrapper program will initialize the
interrupt object with 'async_intr_status' flag set and hence the upstream
CrosVM should not be affected because of this change.
BUG=b:243368499
(cherry picked from commit 7069619ef727acc93c81f72ef390c465e63b3b70)
Change-Id: I691a12ed92af81533b792243c1a7fd06f6b8e281
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346946
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This is done similar to x86 platform to check if a kernel image have
ELF signature first and if it doesn't, then it is passed to the Image
loader as a fallback.
BUG=b:232360323
(cherry picked from commit f319faf8a070e5e5a7744ad0f64206d3a2704811)
Change-Id: I4604c7fc527c0fdf49971233ddba08fee5be4a8f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346945
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Remove KVM-specific code from the generic aarch64 module by providing a
generic enum for hypervisor-specific vCpus to use instead:
VCpuRegAArch64.
(cherry picked from commit cfd5acd14f924fe17f09c007fb20bf2abc632a79)
Change-Id: I486ea24993493c314ed6dacd5cedeeb135225135
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346944
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Move KVM-specific code to "run_kvm" function in preparation for
supporting different hypervisors.
(cherry picked from commit c66faccc3c663a2e8da356d24f6dffcbe2b32b4b)
Change-Id: Iaf7136bf12332672b0a67ca5dac5b654115fe2cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346943
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Simple rename to emphasize that vcpu_ids are not KVM-specific.
(cherry picked from commit 4450ecc21609191210065c5acb5fa1c6f1ad1daf)
Change-Id: I4e702338d8aa1260f9205b19db3eced48661be01
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346942
Reviewed-by: Dennis Kempin <denniskempin@google.com>
When IER.THRE is set, the hardware should trigger interrupt (the better
way should also examine the LSR.THRE bit, but crosvm always enables
LSR.TRHE, so it doesn't need to check it).
When IER.DRI is set and there is data received that hasn't been read by
a guest, the hardware should trigger a receive interrupt too.
BUG=None
TEST=Run VxWorks operating system on crosvm.
Change-Id: I7b59a7dd84980c0c7b353e346e4c81a02dec4057
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4329111
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Since we are going to refactor the vhost-user vsock device, add some
integration tests to make sure we don't break anything.
BUG=b:217480043
TEST=cargo test -p e2e_tests --test vsock
Change-Id: I2a8eaa6c74f8d86aa164ebd92543fe280bc7906c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4337340
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
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>
This seems to be purely reserved for alignment reasons; the kernel
never touches it, so we don't need to serialize/deserialize it.
BUG=b:266515147
TEST=tools/presubmit
Change-Id: I3074d24f50a8e0e86340c398885c2fbef1410a88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4342173
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
We switch from the chromeos-5.10 kernel with crostini configs
to a stripped down config building the mainline 6.1 branch.
This allows us more control over the guest kernel for testing
and significantly speeds up e2e tests (~4s -> 1.2s for all
tests run with nextest).
The rootfs is switched to Debian as that's what we use elsewhere
which makes this easier to maintain.
BUG=b:256652981
TEST=presubmit
Change-Id: Ib3897b8dbf3391eefdb1eedb69ec7555f4c77344
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4326888
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Most users are not the owner of /dev/kvm, but have access to it
via group permissions.
To ensure that we get the same group permissions on the mounted
/dev/kvm device inside the container, we need to preserve groups
in the container namespace.
BUG=b:273335986
TEST=tools/dev_container --podman x86vm run
Change-Id: Ifb61e6e1ab9af9d237b3e17b9bda7535d16082b2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4341239
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This will allow devcontainer.json files to always use the latest
container without manually upreving the version.
BUG=b:273529589
TEST=open dev container in vscode
Change-Id: I71d58eb2936097bd81dfcc0872d362b2c6b9e388
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4341238
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Add get/set VCPU_EVENTS as required to snapshot the full state of the
VCPUs for suspend/resume.
BUG=b:266515147
TEST=build and run VM
Change-Id: Iabca21b67a0eb9906d2e639a616e3f0826dfa659
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4327459
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
The virtio specification for the network device allows the driver to
negotiate two features related to queue counts:
- VIRTIO_NET_F_MQ enables use of more than one rx/tx pair
- VIRTIO_NET_F_CTRL_VQ enables an additional control queue
The crosvm implementation of virtio-net assumed that the driver would
support both of these features and neglected to check the result of the
feature negotiation process; this would result in the net device failing
to start if a driver did not enable the CTRL_VQ feature and did not
provide the extra queue required when that feature is enabled.
Additionally, if the driver did not negotiate the MQ feature, the device
would fail to start up if the maximum supported number of queue pairs
was greater than one.
Fix both of these issues by checking the features acknowledged by the
driver at activate() time and adjusting the expected number of queues
accordingly. As part of this change, the control queue becomes optional,
and the previous code used the presence of the control queue on a worker
thread to indicate whether to perform interrupt resampling work; this
change splits that into a separate handle_interrupt_resample flag passed
to the worker run() function so that the interrupt is resampled even
when the CTRL_VQ flag is not negotiated.
BUG=b:272536271
BUG=b:164505993
TEST=tools/dev_container tools/presubmit
Change-Id: I3dd65c7b134c75f5fc6881ed33c7b8df83c48c36
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4326887
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dmitrii Merkurev <dimorinny@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Adds command line options to move the vGPU threads housed within crosvm
and the vGPUserver threads housed externally into separate cgroups.
This will give us the ability to perform some tweaks/experiments
with the affinity masks of these threads as a group.
BUG=b:269139377
TEST=Launch Borealis VM, ensure command line options work as expected.
Change-Id: I558673e616e0344bae2407db1ff693902816daac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4304743
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Isaac Bosompem <mrisaacb@google.com>
The dev_container no longer has a --reset flag and instead uses --clean.
Updates docs to reflect this.
BUG=b:273389824
TEST=cq
Change-Id: Ic8bdf1900a19e525d1150ebc623ab9d6bd2eec09
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4337296
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
if a sidecar process does not gracefully unregister their listening
socket we should not keep it around forever.
BUG=b:269609274
TEST=crosvm run example-ubuntu-image
TEST=deploy to dut and launch crostini/arcvm
Change-Id: I2e620d97da8f63dc73c2432146273b112770ca84
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4308039
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
we currently store UnixSeqpacket sockets for registered event listeners
- this causes us to clone (and dup) each time we want to send info on
said packets. instead, store the tubes.
BUG=b:269609274
TEST=crosvm run example-ubuntu-image
TEST=deploy to dut and launch crostini/arcvm
Change-Id: Ifeab6d6beeebc8f9171f233e5e8d21aae6d6b9ab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4308038
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This creates a makefile for rutabaga_gfx. Most package managers
seem to still use Cargo to compile, but not packagement. We need
to install headers and the library.
I looked into to cargo-c, but it was just easier to open code it.
BUG=b:173630595
TEST=sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
make and run rutabaga_test
Change-Id: Ibd68ecd0c6215cc36bc104d843847ee47d02123e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4335238
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Nothing calls this code, so it should be okay to remove it.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I5f079dc9e6e15178506b801b7266d8bd0351ddbb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4321329
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>