mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-01 08:56:32 +00:00
Merge pull request #83 from amshinde/remove-device-from-bridge
virtcontainers: qemu: Call removeDeviceFromBridge for virtio-blk
This commit is contained in:
@@ -559,6 +559,19 @@ func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
|
|||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *qemu) removeDeviceFromBridge(ID string) error {
|
||||||
|
var err error
|
||||||
|
for _, b := range q.state.Bridges {
|
||||||
|
err = b.removeDevice(ID)
|
||||||
|
if err == nil {
|
||||||
|
// device was removed correctly
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
|
func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
|
||||||
defer func(qemu *qemu) {
|
defer func(qemu *qemu) {
|
||||||
if q.qmpMonitorCh.qmp != nil {
|
if q.qmpMonitorCh.qmp != nil {
|
||||||
@@ -607,6 +620,12 @@ func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if q.config.BlockDeviceDriver == VirtioBlock {
|
||||||
|
if err := q.removeDeviceFromBridge(drive.ID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := q.qmpMonitorCh.qmp.ExecuteDeviceDel(q.qmpMonitorCh.ctx, devID); err != nil {
|
if err := q.qmpMonitorCh.qmp.ExecuteDeviceDel(q.qmpMonitorCh.ctx, devID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user