• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use base::SafeDescriptor;
6 use base::Tube;
7 
8 use crate::virtio::vhost_user_frontend::handler::BackendReqHandler;
9 use crate::virtio::vhost_user_frontend::handler::BackendReqHandlerImpl;
10 use crate::virtio::vhost_user_frontend::Error;
11 use crate::virtio::vhost_user_frontend::Result as VhostResult;
12 
create_backend_req_handler( h: BackendReqHandlerImpl, backend_pid: Option<u32>, ) -> VhostResult<(BackendReqHandler, SafeDescriptor)>13 pub fn create_backend_req_handler(
14     h: BackendReqHandlerImpl,
15     backend_pid: Option<u32>,
16 ) -> VhostResult<(BackendReqHandler, SafeDescriptor)> {
17     let backend_pid = backend_pid.expect("tube needs target pid for backend requests");
18     vmm_vhost::FrontendServer::with_tube(h, backend_pid).map_err(Error::CreateBackendReqHandler)
19 }
20