qemu: Add qemu parameter for PCI address for a bridge.

We need to be able to specify the PCI slot for a bridge while
adding it.
Add test to verify bridge is correctly added.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde
2018-04-03 11:57:26 -07:00
parent 1509acf186
commit 30aeacb89e
2 changed files with 26 additions and 0 deletions

View File

@@ -907,6 +907,9 @@ type BridgeDevice struct {
// SHPC is used to enable or disable the standard hot plug controller
SHPC bool
// PCI Slot
Addr string
}
// Valid returns true if the BridgeDevice structure is valid and complete.
@@ -941,6 +944,13 @@ func (bridgeDev BridgeDevice) QemuParams(config *Config) []string {
}
deviceParam := fmt.Sprintf("%s,bus=%s,id=%s,chassis_nr=%d,shpc=%s", deviceName, bridgeDev.Bus, bridgeDev.ID, bridgeDev.Chassis, shpc)
if bridgeDev.Addr != "" {
addr, err := strconv.Atoi(bridgeDev.Addr)
if err == nil && addr >= 0 {
deviceParam += fmt.Sprintf(",addr=%x", addr)
}
}
qemuParams = append(qemuParams, "-device")
qemuParams = append(qemuParams, deviceParam)