summary refs log tree commit diff
path: root/vhost_rs/src/vsock.rs
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-08-11 10:49:38 +0000
committerAlyssa Ross <hi@alyssa.is>2021-05-11 12:19:50 +0000
commitfe5750a3854c98635755cd9d0ceb05de896c0e67 (patch)
tree28955f2094e0903a268e4f99eb684d27f1d521fe /vhost_rs/src/vsock.rs
parent8a7e4e902a4950b060ea23b40c0dfce7bfa1b2cb (diff)
downloadcrosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.tar
crosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.tar.gz
crosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.tar.bz2
crosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.tar.lz
crosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.tar.xz
crosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.tar.zst
crosvm-fe5750a3854c98635755cd9d0ceb05de896c0e67.zip
devices: port vhost-user-net from cloud-hypervisor
This is the cloud-hypervisor vhost-user-net code, modified just enough
to compile as part of crosvm.  There is currently no way to run crosvm
with a vhost-user-net device, and even if there were, it wouldn't work
without some further fixes.
Diffstat (limited to 'vhost_rs/src/vsock.rs')
-rw-r--r--vhost_rs/src/vsock.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/vhost_rs/src/vsock.rs b/vhost_rs/src/vsock.rs
new file mode 100644
index 0000000..399b7a3
--- /dev/null
+++ b/vhost_rs/src/vsock.rs
@@ -0,0 +1,30 @@
+// Copyright (C) 2019 Alibaba Cloud Computing. All rights reserved.
+// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
+//
+// Portions Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+//
+// Portions 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-BSD file.
+
+//! Trait to control vhost-vsock backend drivers.
+
+use crate::backend::VhostBackend;
+use crate::Result;
+
+/// Trait to control vhost-vsock backend drivers.
+pub trait VhostVsock: VhostBackend {
+    /// Set the CID for the guest.
+    /// This number is used for routing all data destined for running in the guest.
+    /// Each guest on a hypervisor must have an unique CID.
+    ///
+    /// # Arguments
+    /// * `cid` - CID to assign to the guest
+    fn set_guest_cid(&mut self, cid: u64) -> Result<()>;
+
+    /// Tell the VHOST driver to start performing data transfer.
+    fn start(&mut self) -> Result<()>;
+
+    /// Tell the VHOST driver to stop performing data transfer.
+    fn stop(&mut self) -> Result<()>;
+}