mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-17 14:58:16 +00:00
Merge pull request #53 from sboeuf/fix_pcie_bridge
qemu: Fix the support of PCIe bridge
This commit is contained in:
19
qemu/qemu.go
19
qemu/qemu.go
@@ -938,18 +938,19 @@ func (bridgeDev BridgeDevice) Valid() bool {
|
|||||||
// QemuParams returns the qemu parameters built out of this bridge device.
|
// QemuParams returns the qemu parameters built out of this bridge device.
|
||||||
func (bridgeDev BridgeDevice) QemuParams(config *Config) []string {
|
func (bridgeDev BridgeDevice) QemuParams(config *Config) []string {
|
||||||
var qemuParams []string
|
var qemuParams []string
|
||||||
|
var deviceParam string
|
||||||
|
|
||||||
shpc := "off"
|
switch bridgeDev.Type {
|
||||||
if bridgeDev.SHPC {
|
case PCIEBridge:
|
||||||
shpc = "on"
|
deviceParam = fmt.Sprintf("pcie-pci-bridge,bus=%s,id=%s", bridgeDev.Bus, bridgeDev.ID)
|
||||||
|
default:
|
||||||
|
shpc := "off"
|
||||||
|
if bridgeDev.SHPC {
|
||||||
|
shpc = "on"
|
||||||
|
}
|
||||||
|
deviceParam = fmt.Sprintf("pci-bridge,bus=%s,id=%s,chassis_nr=%d,shpc=%s", bridgeDev.Bus, bridgeDev.ID, bridgeDev.Chassis, shpc)
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceName := "pci-bridge"
|
|
||||||
if bridgeDev.Type == PCIEBridge {
|
|
||||||
deviceName = "pcie-pci-bridge"
|
|
||||||
}
|
|
||||||
|
|
||||||
deviceParam := fmt.Sprintf("%s,bus=%s,id=%s,chassis_nr=%d,shpc=%s", deviceName, bridgeDev.Bus, bridgeDev.ID, bridgeDev.Chassis, shpc)
|
|
||||||
if bridgeDev.Addr != "" {
|
if bridgeDev.Addr != "" {
|
||||||
addr, err := strconv.Atoi(bridgeDev.Addr)
|
addr, err := strconv.Atoi(bridgeDev.Addr)
|
||||||
if err == nil && addr >= 0 {
|
if err == nil && addr >= 0 {
|
||||||
|
@@ -420,9 +420,9 @@ 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"
|
var devicePCIBridgeString = "-device pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,chassis_nr=5,shpc=on,addr=ff"
|
||||||
|
|
||||||
func TestAppendBridgeDevice(t *testing.T) {
|
func TestAppendPCIBridgeDevice(t *testing.T) {
|
||||||
|
|
||||||
bridge := BridgeDevice{
|
bridge := BridgeDevice{
|
||||||
Type: PCIBridge,
|
Type: PCIBridge,
|
||||||
@@ -433,7 +433,21 @@ func TestAppendBridgeDevice(t *testing.T) {
|
|||||||
SHPC: true,
|
SHPC: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
testAppend(bridge, deviceBridgeString, t)
|
testAppend(bridge, devicePCIBridgeString, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
var devicePCIEBridgeString = "-device pcie-pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,addr=ff"
|
||||||
|
|
||||||
|
func TestAppendPCIEBridgeDevice(t *testing.T) {
|
||||||
|
|
||||||
|
bridge := BridgeDevice{
|
||||||
|
Type: PCIEBridge,
|
||||||
|
ID: "mybridge",
|
||||||
|
Bus: "/pci-bus/pcie.0",
|
||||||
|
Addr: "255",
|
||||||
|
}
|
||||||
|
|
||||||
|
testAppend(bridge, devicePCIEBridgeString, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAppendEmptyDevice(t *testing.T) {
|
func TestAppendEmptyDevice(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user