diff --git a/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs b/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs index a5a918949..1bec668cc 100644 --- a/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs +++ b/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs @@ -108,6 +108,10 @@ impl CloudHypervisorInner { } } + pub(crate) async fn update_device(&mut self, _device: DeviceType) -> Result<()> { + Ok(()) + } + async fn handle_share_fs_device(&mut self, sharefs: ShareFsDevice) -> Result { let device: ShareFsDevice = sharefs.clone(); if device.config.fs_type != VIRTIO_FS { diff --git a/src/runtime-rs/crates/hypervisor/src/ch/mod.rs b/src/runtime-rs/crates/hypervisor/src/ch/mod.rs index 37f52d11c..6f8b6c269 100644 --- a/src/runtime-rs/crates/hypervisor/src/ch/mod.rs +++ b/src/runtime-rs/crates/hypervisor/src/ch/mod.rs @@ -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 { let inner = self.inner.write().await; inner.get_agent_socket().await diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs index a689bcb35..07890de65 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs @@ -543,6 +543,11 @@ impl Device for VfioDevice { Ok(device_index) } + async fn update(&mut self, _h: &dyn hypervisor) -> Result<()> { + // There's no need to do update for vfio device + Ok(()) + } + async fn increase_attach_count(&mut self) -> Result { match self.attach_count { 0 => { diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user_blk.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user_blk.rs index 0912f89f1..5150f1956 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user_blk.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vhost_user_blk.rs @@ -86,6 +86,11 @@ impl Device for VhostUserBlkDevice { Ok(Some(self.config.index)) } + async fn update(&mut self, _h: &dyn hypervisor) -> Result<()> { + // There's no need to do update for vhost-user-blk + Ok(()) + } + async fn get_device_info(&self) -> DeviceType { DeviceType::VhostUserBlk(self.clone()) } diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs index 1de3ff389..a93f8553d 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_blk.rs @@ -114,6 +114,11 @@ impl Device for BlockDevice { Ok(Some(self.config.index)) } + async fn update(&mut self, _h: &dyn hypervisor) -> Result<()> { + // There's no need to do update for virtio-blk + Ok(()) + } + async fn get_device_info(&self) -> DeviceType { DeviceType::Block(self.clone()) } diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_net.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_net.rs index c05503ab5..eac28d81d 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_net.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_net.rs @@ -95,6 +95,11 @@ impl Device for NetworkDevice { Ok(Some(self.config.index)) } + async fn update(&mut self, _h: &dyn hypervisor) -> Result<()> { + // There's no need to do update for network device + Ok(()) + } + async fn get_device_info(&self) -> DeviceType { DeviceType::Network(self.clone()) } diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_vsock.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_vsock.rs index 98f48e29a..6ca887953 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_vsock.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/virtio_vsock.rs @@ -62,6 +62,11 @@ impl Device for HybridVsockDevice { Ok(None) } + async fn update(&mut self, _h: &dyn hypervisor) -> Result<()> { + // There's no need to do update for hvsock device + Ok(()) + } + async fn get_device_info(&self) -> DeviceType { DeviceType::HybridVsock(self.clone()) } diff --git a/src/runtime-rs/crates/hypervisor/src/device/mod.rs b/src/runtime-rs/crates/hypervisor/src/device/mod.rs index 59bb7540d..2051313fa 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/mod.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/mod.rs @@ -54,6 +54,8 @@ pub trait Device: std::fmt::Debug + Send + Sync { async fn attach(&mut self, h: &dyn hypervisor) -> Result<()>; // detach is to unplug device from VM async fn detach(&mut self, h: &dyn hypervisor) -> Result>; + // update is to do update for some device + async fn update(&mut self, h: &dyn hypervisor) -> Result<()>; // get_device_info returns device config async fn get_device_info(&self) -> DeviceType; // increase_attach_count is used to increase the attach count for a device diff --git a/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs b/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs index 90c1ae316..3027dd149 100644 --- a/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs +++ b/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs @@ -101,6 +101,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(); diff --git a/src/runtime-rs/crates/hypervisor/src/dragonball/mod.rs b/src/runtime-rs/crates/hypervisor/src/dragonball/mod.rs index f4cb798bc..399f8ca1b 100644 --- a/src/runtime-rs/crates/hypervisor/src/dragonball/mod.rs +++ b/src/runtime-rs/crates/hypervisor/src/dragonball/mod.rs @@ -110,6 +110,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 { let inner = self.inner.read().await; inner.get_agent_socket().await diff --git a/src/runtime-rs/crates/hypervisor/src/lib.rs b/src/runtime-rs/crates/hypervisor/src/lib.rs index deb7c9242..737133de5 100644 --- a/src/runtime-rs/crates/hypervisor/src/lib.rs +++ b/src/runtime-rs/crates/hypervisor/src/lib.rs @@ -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; diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs index 80f86a56e..e4a3c4e0b 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs @@ -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(()) + } } diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/mod.rs b/src/runtime-rs/crates/hypervisor/src/qemu/mod.rs index d26468632..65b4b6e57 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/mod.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/mod.rs @@ -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 { let inner = self.inner.read().await; inner.get_agent_socket().await