Skip to content

Commit

Permalink
runtime-rs: bringing virtio-fs device in device-manager
Browse files Browse the repository at this point in the history
Currently, virtio-fs is still outside of the device manager.
This causes some management issues, such as the inability to
unify PCI address management.
To do Enhancement of device manager, it will bring virtio-fs
device in device-manager for unified management

Fixes: #7915

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
  • Loading branch information
Apokleos committed Sep 25, 2023
1 parent 11cf0e2 commit a425d73
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ impl CloudHypervisorInner {
Ok(())
}

pub(crate) async fn update_device(&mut self, _device: DeviceType) -> Result<()> {
Ok(())
}

async fn handle_share_fs_device(&mut self, cfg: ShareFsDeviceConfig) -> Result<()> {
if cfg.fs_type != VIRTIO_FS {
return Err(anyhow!("cannot handle share fs type: {:?}", cfg.fs_type));
Expand Down Expand Up @@ -272,7 +276,7 @@ mod tests {

let v: [u8; 6] = [10, 11, 128, 3, 4, 5];
let mac_address = Address(v);
cfg.guest_mac = Some(mac_address.clone());
cfg.guest_mac = Some(mac_address);

let expected = NetConfig {
tap: Some(cfg.host_dev_name.clone()),
Expand Down
5 changes: 5 additions & 0 deletions src/runtime-rs/crates/hypervisor/src/ch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ impl Hypervisor for CloudHypervisor {
inner.remove_device(device).await
}

async fn update_device(&self, device: DeviceType) -> Result<()> {
let mut inner = self.inner.write().await;
inner.update_device(device).await
}

async fn get_agent_socket(&self) -> Result<String> {
let inner = self.inner.write().await;
inner.get_agent_socket().await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ impl DragonballInner {
}
}

pub(crate) async fn update_device(&mut self, device: DeviceType) -> Result<()> {
info!(sl!(), "dragonball update device {:?}", &device);

Ok(())
}

fn add_vfio_device(&mut self, device: &VfioDevice) -> Result<()> {
let vfio_device = device.clone();

Expand Down
5 changes: 5 additions & 0 deletions src/runtime-rs/crates/hypervisor/src/dragonball/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ impl Hypervisor for Dragonball {
inner.remove_device(device).await
}

async fn update_device(&self, device: DeviceType) -> Result<()> {
let mut inner = self.inner.write().await;
inner.update_device(device).await
}

async fn get_agent_socket(&self) -> Result<String> {
let inner = self.inner.read().await;
inner.get_agent_socket().await
Expand Down
1 change: 1 addition & 0 deletions src/runtime-rs/crates/hypervisor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub trait Hypervisor: std::fmt::Debug + Send + Sync {
// device manager
async fn add_device(&self, device: DeviceType) -> Result<()>;
async fn remove_device(&self, device: DeviceType) -> Result<()>;
async fn update_device(&self, device: DeviceType) -> Result<()>;

// utils
async fn get_agent_socket(&self) -> Result<String>;
Expand Down
6 changes: 6 additions & 0 deletions src/runtime-rs/crates/hypervisor/src/qemu/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,10 @@ impl QemuInner {
info!(sl!(), "QemuInner::remove_device() {} ", device);
todo!()
}

pub(crate) async fn update_device(&mut self, device: DeviceType) -> Result<()> {
info!(sl!(), "QemuInner::update_device() {:?}", &device);

Ok(())
}
}
5 changes: 5 additions & 0 deletions src/runtime-rs/crates/hypervisor/src/qemu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ impl Hypervisor for Qemu {
inner.remove_device(device).await
}

async fn update_device(&self, device: DeviceType) -> Result<()> {
let mut inner = self.inner.write().await;
inner.update_device(device).await
}

async fn get_agent_socket(&self) -> Result<String> {
let inner = self.inner.read().await;
inner.get_agent_socket().await
Expand Down

0 comments on commit a425d73

Please sign in to comment.