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
@@ -472,6 +472,24 @@ impl ApplyLandlock for FsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct GenericVhostUserConfig {
|
||||
pub socket: PathBuf,
|
||||
pub queue_sizes: Vec<u16>,
|
||||
#[serde(default)]
|
||||
pub id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub pci_segment: u16,
|
||||
pub device_type: u32,
|
||||
}
|
||||
|
||||
impl ApplyLandlock for GenericVhostUserConfig {
|
||||
fn apply_landlock(&self, landlock: &mut Landlock) -> LandlockResult<()> {
|
||||
landlock.add_rule_with_access(&self.socket, "rw")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub struct PmemConfig {
|
||||
pub file: PathBuf,
|
||||
@@ -924,6 +942,7 @@ pub struct VmConfig {
|
||||
#[serde(default)]
|
||||
pub rng: RngConfig,
|
||||
pub balloon: Option<BalloonConfig>,
|
||||
pub generic_vhost_user: Option<Vec<GenericVhostUserConfig>>,
|
||||
pub fs: Option<Vec<FsConfig>>,
|
||||
pub pmem: Option<Vec<PmemConfig>>,
|
||||
#[serde(default = "default_serial")]
|
||||
@@ -1000,6 +1019,12 @@ impl VmConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(generic_vhost_user_configs) = &self.generic_vhost_user {
|
||||
for generic_vhost_user_config in generic_vhost_user_configs.iter() {
|
||||
generic_vhost_user_config.apply_landlock(&mut landlock)?;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(pmem_configs) = &self.pmem {
|
||||
for pmem_config in pmem_configs.iter() {
|
||||
pmem_config.apply_landlock(&mut landlock)?;
|
||||
|
||||
Reference in New Issue
Block a user