mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-02 07:02:16 +00:00
runtime-rs: Add hotunplug_device dispatcher for device type routing
Introduce hotunplug_device() as the device-type dispatcher that routes hot removal requests to the appropriate QMP method. Currently supports Block and BlockModern device types, which are forwarded to Qmp::hotunplug_block_device(). All other device types return an explicit "unsupported" error. Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -931,6 +931,49 @@ impl QemuInner {
|
||||
))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn hotunplug_device(&mut self, device: &DeviceType) -> Result<()> {
|
||||
let qmp = match self.qmp {
|
||||
Some(ref mut qmp) => qmp,
|
||||
None => return Err(anyhow!("QMP not initialized")),
|
||||
};
|
||||
|
||||
match device {
|
||||
DeviceType::Block(ref block_device) => {
|
||||
let block_driver = &self.config.blockdev_info.block_device_driver;
|
||||
qmp.hotunplug_block_device(block_driver, block_device.config.index)
|
||||
.context("hotunplug block device")?;
|
||||
}
|
||||
DeviceType::BlockModern(ref block_device) => {
|
||||
let (index, driver) = {
|
||||
let cfg = &block_device.lock().await.config;
|
||||
(
|
||||
cfg.index,
|
||||
self.config.blockdev_info.block_device_driver.clone(),
|
||||
)
|
||||
};
|
||||
qmp.hotunplug_block_device(&driver, index)
|
||||
.context("hotunplug block device")?;
|
||||
}
|
||||
DeviceType::Network(_)
|
||||
| DeviceType::Vfio(_)
|
||||
| DeviceType::VfioModern(_)
|
||||
| DeviceType::VhostUserBlk(_)
|
||||
| DeviceType::VhostUserNetwork(_)
|
||||
| DeviceType::ShareFs(_)
|
||||
| DeviceType::HybridVsock(_)
|
||||
| DeviceType::Vsock(_)
|
||||
| DeviceType::Protection(_)
|
||||
| DeviceType::PortDevice(_) => {
|
||||
return Err(anyhow!(
|
||||
"hotunplug for {} is currently unsupported",
|
||||
device
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn hotplug_device(&mut self, device: DeviceType) -> Result<DeviceType> {
|
||||
let qmp = match self.qmp {
|
||||
Some(ref mut qmp) => qmp,
|
||||
|
||||
@@ -1036,7 +1036,6 @@ impl Qmp {
|
||||
}
|
||||
|
||||
/// Hotunplug block device.
|
||||
#[allow(dead_code)]
|
||||
pub fn hotunplug_block_device(
|
||||
&mut self,
|
||||
block_driver: &str,
|
||||
|
||||
Reference in New Issue
Block a user