mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: generic vhost-user: add support
Add VMM support for generic vhost-user devices. Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
committed by
Rob Bradford
parent
8c618ff5e0
commit
085a7a49fa
@@ -51,8 +51,8 @@ use crate::config::RestoreConfig;
|
||||
use crate::device_tree::DeviceTree;
|
||||
use crate::vm::{Error as VmError, VmState};
|
||||
use crate::vm_config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, UserDeviceConfig, VdpaConfig,
|
||||
VmConfig, VsockConfig,
|
||||
DeviceConfig, DiskConfig, FsConfig, GenericVhostUserConfig, NetConfig, PmemConfig,
|
||||
UserDeviceConfig, VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
|
||||
/// API errors are sent back from the VMM API server through the ApiResponse.
|
||||
@@ -170,6 +170,10 @@ pub enum ApiError {
|
||||
#[error("The fs could not be added to the VM")]
|
||||
VmAddFs(#[source] VmError),
|
||||
|
||||
/// The generic vhost-user device could not be added to the VM.
|
||||
#[error("The generic vhost-user device could not be added to the VM")]
|
||||
VmAddGenericVhostUser(#[source] VmError),
|
||||
|
||||
/// The pmem device could not be added to the VM.
|
||||
#[error("The pmem device could not be added to the VM")]
|
||||
VmAddPmem(#[source] VmError),
|
||||
@@ -340,6 +344,11 @@ pub trait RequestHandler {
|
||||
|
||||
fn vm_add_fs(&mut self, fs_cfg: FsConfig) -> Result<Option<Vec<u8>>, VmError>;
|
||||
|
||||
fn vm_add_generic_vhost_user(
|
||||
&mut self,
|
||||
fs_cfg: GenericVhostUserConfig,
|
||||
) -> Result<Option<Vec<u8>>, VmError>;
|
||||
|
||||
fn vm_add_pmem(&mut self, pmem_cfg: PmemConfig) -> Result<Option<Vec<u8>>, VmError>;
|
||||
|
||||
fn vm_add_net(&mut self, net_cfg: NetConfig) -> Result<Option<Vec<u8>>, VmError>;
|
||||
@@ -539,6 +548,43 @@ impl ApiAction for VmAddFs {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VmAddGenericVhostUser;
|
||||
|
||||
impl ApiAction for VmAddGenericVhostUser {
|
||||
type RequestBody = GenericVhostUserConfig;
|
||||
type ResponseBody = Option<Body>;
|
||||
|
||||
fn request(
|
||||
&self,
|
||||
config: Self::RequestBody,
|
||||
response_sender: Sender<ApiResponse>,
|
||||
) -> ApiRequest {
|
||||
Box::new(move |vmm| {
|
||||
info!("API request event: VmAddGenericVhostUser {config:?}");
|
||||
|
||||
let response = vmm
|
||||
.vm_add_generic_vhost_user(config)
|
||||
.map_err(ApiError::VmAddGenericVhostUser)
|
||||
.map(ApiResponsePayload::VmAction);
|
||||
|
||||
response_sender
|
||||
.send(response)
|
||||
.map_err(VmmError::ApiResponseSend)?;
|
||||
|
||||
Ok(false)
|
||||
})
|
||||
}
|
||||
|
||||
fn send(
|
||||
&self,
|
||||
api_evt: EventFd,
|
||||
api_sender: Sender<ApiRequest>,
|
||||
data: Self::RequestBody,
|
||||
) -> ApiResult<Self::ResponseBody> {
|
||||
get_response_body(self, api_evt, api_sender, data)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VmAddPmem;
|
||||
|
||||
impl ApiAction for VmAddPmem {
|
||||
|
||||
Reference in New Issue
Block a user