summary refs log tree commit diff
path: root/src
Commit message (Collapse)AuthorAge
* Merge remote-tracking branch 'origin/master'Alyssa Ross2020-03-26
|\
| * audio: Create AC97 device with --ac97 optionJudy Hsiao2020-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Replace --cras-audio, --cras-capture, null-audio options by --ac97 option to create audio devices. 2. "--ac97 backend=BACKEND\ [capture=true,capture_effect=EFFECT]" is comma separated key=value pairs for setting up Ac97 devices. It can be given more than once to create multiple devices. Possible key values are: backend=(null, cras) - Where to route the audio device. `null` for /dev/null, and cras for CRAS server. capture=true - Enable audio capture. capture_effects - | separated effects to be enabled for recording. The only supported effect value now is EchoCancellation or aec. BUG=b:140866281 TEST=1.crosvm run -r ./vm_rootfs.img -c 4 -m 1024 -s /run --cid 5 --host_ip\ 100.115.92.25 --netmask 255.255.255.252 --ac97\ backend=cras,capture=true,capture_effect=aec\ --mac d2:47:f7:c5:9e:53 ./vm_kernel 2. Record with the vm by: arecord -D hw:0,0 -d5 -fS16_LE -c2 -r48000 /tmp/test.mp3 3. Verify that AEC is enabled within the recording stream by cras_test_cleint. Cq-Depend: chromium:2053654 Cq-Depend: chromium:2095644 Cq-Depend: chromium:2038221 Change-Id: Ia9e0e7cda1671a4842ec77a354efaa4a2dc745eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2038413 Tested-by: Judy Hsiao <judyhsiao@chromium.org> Commit-Queue: Judy Hsiao <judyhsiao@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org> Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
| * crosvm: Change expected field to String in InvalidValueJudy Hsiao2020-03-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the type of argument::Error::InvalidValue::expected from "&'static str" to String. It allows the lower level parse error object to handle the output of the expected value so that the rule of parsing will not be duplicated. For example, instead of: ``` v.parse::<Settings>() .map_err(|e| argument::Error::InvalidValue { value: v.to_string(), expected: "The value of setting should null or cras", })?; ``` we can have: ``` v.parse::<Settings>() .map_err(|e| argument::Error::InvalidValue { value: v.to_string(), expected: e.to_string(), })?; ``` and the expected value can be handled in the Display implementaion of Settings::ParseError. BUG=b:140866281 TEST=cargo build Change-Id: Ieba12a21103945fe0e47c70a190a4e5d985af537 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2103605 Tested-by: Judy Hsiao <judyhsiao@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Judy Hsiao <judyhsiao@chromium.org> Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
| * Fix into_iter() usage where iter() sufficesDaniel Verkamp2020-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes warnings of the form: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. BUG=None TEST=emerge-nami crosvm Change-Id: I2b46b55f0e967d985d04678c240604b542e27e07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093287 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* | Merge remote-tracking branch 'origin/master' into masterAlyssa Ross2020-03-10
|\|
| * Vfio: Multi vfio device supportXiong Zhang2020-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current one vm could have one vfio device only, this patch let one vm could have multi vfio devices by changing the vfio parameter into vec<>. BUG=chromium:992270 TEST=passthrough two/three devices into guest, these devices are in the same vfio group, then check these devices function in guest. Change-Id: I366d24d750a199d7862fb907fa44f9be429c5944 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2080111 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * crosvm: remove deprecated --qcow and --rwqcow optionsDaniel Verkamp2020-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | These have been marked as deprecated for several release; use --disk or --rwdisk instead. BUG=None TEST=./build_test.py Change-Id: I8a52c9abaf3f41e2dfc4189dd19c7d828802772e Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1906992 Reviewed-by: Zach Reizner <zachr@chromium.org>
* | crosvm: fmt arguments in run_vmAlyssa Ross2020-03-09
| |
* | Merge remote-tracking branch 'origin/master' into masterAlyssa Ross2020-03-09
|\|
| * Vfio: multi vfio group supportXiong Zhang2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | current one container contains one group only, but one container could contain multi groups actually. The main gap that current code to support multi groups is that container will be initialized multi times when multi groups exist, as each group will initialize container one time. This patch extracts the code which should run one time only on a container, so when the first group is added into container, this container initialize code will run once. The container once initialize code contains: a. Set iommu driver type as VfioType1V2 b. Setup Iommu table on each guest memory region c. create vfio_kvm device, so kernel kvm and vfio is associated. BUG=chromium:992270 TEST=passthrough two/three vfio devices into guest, these devices belong to different vfio groups, then check these devices function in guest. Change-Id: I94c9c86f70f49957a5e5c1dfd2c7d823ad042320 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2078970 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
| * Use simple virtio_input_events where possible.Noah Gold2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, all input events in CrosVM were required to be linux input_events, which have a timestamp field that is actually unused by when we send/receive from the guest which are of type virtio_input_event. This CL allows CrosVM to understand both types of input events in a first class manner. It is a follow up on https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930405. This CL also addresses some bugs with window driven input: 1. attach_event_device was being called before the surface was created, so the devices were never attached. 2. The default touchpad size was not being set to the display window size. Additionally, it removes the unused event "filter" feature on event sources. Breaking change: from this point forward, CrosVM will treat input events sent via a socket (e.g. SocketEventSource) to be virtio_input_events. BUG=None TEST=builds + manual Change-Id: I7fec07c582e5a071a6f116975ba70d6e621bb483 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034046 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Noah Gold <nkgold@google.com>
| * crosvm: add handling for hyperv exitsMatt Delco2020-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When features for Hyper-V are enabled there's a another type of exit that can be triggered. This change attempts to add support for those types of exits. BUG=b:150151095 TEST=ran build_test Change-Id: I3131a2c8d9c610576ac177dbfe82f78e8d5dbfb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073254 Reviewed-by: Matt Delco <delco@chromium.org> Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Matt Delco <delco@chromium.org> Auto-Submit: Matt Delco <delco@chromium.org>
| * crosvm: Add plumbing for split-irqchip interruptsZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Devices use irqfd to inject interrupts, we listen to them in the main thread and activate userspace pic/ioapic accordingly. BUG=chromium:908689 TEST=lanuch linux guest with `--split-irqchip` flag Change-Id: If30d17ce7ec9e26dba782c89cc1b9b2ff897a70d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945798 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
| * devices: PIC: implement interrupt injectionZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | TODO: Route irqfd to PIC, and use signal to kick vCPU thread when interrupt is triggered. BUG=chromium:908689 TEST=Unit tests in file. Change-Id: I9a87502da57e725d3bb26d746a337d0ba44ef337 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945797 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>
| * Add logic to setup PIC/IOAPIC.Zhuocheng Ding2020-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | TODO: Route irqfd to PIC/IOAPIC to make them fully work. BUG=chromium:908689 TEST=None Change-Id: I301287b1cf32cfccffce6c52ebbb5e123931178e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945796 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>
| * linux: fix unused code warning without gpu featureDaniel Verkamp2020-03-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the gpu feature is not enabled, the compiler warns about unused imports of DEFAULT_TOUCH_DEVICE_HEIGHT and DEFAULT_TOUCH_DEVICE_WIDTH. Put these imports behind a cfg check to silence the warning. BUG=None TEST=cargo build TEST=emerge-nami crosvm # test with gpu feature enabled Change-Id: Ib60072cc78a8ffd0ac39dcb4d3a60ba4c9d424b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2080645 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * ac97: switch to ShmStreamSourceFletcher Woodruff2020-02-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert playback and capture for the AC97 device to use the zero-copy ShmStreamSource instead of the old StreamSource. In the process, rework start_playback and start_capture unit tests so they rely less on sleep statements. BUG=chromium:968724 BUG=chromium:1006035 TEST="sox -n -r 48000 -b 16 output.raw synth 5 sine 330 && aplay -f dat output.raw" within a VM, check that sine wave is played accurately. Change-Id: Ie9cddbc5285a9505872c9951a8a1da01de70eb88 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1749950 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
| * linux: add disk path to open error messageDaniel Verkamp2020-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if a disk could not be opened, the error message did not include the path of the disk, e.g.: The architecture failed to build the vm: error creating devices: failed to load disk image: Read-only file system (os error 30) To make debugging easier, add the path to Error::Disk. BUG=b:150181514 TEST=crosvm run --rwdisk ro.img vm_kernel Change-Id: I7b319c419b889334ecadbb0497dc4b3dc5115aa6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2070844 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * linux.rs: Don't pivot_root when using host's root directoryChirantan Ekbote2020-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pivot_root(2) will fail with EBUSY if we try to pivot_root to "/". Check for this case and skip the pivot_root if necessary. BUG=b:147258662 TEST=`tast run <dut> vm.Virtiofs` Change-Id: I1d7645844e183222a561578677fc5f59c080d58c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2067823 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * Support generating and opening backing filesA. Cody Schuffelen2020-02-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new functionality can be invoked through "crosvm create_qcow2 --backing_file=backing new_file". The old behavior of creating a qcow image with a particular size is still available with its original syntax. This is relevant to implement as by default something like qemu-img will create a new image that assumes the backing file is raw or qcow, while crosvm can use its knowledge of other formats (such as composite disk, and later android sparse) to determine the true size of the backing file. TEST=unit tests BUG=b:140069322 Change-Id: I22de6a79c6d8566a9fcb0bc8124e2d74fea9ca55 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982833 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * linux.rs: Refactor 9p device jailChirantan Ekbote2020-02-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Give the 9p device the same jail as the fs device. In particular it needs a higher max open file limit and should map the current euid/egid in its user namespace rather than always using the crosvm user. BUG=b:147258662 TEST=`tast run <dut> vm.Blogbench.p9` Change-Id: I12e7ba7b651da4bae1435e0598b62fe2c35ff1bf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2065254 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * crosvm: add ability to enable caps on vcpuMatt Delco2020-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change primarily adds functionality to allow kvm features to be enabled on a vcpu (most of the current infra only supporst the ioctl for the vm fd). BUG=b:144746965 TEST=ran 'build_test' and verified that the added tests passed. Change-Id: I30c00b6f462377c21d477602ceba5853df953b37 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2055883 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
| * crosvm: support kvm's hyper-v cpuid ioctlMatt Delco2020-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kvm can emulate the hyper-v paravirt interface. Newer versions of kvm can advertise the features they support via an ioctl() that reports the cpuid leafs for this interface. This change adds some support for the ioctl() and plumbs it through the plugin interface so that plugins can determine the level of support available in kvm. BUG=b:144746965 TEST=Ran build_test on kernel that supports the ioctl. Added temporary code to print the cpuid leafs and verified that the output is as expected. Instrumented failure as expected from older kernels and verified that results still passed. Change-Id: I6cd7dade1793e4edb52b331d5b960685541f7ba3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2037919 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
| * linux.rs: unify jail creationMatt Delco2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change unifies two substantially similiar segments of code used to create a jail. BUG=none TEST=Ran 'build_test'. Local build, deployed to DUT, and verified that termina VM could still be used. Change-Id: Ib1f2f9bc5cfe1e6c9f3633af7e23f52e5eafe3c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2057744 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
| * acpipm: implement suspend and resume mechanismChuanxiao Dong2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For suspend request from VM, will write suspend event and notify crosvm main process to pause VCPUs. For resume request, it is not from VM itself but by the resume command through crosvm socket. Resume request will notify the PM device to fill its wakeup registers with wakeup event so that when VCPUs start to run, VM can know there is wakeup from outside. BUG=chromium:1018674 TEST=cargo test -p devices Change-Id: I4724ffee10150065a62bf520076c16cbc70b7749 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035169 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
| * virtio-gpu: gfxstream backendLingfeng Yang2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a new backend type, gfxstream, that calls out to a C library implementing the actual rendering. The purpose is to allow the Cuttlefish and Android Studio Emulator teams to use crosvm with the current API-forwarding style of rendering employed in the Android Studio Emulator. Also, introduces a new key to the --gpu command line interface, backend=, which selects from different backends. Note that the previous behavior is now deprecated and will be removed after some time (when all clients switch over to backend=). The gfxstream backend itself implements a subset of 3d-related resource and context creation/transfer/execbuffer commands. Their meaning is specific to the way in which they are interpreted in the backend library. To interface with display, gfx stream backend takes a callback that is run on guest vsync. The callback is responsible for repainting the display's contents. gfx stream provides a callback, get_pixels, that can be used asynchronously. The asyncness is not taken advantage of currently but will be useful for cases where the client attached to the VMM might want to update at a different rate than guest vsync. The guts of the stream backend library is currently defined here: https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android-qemu2-glue/emulation/virtio-goldfish-pipe.cpp The linking of the library is controlled via the feature "gfxstream". If the feature is turned off, we use a default do-nothing stub impl. Next steps: - integrate virtio-gpu-next so as to have host coherent memory for vulkan - Figure out low latency command submit/response with SUBMIT_CMD_3DV2 BUG=b:146066070 Change-Id: If647381c15e5459cec85e2325f97e2f0a963b083 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2033305 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Lingfeng Yang <lfy@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org>
| * Use display size as the default size for single touchKaiyi Li2020-02-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the user specifies the display size through the gpu argument but not specifies the size of the single touch device, the display size will be used as the size of these touch devices. Use default() to initialize the GpuParameters. Allow initialize the GpuParameters dynamically in the future. Change-Id: I9fa04f8ff479732370514fbaeb062d737adba319 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2043072 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* | crosvm: fix typo in crosvm balloon descriptionAlyssa Ross2020-03-09
| |
* | crosvm: improve crosvm --help outputAlyssa Ross2020-03-09
| | | | | | | | | | Document missing options, and fix inconsistent option/description spacing by making a table.
* | crosvm: improve crosvm run --help outputAlyssa Ross2020-03-09
|/ | | | | | | | | | | | | | | The specifiers and descriptions for crosvm options are just too long to fit into a table. Options were already eclipsing the widths of the table cells, and sizing them correctly just made the table infeasibly wide. So, instead, just print out paragraphs for each option, and stop trying to fit things into a table. Use this opportunity to add some spacing and make key value lists within option descriptions more readable. Also, make formatting consistent. Consistent spacing between sentences, consistent default output, etc.
* Allow mounts to propagate into 9p device jailChirantan Ekbote2020-02-04
| | | | | | | | | | | | | | | | | Allow mounts from the parent namespace to propagate into the mount namespace of the 9p device process. BUG=none TEST=none Change-Id: Iff455c8967949bd3e0f2990c947d45bbbc541d45 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2018305 Reviewed-by: Yusuke Sato <yusukes@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: Yusuke Sato <yusukes@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* virtio-gpu: implement 2D GPU BackendJason Macnak2020-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... which does not require virglrenderer (or any renderer). This will allow the Cuttlefish team to use minigbm as its gralloc implementation when both hardware acceleration is available and unavailable. Adds a GPU `Backend` trait with all of the existing methods of the current backend and converts the existing `Backend` into `Virtio3DBackend` which implements the new trait. Adds a `Virtio2DBackend` which creates resources with byte vectors on the host and implements transfers via the old code from gpu_buffer/src/lib.rs. Adds a runtime flag to select between 2D and 3D mode with 3D mode as the default. Moves the process_resource_bridge() function to the `Frontend` and instead expose a export_resource() function on the `Backend` to avoid some code duplication. BUG=b:123764798 TEST=build + launch cuttlefish w/ 2D mode (minigbm + custom hwcomposer) TEST=built + launch cuttlefish w/ 2D mode (minigbm + drm_hwcomposer) TEST=built + launch cuttlefish w/ 3D mode (minigbm + drm_hwcomposer) Change-Id: Ie5b7a6f80f7e0da72a910644ba42d2f34b246be8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1993913 Commit-Queue: Jason Macnak <natsu@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Lingfeng Yang <lfy@google.com>
* crosvm: pstore works for ARCVM on x86_64Kansho Nishida2020-02-03
| | | | | | | | | | | | | | | | Adds support for pstore on ARCVM on x86_64. The backend file of the buffer will be passed via argument of the crosvm. BUG=b:144962428 TEST=kernel crash on eve-arcvm, check /sys/fs/pstore/console-ramoops-0 Launch crostini manually on eve-arcvm Change-Id: I29492ac7a9067aa2ae23eb03fbb942ab7dd3aa8d Signed-off-by: Kansho Nishida <kansho@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1973391 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Kansho Nishida <kansho@chromium.org>
* linux: use ScopedEvent to trigger the `exit_evt` in vcpu threadsZach Reizner2020-02-01
| | | | | | | | | | | | | | | | The VCPU thread can panic when there is a bug, and this should trigger an exit in crosvm instead of hanging the VCPU thread forever. BUG=None TEST=run crosvm with kernel, trigger a vcpu exit using guest Change-Id: I1df0e04eda73ad67fec20adeff893f6c00699318 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2029929 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
* crosvm: add support for bpf policy filesMatt Delco2020-01-22
| | | | | | | | | | | | | | | | | | | | Change adds supports for providing pre-compiled bpf files as the policy file for jailing. In short it's more effient to compile once on the build machine than each time at runtime. Additionally libminijail's support for more efficient bpfs (which use a binary tree instead of a linear search) is currently only available via tools that are based around pre-compiled use. BUG=None TEST=Ran build_test and verified that tests can pass with both bpf and policy files (though the tests might only exercise the jail for the plugin). Change-Id: Idd93e3c802fc79da93850d6bad1db660576bc9ba Signed-off-by: Matt Delco <delco@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1914416 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* MsgSocket: Don't implement DerefChirantan Ekbote2020-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Deref trait is usually only implemented by smart pointers or by trivial wrappers around the underlying type. MsgSocket does not fit into either category because it wraps a `UnixSeqPacket` to provide new functionality. Having it implement can lead to confusing error messages, especially for people who are new to rust and are not familiar with the Deref trait and Deref coercion. For example, calling `sock.send()` on a MsgSocket without first adding `use msg_socket::MsgSender` leads to the compiler complaining about mis-matched types for the `send` method. `UnixSeqPacket::send` expects a `&[u8]` while `MsgSocket::send` expects a `&M`. The compiler also gives no clues that it is implicitly coercing the socket to a `&UnixSeqPacket` and using the `send` method from there. Drop the `Deref` implementation. `MsgSocket` already implements `AsRef<UniqSeqPacket>` so anything that _needs_ to access the underlying `UnixSeqPacket` should just use that. BUG=none TEST=unit tests Change-Id: If02ef7173ae21d85d517e808489ed4d6d09ae90b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2002997 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* crosvm: log 'run' arguments parsing errors also to syslogDmitry Torokhov2020-01-16
| | | | | | | | | | | | | | | | | | | | We are inconsistent in when we print errors to stdout versus strerr and syslog, with argument parsing errors from "crosvm run" subcommand only logged to stdout whereas other types of errors going to stederr/syslog. Let's make sure argument parsing errors will be logged to stderr/syslog as well, otherwise it is very confusing to analyze crosvm failures when started by VM concierge as it does not dump crosvm stdout/stderr anywhere. BUG=None TEST=Try "crosvm run" with bad arguments when syslog is available, see error messages in syslog. Change-Id: Ie7a284f4a604716ecc655c5a38ec2147b55d63a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2002677 Commit-Queue: Dmitry Torokhov <dtor@chromium.org> Tested-by: Dmitry Torokhov <dtor@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* gpu_display: implement stub displayJason Macnak2020-01-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a stub display that emulates a display without actually displaying contents anywhere. This is needed for transitioning Cuttlefish to always using minigbm as its gralloc implementation. Cuttlefish currently uses a custom gralloc and hwcomposer implementation when running without hardware acceleration. The Cuttlefish team would like to start with removing our custom gralloc implementation and use minigbm. For this, we need to add a virtio 2D backend to crosvm. Our hwcomposer implementation currenlly sends framebuffers from the guest to the host via sockets. The gpu backend still requires a display so we need a stub display to use with the 2D backend for the period of time while we are either still using our hwcomposer implementation or until our hwcomposer implementation is updated to use the virtio backend for display. BUG=b:123764798 BUG=chromium:1033787 TEST=built and launched with Cuttlefish locally Change-Id: I1a7e259d914a53252200c59589c4142e76c6b96b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1993947 Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Jason Macnak <natsu@google.com>
* Add a new command to dump version info.Yi Sun2020-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With command "version", we can dump version information via "crosvm version". By default it would dump the version specified in Cargo.toml like following: "crosvm package version 0.1.0". And if the environment varable "PKG_VERSION=123456" is given during building crosvm, it would dump followed by a package version, like following: "crosvm package version 0.1.0-123456". Sometimes, we need to know which exact version does a crosvm binary come from for developing and testing. It is useful if the git sha is built-in a crosvm binary. BUG=none TEST=PKG_VERSION=xxxxxx Cargo build && crosvm version TEST=PKG_VERSION=xxxxx emerge-eve crosvm && crosvm version TEST=./bin/fmt TEST=./bin/clippy TEST=./build_test.py --x86_64-sysroot /build/eve no errors reported and all behavor is as expected. v2: Refine version info. Change-Id: I89686dbe6ab2888d8a6ce5752a37241b4c00160d Signed-off-by: Yi Sun <yi.sun@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1989256 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: remove user_command from proxy deviceZach Reizner2020-01-09
| | | | | | | | | | | | | | | | | | The only device that used user_command was Serial. This change makes Serial device use a thread to read from its input instead of using user_command. BUG=chromium:1033787 TEST=./build_test run crosvm with stdio serial with and without sandbox Change-Id: Ia0f2ee83d94ad2fee3f1f4f89aa734b976e33507 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1966435 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
* crosvm: align pmem region size to 2MiBStephen Barber2020-01-07
| | | | | | | | | | | | | | | | | 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>
* devices: virtio: wl: Support multiple socketsRyo Hashimoto2020-01-07
| | | | | | | | | | | | | | | | | | | 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>
* disk: move qcow into disk crateDaniel Verkamp2020-01-06
| | | | | | | | | | | | | | | | | | | 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>
* plugin: mount read-only /proc into the jailDmitry Torokhov2019-12-31
| | | | | | | | | | | | | | | | | | 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>
* Cast refernces of libc::RLIMIT_NOFILE to i32 for newer libc crate.Allen Webb2019-12-26
| | | | | | | | | | | | BUG=chromium:1021609 TEST=emerge-sand crosvm Change-Id: I9658d3816cc846be2b6320f2f03036375de67cbe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1979532 Tested-by: Allen Webb <allenwebb@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Allen Webb <allenwebb@google.com>
* Fix parsing arguments that require a value at the end of command lineDmitry Torokhov2019-12-22
| | | | | | | | | | | | | | | | | | | | | | | 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 --parameter <value> argument do not clobber parser errorsDmitry Torokhov2019-12-22
| | | | | | | | | | | | | | | | | | | | | | 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>
* crosvm: fix removing comments when processing -file optionsDmitry Torokhov2019-12-22
| | | | | | | | | | | | | | | | | 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>
* crosvm: treat FailEntry as fatal to a vcpuStephen Barber2019-12-20
| | | | | | | | | | | | | | | | | 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>
* crosvm: allow shorthand notation in plugin-mount and plugin-gid-mapDmitry Torokhov2019-12-18
| | | | | | | | | | | | | | | | | | | | | | | | 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>