Merge pull request #83 from amshinde/remove-device-from-bridge

virtcontainers: qemu: Call removeDeviceFromBridge for virtio-blk
This commit is contained in:
Julio Montes 2018-03-20 13:38:39 -05:00 committed by GitHub
commit 397905f4ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -559,6 +559,19 @@ func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
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 {
defer func(qemu *qemu) {
if q.qmpMonitorCh.qmp != nil {
@ -607,6 +620,12 @@ func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
}
}
} 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 {
return err
}