summary refs log tree commit diff
path: root/devices/src/virtio/vhost/worker.rs
Commit message (Collapse)AuthorAge
* devices: make virtio::Interrupt a traitAlyssa Ross2020-06-15
| | | | | This patch is designed not for efficiency, but for minimal code footprint for experimentation. Hence, Box.
* vhost-net: implement direct msix irq fdChuanxiao Dong2020-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | The current vhost-net msix irq injection flow is from vhost-kernel to crosvm vhost-net, then to the KVM for irq injection. It still need crosvm vhost-net to trigger irq, which is because the set_vring_call is not directly using the msix irq fd. To optimize this flow to be from vhost-kernel to KVM directly, need: 1. if the msix is enabled and unmasked, use the misx irq fd for the vring_call directly so that all the misx injection can directly to KVM from vhost-kernel. 2. if the msix is disabled or masked, use the indirect vhost_interrupt fd to let the crosvm to control the irq injection. BUG=None TEST=cargo test -p devices TEST=start crosvm with vhost-net, and run the iperf3 on the network without any issue Change-Id: Idb3427f69f23b728305ed63d88973156a03e7c6b Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2046452 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* vhost: pass response_socket to activate threadChuanxiao Dong2020-03-25
| | | | | | | | | | | | | | Pass the Option of the response socket should be used by the activate thread, to communicate with its device model. BUG=None TEST=cargo test -p devices Change-Id: I929f4c901468e920116f2a744ec73571d91080e3 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2046451 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* vhost-net: implement the reset methodChuanxiao Dong2020-02-06
| | | | | | | | | | | | | | | | Vhost-net reset method can stop the activate thread and let it to return the ownership of eventfds and tap back to the device, so that it is possible to be activated again. BUG=None TEST=launch Crosvm guest with vhost-net. It works fine with iperf test. TEST=cargo test -p devices Change-Id: I8f3cb6939595b4dffa0e95bcffbf9fcc8fcf71ba Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2009665 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* vhost: put kill eventfd to WorkerChuanxiao Dong2020-02-06
| | | | | | | | | | | | | | | | | | | worker.run might encounter error when running but we still need it to give the ownerships of the kill eventfd back so that it can have a second round activate. And Worker structure also contains several other eventfds which will be needed for a second round activate so change to put this eventfd into Worker as well. BUG=None TEST=launch Crosvm guest with vhost-net and vsock. Both of them work fine. TEST=cargo test -p devices Change-Id: I34477cfa3de23d7ab849f741d0ffb098c720a629 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2009664 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org>
* vhost: impl on_device_sandboxed for virtio deviceChuanxiao Dong2020-01-19
| | | | | | | | | | | | | | | | | vhost set_owner fn only needs to be called once. Put it in activate fn will block the vhost devices to be activated again in future. on_device_sandboxed is a good place to put the set_owner as it only run once. So put it there. BUG=None TEST=launch Crosvm guest with vhost-net and vsock. Both of them can work TEST=cargo test -p devices Change-Id: I45308e26b026c9141e4426d8b1bbe1944612a915 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954173 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* vhost: add cleanup_vqs to do some cleanup stuffChuanxiao Dong2020-01-19
| | | | | | | | | | | | | | | | | | | | Activate_vqs is used to do the queue preparation before really running. The virtio-vhost device might need to do some cleanup to allow a second round activate in the future. How to do the cleanup is depending on how the vhost virtio devices. Just add an interface called cleanup_vqs to allow the vhost virtio devices to do their own cleanup stuff. BUG=None TEST=launch Crosvm guest with vhost-net and vsock. Both of them can work TEST=cargo test -p devices Change-Id: I2472e79a8b63c9336f886cde55ffef6a78008ad8 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954172 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: virtio: pass Interrupt to activate()Daniel Verkamp2019-11-18
| | | | | | | | | | | | | | Factor out the common creation of struct Interrupt. No functional change. BUG=chromium:854765 TEST=./build_test Change-Id: Idf8804771ba1af5181818f643e15e1b42918258a Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898268 Tested-by: kokoro <noreply+kokoro@google.com>
* devices: implement dedicated Interrupt struct for virtio WorkerZide Chen2019-10-25
| | | | | | | | | | | | | | | | | | | | | | The code to inject interrupt to the guest can be generic to all virtio devices. This patch: - move those guest interrupt related fields out of Worker structure and put in a separate file, making the worker code cleaner. - remove redandant functions across virtio devices: signal_used_queue(), signal_config_changed(), etc. BUG=chromium:854765 TEST=sanity test on eve and Linux TEST=cargo test -p devices Change-Id: I8e9f760f2057f192fdc74d16a59fea2e6b08c194 Signed-off-by: Zide Chen <zide.chen@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1869553 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: enable MSI-X for virtio-net and viotio-block devicesXiong Zhang2019-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - signal_used_queue(): trigger MSI-X interrupts to the guest if MSI-X is enabled, otherwise trigger INTx interrupts - enable MSI-X on vhost-net: allocate one vhost_interrupt for every MSI-X vector. Performance wise, fio random R/W test on eve pixelbook: INTx MSI-X delta fio write 8.13MiB/s 9.79MiB/s +1.66MiB/s (+20%) fio read 24.35MiB/s 29.3MiB/s +4.95MiB/s (+20%) For networking performance (TCP stream), test results on eve pixelbook: INTx MSI-X delta iperf3 5.93Gbits/s 6.57Gbits/s +0.64Gbits/s (+10.7%) iperf3 -R 5.68Gbits/s 7.37Gbits/s +1.30Gbits/s (+22.8%) iperf test results on VM launched from Ubuntu host (client sends only): INTx MSI-X delta virtio-net 9.53Gbits/s 11.4 Gbits/s +1.87Gbits/s (+19.5%) vhost 28.34Gbits/s 44.43Gbits/s +16.09Gbits/s (+56.7%) BUG=chromium:854765 TEST=cargo test -p devices TEST=tested virtio-net and block on Linux VM and eve pixelbook Change-Id: Ic4952a094327e6b977f446def8209ea2f796878c Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Signed-off-by: Zide Chen <zide.chen@intel.corp-partner.google.com> Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1828340 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@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>
* 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>
* devices: Replace imports involving super::superDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | I find that imports get disorienting when they refer to super::super or beyond and are better written as relative to the crate root. TEST=cargo check --all-features --tests Change-Id: I96dfd09a2784046669ae57a05f83582203a9c29d Reviewed-on: https://chromium-review.googlesource.com/1565727 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: Daniel Verkamp <dverkamp@chromium.org>
* toolchain: Update to Rust 1.31.0David Tolnay2018-12-13
| | | | | | | | | | | | | | | | | | We updated the production toolchain from 1.30 to 1.31 in CL:1366446. This CL does the same upgrade for the local developer toolchain and Kokoro. The relevant changes are in rust-toolchain and kokoro/Dockerfile. The rest are from rustfmt. TEST=cargo fmt --all -- --check TEST=as described in kokoro/README.md Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4 Reviewed-on: https://chromium-review.googlesource.com/1374376 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: pci: support level-triggered interruptsDaniel Verkamp2018-10-29
| | | | | | | | | | | | | | | | Register the irqfd with resample support so that we can correctly emulate level-triggered interrupts. This requires each PciDevice to listen for interrupt_resample events and re-assert the IRQ eventfd if it should still be active. BUG=None TEST=Boot crosvm on x86-64 and arm devices Change-Id: I5cf8d1d1705cf675b453962c00d2d606801fee91 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1298654 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Dylan Reid <dgreid@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>
* devices: use PollContext for all virtio deivcesZach Reizner2018-04-05
| | | | | | | | | | | BUG=chromium:816692 TEST=run any VM Change-Id: I4219050fdb7947ca513f599f1ac57cde6052d397 Reviewed-on: https://chromium-review.googlesource.com/996917 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Move crosvm/hw to a new devices moduleDylan Reid2017-10-09
Moving the devices to their own module makes it easier to add tests that use them. Change-Id: I61bfef4037d16b20145b5fddce604835cdc4f67b Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/706559 Reviewed-by: Zach Reizner <zachr@chromium.org>