summary refs log tree commit diff
path: root/src
Commit message (Collapse)AuthorAge
* devices: jail serial deviceZach Reizner2019-10-10
| | | | | | | | | | | | | | | | | | This change plumbs the jail throughout the arch specific device creation process. It also adds a custom callback support for the ProxyDevice so that the main process can interrupt the child serial process when it has incoming bytes. TEST=crosvm run BUG=None Change-Id: I6af7d2cb0acbba9bf42eaeeb294cee2bce4a1f36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1752589 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
* sys_util: allow adding handlers for all signalsFletcher Woodruff2019-10-03
| | | | | | | | | | | | | | | | | | Currently, sys_util's register_signal_handler only permits handlers for real-time signals. Rename that function to register_rt_signal_handler and add a new register_signal_handler that supports all signals, then update references to the old name. BUG=chromium:1008990 TEST=builds Change-Id: I455e14c562cd1f2ca4b308b4e38c503845321926 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1836185 Tested-by: Fletcher Woodruff <fletcherw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
* vfio: Setup dma map for vfio deviceXiong Zhang2019-10-01
| | | | | | | | | | | | | | | | | For each guest memory region, setup the corresponding gpa to hva map in the kernel vfio iommu table. Then the kernel vfio driver could get the hpa through gpa. Device could use this gpa for dma also. BUG=chromium:992270 TEST=none Change-Id: I04008d68ab2ed182a789d6ee8c97a0ed9e1e4756 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581141 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* vfio: Integrate VFIO device into pci device modelXiong Zhang2019-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create VFIO device and VFIO PCI device in create_devices() function, and intergrate it into PciRootBridge, so guest could see this vfio device. Add a vfio config parameter, this config point to passthrough or mdev device sysfs path. For passthrough case, first user unbind host device from its driver, then bind host device to vfio-pci. Like: echo 0000:00:02.0 > /sys/bus/pci/devices/0000:00:02.0/driver/unbind ech0 8086 1912 > /sys/bus/pci/drivers/vfio-pci/new_id Finally pass the sysfs to crosvm through --vfio=/sys/bus/pci/devices/0000:00:02.0 For mdev case, user create a mdev device through echo $UUID > mdev_type/create, then pass this mdev device to crosvm like --vfio=/sys/bus/pci/devices/0000:00:02.0/$UUID BUG=chromium:992270 TEST=none Change-Id: I0f59d6e93f62f9ab0727ad3a867d204f4ff6ad2d Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581140 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* linux: drop VM before exiting to allow cleanupDaniel Verkamp2019-09-17
| | | | | | | | | | | | | | | | Clean up the `linux` object (which contains the devices) before the control sockets passed to `run_control` are closed. This allows crosvm to shut down cleanly without any error messages about short reads from the control sockets. BUG=chromium:992494 TEST=exit crosvm without errors Change-Id: I1040c2f9ecbd03f820c7082da3327962ecc445f1 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1802155 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Extract disk creation logic out of qcow and src.Cody Schuffelen2019-08-28
| | | | | | | | | Bug: b/133432409 Change-Id: Iba25d5f6bb5f60619bb2f5a3d72ddfd3a81650b4 Signed-off-by: Cody Schuffelen <schuffelen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691460 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* crosvm: silence unused code warning for NonZeroU8Daniel Verkamp2019-08-22
| | | | | | | | | | | | | | | | After a recent refactoring of display support, this import is only used when building with the "gpu" feature enabled. Put it behind a cfg check to avoid a warning when building without gpu support. BUG=None TEST=cargo build TEST=emerge-nami crosvm Change-Id: I4e407e09daa93c74203f3472dad5a3713b99d122 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1762448 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* plugin: switch to using /mnt/empty for rootDmitry Torokhov2019-08-19
| | | | | | | | | | | | | | | We have stopped mounting /var/empty as we have decided that /mnt/empty should be used instead. BUG=chromium:933582,b:139436326 TEST=Start plugin VM. Change-Id: I50bbf9d4a9ebd86d54cb9ecc67891921f46e27e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1757343 Tested-by: Dmitry Torokhov <dtor@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Dmitry Torokhov <dtor@chromium.org>
* crosvm: add x-display argument for choosing the X11 gpu displayZach Reizner2019-08-08
| | | | | | | | | | | | TEST=cargo run -- run --gpu --x-display :0 BUG=None Change-Id: I76b4b33a6b14cb6fad322ffa95f00cce976f81a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1670550 Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* split crosvm into a library and a main "crosvm" binaryZach Reizner2019-08-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change has 3 parts: - Modify the Cargo.toml to point at the bin and the lib source. - Move modules and Config struct into the lib source - Fix the argument/plugins module's doc comments which had never been tested. The motivation for this change is to make testing crosvm's major functionality (booting guest kernels, emulating hardware, etc) easier to do from a cargo test. Being able to launce a crosvm config via the API instead of the binary's command line will be possible with this change. A side benefit is that this also enables doc tests in the lib side of crosvm. The doc tests in binaries are not run due to a limitation in how they get tested by cargo. TEST=cargo test ./build_test kokoro/kokoro_simulator.sh emerge crosvm BUG=None Change-Id: I9d4b3a24231b895e8dfaf9e7b0f2b33350772041 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1730333 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org>
* Allow to connect standard input to a serial port other than the guest consoleJorge E. Moreira2019-08-03
| | | | | | | | | | | | | | | | | | | | | Before this change, setting console=true on a serial port caused that port to be the one connected to the crosvm process' standard input. By adding an extra 'stdin' argument to the serial parameters it's possible to make those concepts independent. Just as with the console argument, stdin defaults to serial port 1 (ttyS0) when not provided and it's possible to set no serial port connected to stdin (or set as the console) by defining the first serial port without the stdin (console) argument. BUG=b/138616941 TEST=boot debian guest in debian host, boot cuttlefish in debian host Change-Id: I7273e6860218521073df93a4ad71e31c7da522a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1731139 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Jorge Moreira Broche <jemoreira@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org>
* gpu: Add sandboxing support for pvr.David Riley2019-08-01
| | | | | | | | | | | | | BUG=chromium:892280 TEST=glxgears with virtio-gpu on hana Change-Id: Ib92b21c124e30eacb3fc28558e2eb5d8d4a92567 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1717739 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: David Riley <davidriley@chromium.org> Commit-Queue: David Riley <davidriley@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: David Riley <davidriley@chromium.org>
* gpu: Add sandboxing support for mali/ARM.David Riley2019-08-01
| | | | | | | | | | | | | | | | ARM platforms have different library locations and also required GPU devices to be availble to the GPU process. BUG=chromium:892280 TEST=glxgears with virtio-gpu on kevin and nami Change-Id: If1baeb1edda76d057e88ab5e88ce22f02e5d30a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1717738 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: David Riley <davidriley@chromium.org> Commit-Queue: David Riley <davidriley@chromium.org> Auto-Submit: David Riley <davidriley@chromium.org>
* tree-wide: use PollContext::build_with where possibleZach Reizner2019-07-24
| | | | | | | | | | | | | | | | | | The old method of creating a PollContext and calling `add` inside of `and_then` chains was an ugly way handle the Results that can crop up after each call. The `build_with` function is equivalent but operates on a slice which has way less boilerplate. TEST=./build_test BUG=None Change-Id: I8b0d6532680e04c501187397bd211014a2363c25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1715581 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
* main: add seccomp-log-failures flag to command lineZach Reizner2019-06-27
| | | | | | | | | | | | | | | | | | | | | | | | | | All cros-debug versions of crosvm enabled seccomp logging, which is now broken on kernels <4.4 thanks to new minijail changes as explained in the referenced BUG. This seems to be intended by the minijail folks as the aim to improve the seccomp logging in part by changing its semantics to logging failures without killing the violating process. In such a world, crosvm should not as a compile time choice, enable logging, which would amount to disabling some of the security. This change adds a command line flag to emulate the old behavior for the purposes of developer debugging, as long as that developer is running on a kernel that supports the new minijail seccomp filter failure logging. BUG=chromium:978998 TEST=USE=cros-debug emerge-eve crosvm && cros deploy eve crosvm then start crostini in UI Change-Id: I98190a068a919929e466fe22d6d630b90a758336 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679380 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
* main: add --rwroot option to runDaniel Verkamp2019-06-27
| | | | | | | | | | | | | | | This allows specifying a read-write rootfs (rather than read-only as with --root), including the automatic kernel command line additions normally added by --root. BUG=None TEST=Boot crosvm with --rwroot and write to root filesystem Change-Id: I6a3dc9176bffdefe664139cb33bf3e65a751dbf2 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679531 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* gpu: Allow more than one resource bridge socketChirantan Ekbote2019-06-24
| | | | | | | | | | | | | | | | | | | | | | | | Currently the wayland device accesses buffers allocated by the gpu device via a dedicated socket connection. Upcoming virtual devices like vdec and camera will also need access to these buffers. Modify the gpu device so that it can process requests on multiple resource_bridge sockets. Each future device that needs access to gpu device buffers should create a new resource bridge socket pair and add it to the list of sockets that the gpu device monitors. The actual interface between the devices is unchanged. BUG=b:133381367 TEST=run glxgears in a crostini container with and without gpu enabled Change-Id: I58693881945965071a53653bf4f86681725267d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1652876 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
* devices: Add separate seccomp policy for pmem deviceJakub Staron2019-06-21
| | | | | | | | | | | | | | | This change adds separate seccomp policy for pmem device. Previously, pmem device was using block device seccomp policy. BUG=None TEST=Boot VM and run xfstests on pmem device Change-Id: I3f25d64d4da6ad8f0ff22b285e1a7e958f545c55 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1652441 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Jakub Staroń <jstaron@google.com>
* crosvm: default serial parameter `num` field to 1 if not providedTrent Begin2019-06-20
| | | | | | | | | | | | | | | | | If multiple serial parameters do not have `num` fields, or a different parameter has already defined serial num 1, then crosvm will show an error. BUG=chromium:974885 TEST=cargo test; emerge-sarien crosvm && cros deploy dut crosvm; Manual testing with and without num field in --serial parameter Change-Id: Ia80247e8d055179adfd9e7471a98e8a2923cf1f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1662773 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Trent Begin <tbegin@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Trent Begin <tbegin@chromium.org>
* src/linux.rs: Modify socket instead of add socket when remove other socketsXiong Zhang2019-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an ill socket is detected, it will be removed from poll_context and control_sockets, then the remaining good sockets should change their indices, So modify should be used instead of add, as all of them have been added into poll_context already, the add will return an error. This change is merge of another change at I977be57ea0898cc8226505f7d3da103a46ea626c that was identical to this one except it contained the following similar commit message: linux: when renumbering control sockets, use modify instead of add In some circumstances, a VM control socket will get removed from the list of control sockets in the run_control loop. Usually, the last control socket in the list gets removed, but if that is not the case, the control sockets will get reordered to fill in the gap in the list. The `add` method of `PollContext` was used to change the token used for a given control socket, when `modify` should have been used instead. The problem with using `add` when a control socket is already part of a `PollContext` is that it will return an error and terminate crosvm. This CL fixes that issue. BUG=none TEST="crosvm run --vfio=$GVT_UUID", then run many gpu workloads in guest TEST=crosvm run --gpu Change-Id: Ic00a781d8839e652e2a8fd54ccd8e55849fa20bb Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Signed-off-by: Zach Reizner <zachr@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581151 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: fix clippy warningsJakub Staron2019-06-08
| | | | | | | | | | | | | | | | | | | Resolve a couple of minor clippy warnings: - unneeded return statement - use `if let` instead of `match` for single pattern destruction - use `values()` function to iterate over map values - supress warning about `ptr::null()` as expressed by the comment BUG=None TEST=./bin/clippy TEST=cargo build Change-Id: Ic4cea94cd3a25a9edf6ef38119de8c46dcfec563 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646739 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Jakub Staroń <jstaron@google.com>
* crosvm: virtio-pmem deviceJakub Staron2019-06-05
| | | | | | | | | | | | | | | | | | | | Adds support for virtio-pmem device as an alternative for virtio-blk. Exposing disk image to guest as virtio-blk device results in both guest and host independently caching the disk I/O. Using virtio-pmem device allows to mount disk image as direct access (DAX) in the guest and thus bypass the guest cache. This will reduce memory foodprint of the VMs. BUG=None TEST=cargo test TEST=Boot patched termina kernel in crosvm; mount virtio-pmem device as DAX and run xfstests. Change-Id: I935fc8fc7527f79e5169f07ec7927e4ea4fa6027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1605517 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Jakub Staroń <jstaron@google.com>
* Initial BIOS support.Cody Schuffelen2019-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The --bios argument is added as an alternative to the kernel positional argument. The BIOS runs in unreal mode (16-bit cs selector set to the end of 32-bit address space), which matches the default state KVM puts the segment and data registers into. Example usage: Build u-boot with "make qemu-x86_defconfig && make" Run crosvm with "crosvm_wrapper.sh run --bios=u-boot.rom" This produces the following message: """ U-Boot 2019.01-00017-gdc76aabe6a-dirty (May 21 2019 - 12:17:02 -0700) CPU: DRAM: 16 MiB unable to get online cpu number: -19 Warning: MP init failure Model: QEMU x86 (I440FX) Net: No ethernet found. error: can't find etc/table-loader Hit any key to stop autoboot: 0 => """ At this point the u-boot shell works with stdin/stdout, but virtual disks passed with --rwdisk weren't immediately visible from running "virtio scan" and "virtio info". This change puts the bios loading together with the linux kernel loading code since there is a lot of overlap in functionality. Bug: b/133358982 Test: ./crosvm_wrapper.sh run --mem=4097 --bios=u-boot.rom Change-Id: I65b0e1044233af662a642c592d35b106217f3c13 Reviewed-on: https://chromium-review.googlesource.com/1622648 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* linux: Add cras-capture option for cras-audio devicepaulhsia2019-05-31
| | | | | | | | | | | | | | | | | | | | The flag can enable capturing audio from CRAS server to the cras-audio device. We'll re-enable capture function on Crostini after finishing capture permission works. BUG=chromium:932268 TEST=Boot vm with crosvm --cras-audio --cras-capture to check recording functionality. Cq-Depend: chromium:1628633 Change-Id: I7502cbd668cbc722224164d9f69e50a16b0ab86b Reviewed-on: https://chromium-review.googlesource.com/1628687 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
* crosvm: fix unused variable warning in create_virtio_devicesDmitry Torokhov2019-05-29
| | | | | | | | | | | | | | | The gpu_device_socket is not used when GPU support is disabled. BUG=chromium:967436 TEST=cargo build --no-default-features Change-Id: I5c0ef0ecf27349bcfbc19474879a282c9f6fb8ef Reviewed-on: https://chromium-review.googlesource.com/1631292 Commit-Ready: Dmitry Torokhov <dtor@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dmitry Torokhov <dtor@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
* virtio-gpu: add gpu control socketGurchetan Singh2019-05-28
| | | | | | | | | | | | | | | The GPU process will need access to KVM. BUG=chromium:924405 TEST=compile Change-Id: I9e454d79a36a40a20c6c4b3a62ea367f339e526b Reviewed-on: https://chromium-review.googlesource.com/1626793 Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: David Riley <davidriley@chromium.org>
* linux.rs: create a socket between gpu device and hostGurchetan Singh2019-05-24
| | | | | | | | | | | | | | | The GPU process needs to access KVM from host coherent memory. BUG=chromium:924405 TEST=compile Change-Id: I3db9dce044e2a5cc816f48f28d943024dad7e7eb Reviewed-on: https://chromium-review.googlesource.com/1626792 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: {WlDriverRequest, WlDriverResponse} --> {VmMemoryRequest, ↵Gurchetan Singh2019-05-24
| | | | | | | | | | | | | | | | | VmMemoryResponse} These type of requests are not necessarily specific to the virtio-wl, and other devices (virtio-gpu) may want to use them. BUG=chromium:924405 TEST=compile Change-Id: Iad0889da8ab3d23bb2378448fc05e3c840a93d93 Reviewed-on: https://chromium-review.googlesource.com/1626791 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Implement the file type for serial portsJorge E. Moreira2019-05-22
| | | | | | | | | | | | BUG=chromium:953983 Change-Id: I0c1dc6216ebfdb61db85d3d9665f88f7231d99c8 Reviewed-on: https://chromium-review.googlesource.com/1618281 Commit-Ready: Jorge Moreira Broche <jemoreira@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* crosvm: add cmdline flags for configuring serial outputs in guest machineTrent Begin2019-05-15
| | | | | | | | | | | | | | | | This change allows an output to be set for each serial device for a guest machine (stdout, syslog, or sink). BUG=chromium:953983 TEST=FEATURES=test emerge-sarien crosvm; cd sys_util; cargo test; ./build_test; manual testing on x86_64 and aarch_64 Change-Id: I9e7fcb0b296c0f8a5aa8d54b1a74ae801f6badc8 Reviewed-on: https://chromium-review.googlesource.com/1572813 Commit-Ready: Trent Begin <tbegin@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Trent Begin <tbegin@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* linux: handle margin file with multiple valuesSonny Rao2019-04-29
| | | | | | | | | | | | | | | | | We're changing the content of the low_mem margin file to handle multiple values to support notification for multiple memory pressure levels. The values will be from most critical to least, so we need to handle this by fetching the first value. BUG=chromium:736538 TEST=run vm.CrostiniStartEverything with and put memory pressure on the system Change-Id: I0278ed492ddda1594d53750e0d4024a878210c9f Reviewed-on: https://chromium-review.googlesource.com/1584644 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: Fix misleading field name in VmComponents struct.Jakub Staron2019-04-29
| | | | | | | | | | | | | | | Renames field memory_mb to memory_size. All usages of this field treat it as a memory size in bytes, not megabytes. BUG=None TEST=cargo check TEST=cargo check --package aarch64 --target aarch64-unknown-linux-gnu Change-Id: I7b1aefe4f0b612d5eeb2987dc2a0fce6db0dd228 Reviewed-on: https://chromium-review.googlesource.com/1585617 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: support for listing attached usb devicesZach Reizner2019-04-27
| | | | | | | | | | | | | | | | | | Originally, crosvm would list details about an attached usb device for a given port. This change allows getting details about multiple ports at once. This is intended to simplify command line usage and downstream consumers like concierge. TEST=various vmc commands Chrome UI for handling USB devices BUG=chromium:831850 Change-Id: I55681a7fea7425c897a22a579dcc15567683ef54 Reviewed-on: https://chromium-review.googlesource.com/1529765 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Extracts Wayland commands from from VmRequest.Jakub Staron2019-04-27
| | | | | | | | | | | | | | | BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: I07f034b1cc41e30b9deae68ea9c510b0923e17a8 Reviewed-on: https://chromium-review.googlesource.com/1565299 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Extracts BalloonAdjust from VmRequest.Jakub Staron2019-04-25
| | | | | | | | | | | | | | | | | Extracts BalloonAdjust from VmRequest into BalloonControlCommand. BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: Ia9f5778c37c8fd4fa560df413134d1b441142f64 Reviewed-on: https://chromium-review.googlesource.com/1565298 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* crosvm: only clear signal when neededMatt Delco2019-04-24
| | | | | | | | | | | | | | | | | | Only clear signal when EINTR is indicated, rather than doing it after each attempt to run the VM. BUG=None TEST=Local compile. Ran my diagnostic plugin and confirmed that pause can still be trigger. Ran my benchmarking plugin and saw the time used decrease by about 13%. The net reduction with 2 other changes is about 42%. Change-Id: I118e05c6c62d1251946dd6432d4c933a3b8504fc Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1573219 Commit-Ready: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: use pipe instead of socket for vcpu communicationMatt Delco2019-04-24
| | | | | | | | | | | | | | | | | | | | | Pipes have better performance than sockets, so switch the vcpu communication over to pipes. The vm communication channels will continue to use sockets since that communication isn't performance critical (and those messages sometimes exchange file descriptors, and that functionality requires sockets). TEST=local compile and confirmed that my diagnostic plugin is still happy. The time it takes to run my benchmark plugin has decreased by 20%. This combined with my prior commit results in a net wall-clock time reduction of 32%. BUG=None Change-Id: I44c198d62a3bbe3b539ff6ac79707d02488876e3 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1572873 Commit-Ready: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: reduce excess chatter with pluginMatt Delco2019-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change helps to improve performance in plugin communications by removing unnecessary communication exchange. The existing protocol basically requires the plugin to send a request msg and wait for a reply msg. Prior to this change a plugin had to send a wait request before it got a wait reply (which typically contains an IO event notication). Similarly, when the plugin sends a resume request there's also a resume reply that's sent. The reply to the resume message serves no worthwhile purpose and can be removed. In the common case there's also no need for the plugin to send a wait request message--the prior operation was a resume so both sides know that the only next legal operation is a wait. Thereforce, crosvm can send a wait reply message without waiting for the plugin's request. Another way to look at the situation is that a resume request message is now answered by a wait reply message, and the overall message exchange pattern looks less like http and more like async I/O. The plugin's first call to wait is the one time that a wait request is sent. This in turn will receive an wait-init reply. TEST=Ran my diagnostic plugin and confirmed that it still passes (after working around an 8-byte limitation in crosvm). Run my benchmarking plugin and observed the time it takes to complete go down by 16.5%. BUG=None Change-Id: I9c93ba1d3a8f7814ca952f3dc7239d48675192e2 Signed-off-by: Matt Delco <delco@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1571066 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Matt Delco <delco@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* resources+pci: allocator rework (allocation tags)Daniel Prilik2019-04-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | AddressAllocator now maintains a HashMap<Alloc, (u64, u64, u64)>, which uniquely maps a Allocation enum (e.g: PciBar(bus, dev, bar), GpuRenderNode, etc...) to it's address, size, and human-readable tag / description. The interface has also been modified to use Error instead of Option. Aside from improving debugging, tracking allocations will have numerous uses in the future. For example, when allocating guest memory over VmControl sockets, it will be possible to restrict allocations to pre-allocated slices of memory owned by the requesting device. To plumb through PCI information to PCI devices, this CL necessitated the addition of a PciDevice method called `assign_bus_dev`, which notifies PCI devices of their uniquely assigned Bus and Device numbers. BUG=chromium:936567 TEST=cargo test -p resources && cargo build --features="gpu gpu-forward" Change-Id: I8b4b0e32c6f3168138739249ede53d03143ee5c3 Reviewed-on: https://chromium-review.googlesource.com/1536207 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Extracts DiskResize from VmRequest to a new type.Jakub Staron2019-04-19
| | | | | | | | | | | | | | | BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: Icf26f53d3fd813ab43b8f14079f90628d245eed7 Reviewed-on: https://chromium-review.googlesource.com/1565297 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve cast_ptr_alignmentDavid Tolnay2019-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | This CL fixes four cases of what I believe are undefined behavior: - In vhost where the original code allocates a Vec<u8> with 1-byte alignment and casts the Vec's data pointer to a &mut vhost_memory which is required to be 8-byte aligned. Underaligned references of type &T or &mut T are always undefined behavior in Rust. - Same pattern in x86_64. - Same pattern in plugin::vcpu. - Code in crosvm_plugin that dereferences a potentially underaligned pointer. This is always undefined behavior in Rust. TEST=bin/clippy TEST=cargo test sys_util Change-Id: I926f17b1fe022a798f69d738f9990d548f40c59b Reviewed-on: https://chromium-review.googlesource.com/1566736 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* clippy: Iterate without calling .iter()David Tolnay2019-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | See: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop https://rust-lang.github.io/rust-clippy/master/index.html#explicit_into_iter_loop Before: for element in slice.iter() {...} After: for element in slice {...} TEST=grep -r '\.iter() {' TEST=grep -r '\.iter_mut() {' TEST=grep -r '\.into_iter() {' TEST=cargo check --all-features TEST=local kokoro Change-Id: I27f0df7cfa1064b2c8b162cba263513926a433a9 Reviewed-on: https://chromium-review.googlesource.com/1568525 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Eliminate ref keywordDavid Tolnay2019-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html which also covers the new mental model that the Rust Book will use for teaching binding modes and has been found to be more friendly for both beginners and experienced users. Before: match *opt { Some(ref v) => ..., None => ..., } After: match opt { Some(v) => ..., None => ..., } TEST=cargo check --all-features TEST=local kokoro Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7 Reviewed-on: https://chromium-review.googlesource.com/1566669 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Eliminate blocks superseded by NLLDavid Tolnay2019-04-17
| | | | | | | | | | | | | | | | | | | | Before the new borrow checker in the 2018 edition, we sometimes used to have to manually insert curly braced blocks to limit the scope of borrows. These are no longer needed. Details in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html TEST=cargo check --all-features TEST=local kokoro Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3 Reviewed-on: https://chromium-review.googlesource.com/1568075 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve single_matchDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Iea0d3539b3ab587a2d97f676e1d9c7a239504308 Reviewed-on: https://chromium-review.googlesource.com/1566748 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve redundant_closureDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Id4f38956d788e4402df164df03e80c4b487b1ad6 Reviewed-on: https://chromium-review.googlesource.com/1566745 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve needless_returnDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: I62eb3f86b01a6000107c54a967689d4e430adf50 Reviewed-on: https://chromium-review.googlesource.com/1566743 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve match_ref_patsDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: I3eceba7418992d453dea9f429d45e4e2a72740fc Reviewed-on: https://chromium-review.googlesource.com/1566742 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve ptr_argDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: I2880852da218bcb96c56c49977ba9d86e3156f70 Reviewed-on: https://chromium-review.googlesource.com/1566738 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Remove extern crate linesDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rust 2018 edition, `extern crate` is no longer required for importing from other crates. Instead of writing: extern crate dep; use dep::Thing; we write: use dep::Thing; In this approach, macros are imported individually from the declaring crate rather than through #[macro_use]. Before: #[macro_use] extern crate sys_util; After: use sys_util::{debug, error}; The only place that `extern crate` continues to be required is in importing the compiler's proc_macro API into a procedural macro crate. This will hopefully be fixed in a future Rust release. extern crate proc_macro; TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293 Reviewed-on: https://chromium-review.googlesource.com/1565302 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>