1 // Copyright (C) 2019 Alibaba Cloud Computing. All rights reserved. 2 // SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause 3 // 4 // Portions Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 // 6 // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. 7 // Use of this source code is governed by a BSD-style license that can be 8 // found in the LICENSE-BSD-Google file. 9 10 //! Trait to control vhost-vsock backend drivers. 11 12 use crate::backend::VhostBackend; 13 use crate::Result; 14 15 /// Trait to control vhost-vsock backend drivers. 16 pub trait VhostVsock: VhostBackend { 17 /// Set the CID for the guest. 18 /// This number is used for routing all data destined for running in the guest. 19 /// Each guest on a hypervisor must have an unique CID. 20 /// 21 /// # Arguments 22 /// * `cid` - CID to assign to the guest set_guest_cid(&self, cid: u64) -> Result<()>23 fn set_guest_cid(&self, cid: u64) -> Result<()>; 24 25 /// Tell the VHOST driver to start performing data transfer. start(&self) -> Result<()>26 fn start(&self) -> Result<()>; 27 28 /// Tell the VHOST driver to stop performing data transfer. stop(&self) -> Result<()>29 fn stop(&self) -> Result<()>; 30 } 31