Flag these three as allowed to be unused to make crosvm warning-free
again.
Change-Id: Id9bf18728c481484e31860836de6f0a1d1e55c5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1988282
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Linux commit 7ea6216049ff9cf250a6722cd766d99c8d1424e5 "mm/sparsemem: prepare
for sub-section ranges" added validation of memory region sizes for hotplugging.
This requires alignment of the region to 2MiB, which can be done with a
MemoryMappingArena that will pad the end of the region with read-only pages.
BUG=chromium:1031408
TEST=crostini.Sanity.artifact with 5.4 guest kernel
Change-Id: I526f23a5ef32edd3268cd23f010e2bc20f9c305a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1979257
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Guest can specify which socket it wants to connect by passing a
parameter to VIRTWL_IOCTL_NEW_CTX_NAMED.
Even after this CL, only the unnamed wayland socket is used for composition.
Additional sockets are used for IPC purpose (e.g. camera).
BUG=b:146100044
TEST=Camera works
Cq-Depend: chromium:1962108
Change-Id: Ibd8efbae1b2177cc0381d88d151643183c31b519
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1963412
Tested-by: Ryo Hashimoto <hashimoto@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
PciRoot doesn't support multifunciion which forward pci config r/w
from function > 0 to function 0, so if the vfio device have multifunction
flag, guest will find the existence of all the other functions, actually it
is from the function 0. In order to fix these extra functions, this
patch clear the multifunction flag, so guest won't probe the other
functions.
BUG=chromium:992270
TEST=pass through a device with multifunction into guest
Change-Id: I395636411e0d7d2a3729de16e638d7f6b2dde552
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954221
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
igd opregion is used by igd driver to get vbt info and exhange info
between bios and driver, but it isn't a standard pci resource, host
bios allocate, reserve its memory, and report the memory base address
through cfg_register 0xFC on native.
As crosvm doesn't have bios, it is hard to allocate and reserve opregion
for guest. Here opregion is faked as mmio memory, and let crosvm
allocate guest memory from mmio space, report its base to cfg_register
0xFC also.
guest driver read cfg_register 0xFC to get opregion base address, then rw
it throgh this address. Read is forwarded to vfio kernel and write is
ignored.
BUG=chromium:992270
TEST=crosvm --vfio /sys/devices/pci0000:00/0000:00:02.0, pass through
host igd into linux guest, the physical local display lightup and show linux desktop.
Change-Id: I1cc3618e99313fc1f88b96dcbc635f090b19340c
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1688689
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Move qcow from being its own crate into a module of the disk crate,
similar to the composite disk module.
This will allow use of qcow from disk and vice versa without introducing
a circular crate dependency.
BUG=None
TEST=./build_test.py
TEST=USE='asan fuzzer' emerge-nami crosvm
Change-Id: I77512bbe4b94faff1b5460f9796ee56505135580
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1972477
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The convert_to_qcow2 and convert_to_raw functions are no longer used
now that concierge's export operation exports the unmodified disk image
in a tarball instead of converting it to qcow2. Remove the unused
functions to clean up unreachable code.
BUG=None
TEST=cargo build -p qcow_utils
TEST=emerge-nami crosvm vm_host_tools
Change-Id: I525a9123481bd8cb6ebf022a289ecdf6e7ceaff2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1972476
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Adds bindings to the X11 display window to capture keyboard & mouse
input & send it to the guest via an EventDevice.
Original implementation by zachr@chromium.org.
BUG=chromium:1023975
TEST=None
Change-Id: I33156a8ca0b8c610a2080e3b6891cca2a865734b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1971121
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The keycode translates scancodes into Linux keycodes so they can be sent
to the virtio-input device. The translation is based on Chromium's existing
table, but converted into Rust.
BUG=chromium:1023975
TEST=None
Change-Id: Icd709e40c6d12775fdce0738f3dde3620f6c7da5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1962872
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The reset method will be called when guest virtio driver is
resetting the device. Currently the balloon/Rng/block/net
virtio drivers will re-configure the virt queue during the
reset so they required to be re-activated for using the new
virt queue configurations. To support this, need these device
models to return back the moved ownership of the important
variables so that they can do the re-activate.
BUG=chromium:1030609
TEST=Launch linux guest and follow the reproduce steps in BUG#1030609 to check
if balloon/Rng/block/net driver still complain failure.
Change-Id: I5b40fd303ea334484c590982e3e0874ea4e854ee
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1971097
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
It refers to the implementation of the Cloud-hypervisor
commit:
- vm-virtio: Reset underlying device on driver request
If the driver triggers a reset by writing zero into the status register
then reset the underlying device if supported. A device reset also
requires resetting various aspects of the queue.
The reset method of a virtio device might return false if it is failed
to reset the device or it is not implemented. In this case, we don't
reset the queues. Otherwise the queues will also be reset together with
a successful device reset.
BUG=chromium:1030609
TEST=cargo test -p devices
Change-Id: Iad2be38149e423a79d8366dc72e570a1d6eb297c
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1971096
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Breakpad requires /proc, so let's mount it (as read only) into plugin
jail. We can't initiate it from concierge as concierge can only pass
bind mounts to crosvm, whereas here we need to mount or own copy of
/proc that reflects out own namespace(s).
BUG=None
TEST=Run Plugin VM, check /proc of the plugin process.
Cq-Depend: 1982695
Change-Id: I5d673e3c8733a61afc5986f9bf110b05c45bbdce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982820
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
rust 1.40 has a new warning when there are extra parens, soRemove them.
Change-Id: Ibb565cac41ba8d72879f4cb8b949f2be30e55167
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1978140
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
We may be in state of waiting for the value for the parameter, and run
out of the parameters. In this case we should try to parse the parameter
as if it does not have a value and see if that succeeds.
This makes sure that
crosvm run ... --plugin-mount
fails with error that --plugin-mount option needs a value instead of
succeeding.
BUG=None
TEST=cargo test
Change-Id: I9f3f1f3c7e6e2ca88efed1eeea5a52dd4aae70ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1975097
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
When parsing arguments in form of "--parameter <value>", because it is
yet unclear whether the parameter needs a value or not, we first try to
parse it together with the next argument, and if that fails, try to
parse it standalone. If both fail, then we should take the error from
the first one, as it is more informative. This way, doing
crosvm run --plugin ... --plugin-mount bin --plugin-mount lib
will fail with error that "bin is not absolute path" and not that value
is missing for "--plugin-mount".
BUG=None
TEST=cargo test
Change-Id: Icc3bb0fcab4fb90e38eff3d116679091b598120d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1975096
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
As it turns out trim_end_matching() does not do what I expected (namely
trim the string when it encounters matching substring) but rather
expects to remove exactly matching suffix, so it actually fails to
remove comments. Let's switch to using splitn() that does what I want.
BUG=b:144454617
TEST=Run Plugin VM
Change-Id: Ibe8cd14d9d3c14ff99dd9abfa8f286e452d96913
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1975095
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This display isn't typically used when the virt-wl device is
available and it can lead to hung fds during plug/unplug with
external displays and docks.
BUG=chromium:1027379, chromium:1027447
TEST=
Tested five times each on R79-12607.47.0 sarien:
=> without patch --> CPU usage goes to 100% after unplug
=> with patch --> CPU usages remains normal
Change-Id: Iea57f05002acc661f36b180e9e88c37b1f1b9047
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1977100
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
FailEntry indicates an arch-specific failure to enter a VM. Treat this as
fatal to the vcpu.
Pass the u64 hardware failure reason from the kvm_run struct up to the client.
BUG=chromium:1036009
TEST=crosvm on hatch nested VM dies immediately instead of infinite looping
Change-Id: Iecb279b5b08ae1edc085717dce65e3ca46cbd30e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1977221
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Let's allow shorthand notation in the form of:
--plugin-mount=<src>[:[<dst>][:<writable>]]
--plugin-gid-map=<inner>[:[<outer>][:<count>]]
so that we can invoke crosvm as
crosvm ... --plugin-mount=/bin --plugin-mount=/dev/log::true \
--plugin-gid-map=123 --plugin-gid-map=567::5
as repeating the data for both src and destination muddies the waters
and is prone to errors.
BUG=None
TEST=cargo test
Change-Id: I6f0a075ea3b27d4ec3dcf88698069930c158e759
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967786
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
igd stolen memory isn't a standard pci resource, so guest couldn't
access it. Once guest i915 driver see its size is zero, i915 won't use
it. Here sotlen memory's size register PciCfg 0x51 is forced to zero.
BUG=chromium:992270
TEST=crosvm run --vfio=/sys/devices/pci0000:00/0000:00:02.0, pass
through host igd into linux guest. The physical local display lightup and show linux desktop.
Change-Id: I1a0a6edda5d92d32307ea8025ef96677ca62c125
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1688368
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
List of bind-mounts and gid maps can be quite long, so let's allow
listing them in text files, when convenient.
BUG=b:144454617
TEST=Run Plugin VM
Change-Id: I1218dab5a7e87b9f1ba44de6828da890fddb99fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967785
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
In order to support specifying list of bind-mounts and gid maps options
via files, factor out the parsing code.
BUG=b:144454617
TEST=Run Plugin VM
Change-Id: I772116cd77827ef722559e9fce450235fdbf6478
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967784
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Support TSC deadline mode of LAPIC timer, this can potentially increase
the precision of guest timer.
BUG=None
TEST=launch linux guest and run `lscpu`, tsc_deadline_timer is present
in the output.
Change-Id: I7adc87827a51ba8d1866ebee201759f2769ba664
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1951429
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
Other users will want to set flags on FDs. Particularly asynchronous
code that wants to set FDs as non-blocking. Add a helper that handles
fetching and or-ing in the given flags so users don't have to handle
that themselves.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Iabe438fbbb1ec305f693dbe1348930ef153edcf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1955044
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Fix the build of block_fuzzer after "devices: block: add block_size
option for disks".
It might be nice to generate the block size from the random fuzz data,
but that would complicate things (we'd have to handle failure of
Block::new due to invalid sizes), so let's leave that as a future
improvement for now and just use a block_size of 512 to match previous
behavior.
BUG=chromium:942700
TEST=`USE='asan fuzzer' emerge-nami crosvm`
Change-Id: Ia16ef6a57fc8ce4407f8ec9dda0e708302916c4c
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1962535
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Could be used by virtio-fs and virtio-gpu.
(cherry picked from crrev.com/c/1493014)
[took out PCI portions and modified commit message -- @gsingh]
BUG=chromium:924405
TEST=build and run
Change-Id: I47fd4482aa7c11e08bfb4f6c990221ae7a11a11d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1963333
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
According to ac97 spec, warm reset is specified to no-op when the device
is running. We should ignore it while the device is recording audio as
well.
BUG=chromium:1026538
TEST=Build
Change-Id: I64be922149c90be9a7a8669ef6d56591e6de632b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1960058
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Create a function move_to_next_buffer which handles incrementing civ and
piv properly.
Set the PICB register when that function is called, not when we read a
guest buffer.
BUG=chromium:968724
TEST=playback on-device
Change-Id: Ib384efceeac4be0e056c20591d93fe32b7305db6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954207
Reviewed-by: Fletcher Woodruff <fletcherw@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
Tested-by: Fletcher Woodruff <fletcherw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This allows overriding the default logical block size (512 bytes) with
other values, such as 4096 for 4K block size disks.
BUG=chromium:942700
TEST=crosvm run -r vm_rootfs,block_size=4096 vm_kernel
TEST=verify block size with lsblk --output-all
Change-Id: Ia6db05f369a76557a2afb8b48b5cc2b66cf84b01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954220
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add a new type `RunnableVcpu` for a vcpu that is bound to a thread. This
adds type safety to ensure that vcpus are only ever run on one thread
because RunnableVcpu can't `Send`. It also ensures multiple vcpus can't
run on the same thread.
Change-Id: Ia50dc127bc7a4ea4ce3ca99ef1062edbcaa912d0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898909
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The PIT implementation has the assumption that addresses are I/O port
numbers, so we should use full address mode. i8042 is also changed to
full address mode to avoid the conflict on port 0x61.
BUG=chromium:908689
TEST=None
Change-Id: Ibbb851e3a46ac7fc71576990a1618196de92e33c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945794
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Interrupt polarity is ignored by kvm since 3.15, and the irqfd interface
does not support polarity. We should not consider polarity either.
BUG=chromium:908689
TEST=Unit tests in file. Integration testing is blocked on rest of
split-irqchip being implemented.
Change-Id: Ibae23b81274f867bbf56009854611628dbb4c154
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945793
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This change enables Cuttlefish to run with a user specified display size on top
of virtio gpu accelerated graphics rendering.
This change makes the width and height an argument/flag and adds the necessary
plumbing to pass this width and height through the gpu backend.
BUG=b:134086390
TEST=built crosvm and booted cuttlefish locally
Change-Id: Idabf7ef083b2377e3ebf3b50dd0296f4bf7e8ddc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1927872
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Add support for FS_IOC_{GET,SET}_ENCRYPTION_POLICY. Unfortunately,
since the I/O direction is encoded backwards in the ioctl definitions,
these will only work with on a kernel that's compiled with a patch to
mark them as unrestricted FUSE ioctls.
BUG=b:136127632
TEST=Compile and run the vfs_crypto.c program on a virtio-fs mount
inside a VM
Change-Id: I124c5a943111b453dd44921a079a2baa1036dfd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1952570
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
When all refblocks are consumed, the loop looking for the first free
cluster would access the element at refcounts[refcounts.len()], which is
out of bounds. Modify the free cluster search loop to check that the
index is in bounds before accessing it.
BUG=chromium:1030751
TEST=qcow_fuzzer
Change-Id: Ib2384b9cf1edeaadb99be5fc67c27a55c03fc6e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1953766
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Don't use /proc/sys/fs/file-max when setting the max open file limit for
the virtio-fs device. This will fail when the value is larger than the
hard limit set for the crosvm process, unless it also has CAP_SYS_ADMIN
in the initial namespace.
Instead, just use the hard limit as returned by `prlimit64`. Increasing
the soft limit up to the hard limit is allowed even for completely
unprivileged processes. It is up to the process that spawned crosvm to
ensure that the hard limit is high enough that the virtio-fs server will
not run out of fds.
BUG=b:142344095
TEST=Start a termina VM with a virtio-fs device after applying
CL:1939193
Change-Id: I4fb4c33ffe6378ed3109fddcb0fc2bf3da850252
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1957767
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
... to allow for specifying either '--gpu' to get default params or
'--gpu=width=800,height=600,egl,surfaceless' to get custom params.
Note: this introduces some potential ambiguity if the flag_or_value
argument is the last arg specified before a positional argument.
For example, 'crosvm run --gpu something' could either be parsed
as a single value ('--gpu=something') or a flag and a positional
argument ('--gpu' and 'something'). This change currently expects
that the functor passed to set_arguments() will return an error
on '--gpu=something' in order to resolve the disambiguity.
BUG=b:134086390
TEST=built crosvm and booted cuttlefish locally
Change-Id: Ib9be604af82583a39d7bd0a403e2168ef7350389
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1929603
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The interrupt_evt/interrupt_resample_evt/queue_evts were move to activate
so the reset method has to return them back (although there is no virtio
device implemented the reset method yet).
Instead of move, another way is just clone these EventFds so that they
don't need needed to be returned.
The advantage of doing this can avoid changing every virtio device reset
method (again, currently there is no virtio device implemented the reset
method yet, but this method is going to used when needs to support the
reset of a virtio device) for returning them, which can simplify the code.
And reset method just needs to take care their own specific resources.
The disadvantage is that, the clone of an EventFd is try_clone which might
return error code (although this shouldn't happen). If in such case, the virtio
device won't be activated.
BUG=None
TEST=launch crosvm guest with virtio devices(rng/balloon/blk/net).
Change-Id: I6e55782c3ecc46bfa878aff24b85a58a7ed66365
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1925682
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Instant::Now() is called from buffer_completed in ac97_bus_master.rs
sometimes, so we need this. It seems we've already added this to
arm. I guess that code path is only triggered on "slow" devices, that's
why we missed it here in the first place.
BUG=b:139318078
TEST=manual - Run betty-arcvm-pi board under qemu.
Change-Id: I45395eea4d69942c4e9577a39c8074888b4f637c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954222
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Replace the unchecked conversion with a try_from() rather than just
truncating without warning. This gives a more useful error message when
a >4GB guest memory size is requested on a 32-bit platform.
BUG=chromium:1028747
TEST=`crosvm run -m $((5 * 1024)) ...` on kevin
Change-Id: Ib1fcf4019eefdc9ee8f93a5307802e6d6d43d01c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1937552
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
On systems where usize is 32 bits wide (e.g. 32-bit arm), the
calculation of memory_size in bytes based on the -m configuration option
in megabytes would silently overflow when the resulting value was wider
than 32 bits.
Change the shift that converts megabytes to bytes into a checked_mul so
that a suitable error is produced if the size overflows.
Additionally, change the cfg.memory type to u64 instead of usize; this
is representing a size in megabytes, so its maximum value isn't related
to the size of an object in memory anyway, and this avoids the need for
a cast in the memory_size calculation. Requesting a memory size larger
than the crosvm process can map will still result in an error at a later
stage in guest startup.
BUG=chromium:1028747
TEST=`crosvm run -m $((5 * 1024)) ...` on kevin
Change-Id: I8fef7070bab4dafff70ed54738b26d0bb7632150
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1937551
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>