mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 05:58:04 +00:00
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:
parent
1509acf186
commit
30aeacb89e
10
qemu/qemu.go
10
qemu/qemu.go
@ -907,6 +907,9 @@ type BridgeDevice struct {
|
|||||||
|
|
||||||
// SHPC is used to enable or disable the standard hot plug controller
|
// SHPC is used to enable or disable the standard hot plug controller
|
||||||
SHPC bool
|
SHPC bool
|
||||||
|
|
||||||
|
// PCI Slot
|
||||||
|
Addr string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid returns true if the BridgeDevice structure is valid and complete.
|
// 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)
|
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, "-device")
|
||||||
qemuParams = append(qemuParams, deviceParam)
|
qemuParams = append(qemuParams, deviceParam)
|
||||||
|
|
||||||
|
@ -365,6 +365,22 @@ func TestAppendDeviceSCSIController(t *testing.T) {
|
|||||||
testAppend(scsiCon, deviceSCSIControllerBusAddrStr, t)
|
testAppend(scsiCon, deviceSCSIControllerBusAddrStr, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deviceBridgeString = "-device pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,chassis_nr=5,shpc=on,addr=ff"
|
||||||
|
|
||||||
|
func TestAppendBridgeDevice(t *testing.T) {
|
||||||
|
|
||||||
|
bridge := BridgeDevice{
|
||||||
|
Type: PCIBridge,
|
||||||
|
ID: "mybridge",
|
||||||
|
Bus: "/pci-bus/pcie.0",
|
||||||
|
Addr: "255",
|
||||||
|
Chassis: 5,
|
||||||
|
SHPC: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
testAppend(bridge, deviceBridgeString, t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestAppendEmptyDevice(t *testing.T) {
|
func TestAppendEmptyDevice(t *testing.T) {
|
||||||
device := SerialDevice{}
|
device := SerialDevice{}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user