blob: 9edc9a99b9e923b9e5a0523c1c7d87ab3462c1cb [file] [log] [blame]
// Copyright 2020 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.
use base::Error as SysError;
use msg_socket::{MsgOnSocket, MsgSocket};
#[derive(MsgOnSocket, Debug)]
pub enum VhostDevRequest {
/// Mask or unmask all the MSI entries for a Virtio Vhost device.
MsixChanged,
/// Mask or unmask a MSI entry for a Virtio Vhost device.
MsixEntryChanged(usize),
}
#[derive(MsgOnSocket, Debug)]
pub enum VhostDevResponse {
Ok,
Err(SysError),
}
pub type VhostDevRequestSocket = MsgSocket<VhostDevRequest, VhostDevResponse>;
pub type VhostDevResponseSocket = MsgSocket<VhostDevResponse, VhostDevRequest>;
/// Create control socket pair. This pair is used to communicate with the
/// virtio device process.
/// Mainly between the virtio and activate thread.
pub fn create_control_sockets() -> (
Option<VhostDevRequestSocket>,
Option<VhostDevResponseSocket>,
) {
match msg_socket::pair::<VhostDevRequest, VhostDevResponse>() {
Ok((request, response)) => (Some(request), Some(response)),
_ => (None, None),
}
}