summary refs log tree commit diff
path: root/devices/src/virtio/vhost/mod.rs
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2017-10-06 15:26:46 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-09 17:39:05 -0700
commitd169a8d9ed63ae33b8678821c9675963bcee3f92 (patch)
tree03f436cbaeeb74f8fa49e02232162fabed442ba5 /devices/src/virtio/vhost/mod.rs
parent94bf1bf6b4a7791757937e2ffb2a81e797b82922 (diff)
downloadcrosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.tar
crosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.tar.gz
crosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.tar.bz2
crosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.tar.lz
crosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.tar.xz
crosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.tar.zst
crosvm-d169a8d9ed63ae33b8678821c9675963bcee3f92.zip
Move crosvm/hw to a new devices module
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>
Diffstat (limited to 'devices/src/virtio/vhost/mod.rs')
-rw-r--r--devices/src/virtio/vhost/mod.rs72
1 files changed, 72 insertions, 0 deletions
diff --git a/devices/src/virtio/vhost/mod.rs b/devices/src/virtio/vhost/mod.rs
new file mode 100644
index 0000000..1a45c5b
--- /dev/null
+++ b/devices/src/virtio/vhost/mod.rs
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+//! Implements vhost-based virtio devices.
+
+use std;
+
+use net_util::Error as TapError;
+use sys_util::Error as SysError;
+use vhost::Error as VhostError;
+
+mod net;
+mod vsock;
+mod worker;
+
+pub use self::net::Net;
+pub use self::vsock::Vsock;
+
+#[derive(Debug)]
+pub enum Error {
+    /// Creating kill eventfd failed.
+    CreateKillEventFd(SysError),
+    /// Cloning kill eventfd failed.
+    CloneKillEventFd(SysError),
+    /// Error while polling for events.
+    PollError(SysError),
+    /// Open tap device failed.
+    TapOpen(TapError),
+    /// Setting tap IP failed.
+    TapSetIp(TapError),
+    /// Setting tap netmask failed.
+    TapSetNetmask(TapError),
+    /// Setting tap interface offload flags failed.
+    TapSetOffload(TapError),
+    /// Setting vnet header size failed.
+    TapSetVnetHdrSize(TapError),
+    /// Enabling tap interface failed.
+    TapEnable(TapError),
+    /// Failed to open vhost device.
+    VhostOpen(VhostError),
+    /// Set owner failed.
+    VhostSetOwner(VhostError),
+    /// Get features failed.
+    VhostGetFeatures(VhostError),
+    /// Set features failed.
+    VhostSetFeatures(VhostError),
+    /// Set mem table failed.
+    VhostSetMemTable(VhostError),
+    /// Set vring num failed.
+    VhostSetVringNum(VhostError),
+    /// Set vring addr failed.
+    VhostSetVringAddr(VhostError),
+    /// Set vring base failed.
+    VhostSetVringBase(VhostError),
+    /// Set vring call failed.
+    VhostSetVringCall(VhostError),
+    /// Set vring kick failed.
+    VhostSetVringKick(VhostError),
+    /// Net set backend failed.
+    VhostNetSetBackend(VhostError),
+    /// Failed to set CID for guest.
+    VhostVsockSetCid(VhostError),
+    /// Failed to start vhost-vsock driver.
+    VhostVsockStart(VhostError),
+    /// Failed to create vhost eventfd.
+    VhostIrqCreate(SysError),
+    /// Failed to read vhost eventfd.
+    VhostIrqRead(SysError),
+}
+
+pub type Result<T> = std::result::Result<T, Error>;