summary refs log tree commit diff
path: root/vm_control
Commit message (Collapse)AuthorAge
...
* usb: add host backendJingkui Wang2019-03-16
| | | | | | | | | | | | | | | | | | Host backend implement backend device. It will attach a read device to xhci controller. Also squashed from ce6b35, author: zachr@. CQ-DEPEND=CL:1510820 BUG=chromium:831850 TEST=local build Change-Id: Idcf2d7d6aca92de9859b7c38d1bf1d98032eae91 Reviewed-on: https://chromium-review.googlesource.com/1512761 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* main: log responses to command line vm control requestsZach Reizner2019-02-28
| | | | | | | | | | | | | | | | Now that the connection oriented seqpacket sockets are used for vm control messages, a response can be received by the requested. This change prints out that response. TEST=crosvm suspend|resume|balloon|stop <socket> BUG=chromium:848187 Change-Id: I18ac23c26127332e2be498113cc0c3310fd09a7d Reviewed-on: https://chromium-review.googlesource.com/1482370 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* crosvm: use seqpacket rather than datagram socketsZach Reizner2019-02-28
| | | | | | | | | | | | | | | | | | | | The advantage of seqpacket is that they are connection oriented. A listener can be created that accepts new connections, useful for the path based VM control sockets. Previously, the only bidirectional sockets in crosvm were either stream based or made using socketpair. This change also whitelists sendmsg and recvmsg for the common device policy. TEST=cargo test BUG=chromium:848187 Change-Id: I83fd46f54bce105a7730632cd013b5e7047db22b Reviewed-on: https://chromium-review.googlesource.com/1470917 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* error: Print errors using Display implDavid Tolnay2019-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | I have been running into Debug-printed error messages too often and needing to look up in the source code each level of nested errors to find out from the comment on the error variant what the short name of the variant means in human terms. Worse, many errors (like the one shown below) already had error strings written but were being printed from the calling code in the less helpful Debug representation anyway. Before: [ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty After: [ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices. TEST=cargo check --all-features TEST=FEATURES=test emerge-amd64-generic crosvm Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10 Reviewed-on: https://chromium-review.googlesource.com/1469225 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>
* crosvm: add suspend/resume commandsZach Reizner2019-01-23
| | | | | | | | | | | | | | | | | | | | | This change adds the suspend and resume commands to crosvm, as well as corresponding VmRequest variants and VCPU loop support. When a request triggers a VmRunMode change, the Mutex guarded shared VmRunMode variable is mutated and the associated Condvar is notified. Each VCPU thread is interrupted to kick it out of the KVM_RUN call and checks the VmRunMode, If the VCPU was already suspended by waiting for the Condvar, the notify_all call will wake up the thread, upon which the VCPU thread can respond to the new mode. TEST=crosvm suspend/crosvm resume BUG=chromium:920875 Change-Id: Ibbeb748ab0d64402c7196890815e8e1cb4dfca38 Reviewed-on: https://chromium-review.googlesource.com/1416317 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: block: add resize VmControl requestDaniel Verkamp2019-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | This allows manual resizing of block devices at runtime via the command line ('crosvm disk resize <index> <size>'). The virtio config interrupt is asserted when the disk size changes so that the guest driver can update the block device to the updated size. Currently, there is no automatic policy for resizing disks - that will be implemented in another change. Additionally, this resize operation just changes the size of the block device; the filesystem will need to be resized by the guest (e.g. via the 'btrfs filesystem resize' command) as a separate step either before (shrinking) or after (expanding) the disk resize operation. BUG=chromium:858815 TEST=Start crosvm with a control socket (-s) and resize the disk with 'crosvm disk resize' from another shell. Change-Id: I01633a7af04bfbaffbd27b9227274406d2a2b9cb Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1394152 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: balloon: fix the 'crosvm balloon' commandDaniel Verkamp2019-01-05
| | | | | | | | | | | | | | | | | | The balloon socket interface was changed to take an absolute number of pages in a u64 in commit 448516e3f9 ("balloon: Implement device policy"), but the 'crosvm balloon' command wasn't updated to match. Fix the crosvm front-end to send a u64 as expected by the command socket reader instead of the i32 it was sending previously, and change the parameter to bytes instead of pages to match the receiving end as well. BUG=None TEST=crosvm balloon a running VM to various sizes Change-Id: I265bee55c06809de7559a79a5eb6d0d094533993 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1394157 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* lint: Resolve the easier clippy lintsDavid Tolnay2018-12-03
| | | | | | | | | | | | | | | | | | | | Hopefully the changes are self-explanatory and uncontroversial. This eliminates much of the noise from `cargo clippy` and, for my purposes, gives me a reasonable way to use it as a tool when writing and reviewing code. Here is the Clippy invocation I was using: cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute} TEST=cargo check --features wl-dmabuf,gpu,usb-emulation TEST=boot linux Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2 Reviewed-on: https://chromium-review.googlesource.com/1356911 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: use msg_socket in vm_controlJingkui Wang2018-11-19
| | | | | | | | | | | | | Refactor existing code to use msg_socket. BUG=None TEST=local build and run Change-Id: Iee72326b330e035303f679e1aedd6e5d18ad4f8a Reviewed-on: https://chromium-review.googlesource.com/1260260 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: refactor ioeventfd datamatch interfaceDaniel Verkamp2018-10-11
| | | | | | | | | | | | | | | This allows the caller to specify the full range of datamatch options defined in the KVM ioeventfd API, including matching accesses of a particular size with or without matching a specific data value. BUG=None TEST=cargo test -p kvm Change-Id: I28b543f7c0b35eb2a6d47a14a33145ea00d09d1d Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1271836 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* cargo fmt all source codeZach Reizner2018-10-09
| | | | | | | | | | | | | | Now that cargo fmt has landed, run it over everything at once to bring rust source to the standard formatting. TEST=cargo test BUG=None Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b Reviewed-on: https://chromium-review.googlesource.com/1259287 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sys_util: remove Scm struct and sock_ctrl_msg C libraryZach Reizner2018-09-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Scm object was made to reduce the number of heap allocations in the hot paths of poll loops, at the cost of some code complexity. As it turns out, the number of file descriptors being sent or received is usually just one or limited to a fixed amount that can easily be covered with a fixed size stack allocated buffer. This change implements that solution, with heap allocation as a backup in the rare case that many file descriptors must be sent or received. This change also moves the msg and cmsg manipulation code out of C and into pure Rust. The move was necessary to allocate the correct amount of buffer space at compile time. It also improves safety by reducing the scope of unsafe code. Deleting the code for building the C library is also a nice bonus. Finally, the removal of the commonly used Scm struct required transitioning existing usage to the ScmSocket trait based methods. This includes all those changes. TEST=cargo test BUG=None Change-Id: If27ba297f5416dd9b8bc686ce740866912fa0aa0 Reviewed-on: https://chromium-review.googlesource.com/1186146 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Move gpu allocator to resourcesDylan Reid2018-07-09
| | | | | | | | | | Combine GPU buffer allocation with the system resource allocator making life easier as only one allocator needs to get passed to the execute function. Change-Id: I199eb0fd6b99b629aaec1ae3295e8a1942da5309 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1099856
* Remove the device manager and use the new resource allocatorDylan Reid2018-06-29
| | | | | | | | | | | | | | | | | Allow IRQs to be assigned before creating device manager. For PCI, we need to add devices with interrupts before MMIO setup. Add the ability to tell the architecture device manager about IRQs that we have stolen. There was only one function in device_manager and all of its state is now delegated to the resource allocator, remove it. Change-Id: I9afa0e3081a20cb024551ef18ae34fe76a1ef39d Reviewed-on: https://chromium-review.googlesource.com/1089720 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* virtwl: better multi-plane DMABuf supportDavid Reveman2018-05-26
| | | | | | | | | | | | | | | | | | | Multi-plane DMABufs are useful for efficient video playback. The guest can already use this but has to guess the stride and offsets for the second and third plane as they are not passed by virtwl to the guest kernel. This extracts the correct strides and offsets for each buffer and passes them back to the guest in the allocation response message. BUG=chromium:837209 TEST=sommelier can use nv12 buffers without guessing stride/offset Change-Id: I36ae2fad6605293c907802121676296cbc607a57 Reviewed-on: https://chromium-review.googlesource.com/1070799 Commit-Ready: David Reveman <reveman@chromium.org> Tested-by: David Reveman <reveman@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* virtwl: Add DMABuf allocation support.David Reveman2018-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements DMABuf allocation type in the virtio wayland device. We attempt to locate a supported DRM device prior to engaging the device jail. If found, the DRM device is passed to the wayland device code and used to serve DMABuf allocations. DMABuf support can be disabled by not providing crosvm with access to any DRM device nodes. The guest is expected to handle the case when DMABuf allocation fails and fall-back to standard shared memory. This initial change uses DRM directly but is structured in a way that would allow the allocator to be replaced by minigbm with minimal effort. BUG=chromium:837209 TEST=crosvm finds drm device and returns valid dmabufs to guest Change-Id: Ic1fd776dfdfefae2d7b321d449273ef269e9cc62 Reviewed-on: https://chromium-review.googlesource.com/1034088 Commit-Ready: David Reveman <reveman@chromium.org> Tested-by: David Reveman <reveman@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* vm_control: more error signedness fixesDmitry Torokhov2018-03-01
| | | | | | | | | | | | Fix a couple more spaces where we used negative errno values. TEST=cargo test -p vm_control BUG=None Change-Id: Id622192d025d0ac733419411492ca53a50f957f3 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/942087 Reviewed-by: Zach Reizner <zachr@chromium.org>
* vm_control: do not use negative error coded for errno-based errorsDmitry Torokhov2018-02-27
| | | | | | | | | | | | | | | Errors derived from sysem errors delivered via -1 return code/errno should use positive error codes, not negative, in order for them to be recognized by other components. I.e. we should use errno::Error::new(EINVAL) and not -EINVAL. TEST=cargo test --features plugin; cargo test -p kvm BUG=None Change-Id: I10d5992cb1e1750aa9b8a7269c4f574d7c753683 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/939866 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: support adding read only memory to VMsZach Reizner2018-02-06
| | | | | | | | | | | | | | | | | Read only memory is useful for triggering VM exits when the VM writes to memory while allowing reads transparently and quickly. For example, a virtual device implementation might not care if the VM reads a memory mapped device register, but a exit would be required if the VM wrote to the same register. TEST=cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: Ic605b2cfc2a1e44941d91945f9390b9abb820040 Reviewed-on: https://chromium-review.googlesource.com/903075 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: change GuestAddress to always be a u64Sonny Rao2018-02-01
| | | | | | | | | | | | | | | We want to be able to run 64-bit ARM kernels using a 32-bit version of crosvm, to make it more consistent use a u64 to represent GuestAddress. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline Change-Id: I43bf993592caf46891e3e5e05258ab70b6bf3045 Signed-off-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/896398 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: add dirty log supportZach Reizner2018-01-03
| | | | | | | | | | | | | This add safe support for KVM's KVM_GET_DIRTY_LOG ioctl. TEST=./build_test BUG=None Change-Id: I3d0f996927844a33addd072f2bfc62361f8b7fe0 Reviewed-on: https://chromium-review.googlesource.com/848019 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* main: Add inflate/deflate interface for balloonDylan Reid2018-01-02
| | | | | | | | Change-Id: I0fc63abbed8db303c7d283ce392fd47777b60d19 Reviewed-on: https://chromium-review.googlesource.com/818207 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sys_util/vm_control: Don't test shm if memfd_create doesn't existDylan Reid2017-11-16
| | | | | | | | | | On older kernels, the memfd_create syscall isn't available. Skip shm tests if that is the case. Change-Id: I39c1f1779f1f02e90df727c6ca18b5bdae52e855 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/768102 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Move vm_control to a top-level crateDylan Reid2017-10-09
Break out vm_control to a crate that will be able to used by more modules. Having vm_control usable from outside crosvm makes it possible to move the devices out of crosvm in a later commit. Change-Id: I1f060700ed49b5d77519d55efa2430490d521256 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/706558 Reviewed-by: Zach Reizner <zachr@chromium.org>