Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
qemu: hot plug block devices according with its properties
Browse files Browse the repository at this point in the history
PCI devices have the addr property that correspond to the
address of the parent where the device is plugged, when this
property is set, we have to use the method to hot plug PCI
devices.

fixes #455

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Oct 30, 2017
1 parent 9ff8885 commit 4a67d04
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,16 @@ func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
}

driver := "virtio-blk-pci"
if err := q.qmpMonitorCh.qmp.ExecuteDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, ""); err != nil {

// Addr is PCI specific, use ExecutePCIDeviceAdd if it's NOT empty
if drive.Addr != "" {
if err := q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, drive.Addr, drive.Bus); err != nil {
return err
}
} else {
if err := q.qmpMonitorCh.qmp.ExecuteDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, drive.Bus); err != nil {
return err
}
return err
}
} else {
Expand Down

0 comments on commit 4a67d04

Please sign in to comment.