qemu: Return bridge itself with addDeviceToBridge instead of bridge bus

Change the function to return the bridge itself that the
device is attached to. This will allow bridge address to be used
for determining the PCI slot of the device within the guest.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2018-04-26 09:37:14 -07:00
parent 3d1b4a1595
commit dd927921c1

View File

@ -565,7 +565,7 @@ func (q *qemu) qmpSetup() (*govmmQemu.QMP, error) {
return qmp, nil
}
func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
func (q *qemu) addDeviceToBridge(ID string) (string, Bridge, error) {
var err error
var addr uint32
@ -573,11 +573,11 @@ func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
for _, b := range q.state.Bridges {
addr, err = b.addDevice(ID)
if err == nil {
return fmt.Sprintf("0x%x", addr), b.ID, nil
return fmt.Sprintf("%02x", addr), b, nil
}
}
return "", "", err
return "", Bridge{}, err
}
func (q *qemu) removeDeviceFromBridge(ID string) error {
@ -616,12 +616,12 @@ func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
if q.config.BlockDeviceDriver == VirtioBlock {
driver := "virtio-blk-pci"
addr, bus, err := q.addDeviceToBridge(drive.ID)
addr, bridge, err := q.addDeviceToBridge(drive.ID)
if err != nil {
return err
}
if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bus); err != nil {
if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID); err != nil {
return err
}
} else {
@ -676,12 +676,12 @@ func (q *qemu) hotplugVFIODevice(device VFIODevice, op operation) error {
devID := "vfio-" + device.DeviceInfo.ID
if op == addDevice {
addr, bus, err := q.addDeviceToBridge(devID)
addr, bridge, err := q.addDeviceToBridge(devID)
if err != nil {
return err
}
if err := q.qmpMonitorCh.qmp.ExecutePCIVFIODeviceAdd(q.qmpMonitorCh.ctx, devID, device.BDF, addr, bus); err != nil {
if err := q.qmpMonitorCh.qmp.ExecutePCIVFIODeviceAdd(q.qmpMonitorCh.ctx, devID, device.BDF, addr, bridge.ID); err != nil {
return err
}
} else {