mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-01 22:50:54 +00:00
runtime-rs: Implement remove_device for block device hot removal
Replace the "Not yet implemented" stub in QemuInner::remove_device() with a working implementation that calls hotunplug_device() to perform the QMP-level device removal, then cleans up the internal devices list via retain() to remove stale coldplug entries. Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -925,13 +925,17 @@ impl QemuInner {
|
||||
|
||||
pub(crate) async fn remove_device(&mut self, device: DeviceType) -> Result<()> {
|
||||
info!(sl!(), "QemuInner::remove_device() {} ", device);
|
||||
Err(anyhow!(
|
||||
"QemuInner::remove_device({}): Not yet implemented",
|
||||
device
|
||||
))
|
||||
self.hotunplug_device(&device).await?;
|
||||
|
||||
self.devices.retain(|d| match (d, &device) {
|
||||
(DeviceType::Block(a), DeviceType::Block(b)) => a.config.index != b.config.index,
|
||||
(DeviceType::BlockModern(a), DeviceType::BlockModern(b)) => !std::sync::Arc::ptr_eq(a, b),
|
||||
_ => true,
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn hotunplug_device(&mut self, device: &DeviceType) -> Result<()> {
|
||||
let qmp = match self.qmp {
|
||||
Some(ref mut qmp) => qmp,
|
||||
|
||||
Reference in New Issue
Block a user