Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #83 from amshinde/remove-device-from-bridge
Browse files Browse the repository at this point in the history
virtcontainers: qemu: Call removeDeviceFromBridge for virtio-blk
  • Loading branch information
Julio Montes authored Mar 20, 2018
2 parents 0619b0e + 5f1bc49 commit 397905f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 397905f

Please sign in to comment.