diff --git a/src/runtime/virtcontainers/network.go b/src/runtime/virtcontainers/network.go index ff09818d2a..975e15bb12 100644 --- a/src/runtime/virtcontainers/network.go +++ b/src/runtime/virtcontainers/network.go @@ -12,6 +12,7 @@ import ( "fmt" "net" "os" + "runtime" "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" @@ -263,6 +264,15 @@ func generateVCNetworkStructures(ctx context.Context, endpoints []Endpoint) ([]* ipAddresses = append(ipAddresses, &ipAddress) } noarp := endpoint.Properties().Iface.RawFlags & unix.IFF_NOARP + devicePath := endpoint.PciPath().String() + if runtime.GOARCH == "s390x" { + device := endpoint.CcwDevice() + if device == nil { + devicePath = "" + } else { + devicePath = device.String() + } + } ifc := pbTypes.Interface{ IPAddresses: ipAddresses, Device: endpoint.Name(), @@ -271,7 +281,7 @@ func generateVCNetworkStructures(ctx context.Context, endpoints []Endpoint) ([]* Type: string(endpoint.Type()), RawFlags: noarp, HwAddr: endpoint.HardwareAddr(), - DevicePath: endpoint.PciPath().String(), + DevicePath: devicePath, } ifaces = append(ifaces, &ifc) diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index 6fd6296ce7..9072170008 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -1942,16 +1942,7 @@ func (q *qemu) hotplugNetDevice(ctx context.Context, endpoint Endpoint, op Opera } }() - bridgeSlot, err := types.PciSlotFromInt(bridge.Addr) - if err != nil { - return err - } - devSlot, err := types.PciSlotFromString(addr) - if err != nil { - return err - } - pciPath, err := types.PciPathFromSlots(bridgeSlot, devSlot) - endpoint.SetPciPath(pciPath) + q.arch.setEndpointDevicePath(endpoint, bridge.Addr, addr) var machine govmmQemu.Machine machine, err = q.getQemuMachine() diff --git a/src/runtime/virtcontainers/qemu_arch_base.go b/src/runtime/virtcontainers/qemu_arch_base.go index 31c55209fa..fe330d01a8 100644 --- a/src/runtime/virtcontainers/qemu_arch_base.go +++ b/src/runtime/virtcontainers/qemu_arch_base.go @@ -116,6 +116,9 @@ type qemuArch interface { // appendRNGDevice appends a RNG device to devices appendRNGDevice(ctx context.Context, devices []govmmQemu.Device, rngDevice config.RNGDev) ([]govmmQemu.Device, error) + // setEndpointDevicePath sets the appropriate PCI or CCW device path for an endpoint + setEndpointDevicePath(endpoint Endpoint, bridgeAddr int, devAddr string) error + // addDeviceToBridge adds devices to the bus addDeviceToBridge(ctx context.Context, ID string, t types.Type) (string, types.Bridge, error) @@ -732,6 +735,23 @@ func (q *qemuArchBase) appendRNGDevice(_ context.Context, devices []govmmQemu.De return devices, nil } +func (q *qemuArchBase) setEndpointDevicePath(endpoint Endpoint, bridgeAddr int, devAddr string) error { + bridgeSlot, err := types.PciSlotFromInt(bridgeAddr) + if err != nil { + return err + } + devSlot, err := types.PciSlotFromString(devAddr) + if err != nil { + return err + } + pciPath, err := types.PciPathFromSlots(bridgeSlot, devSlot) + if err != nil { + return err + } + endpoint.SetPciPath(pciPath) + return nil +} + func (q *qemuArchBase) handleImagePath(config HypervisorConfig) error { if config.ImagePath != "" { kernelRootParams, err := GetKernelRootParams(config.RootfsType, q.disableNvdimm, false) diff --git a/src/runtime/virtcontainers/qemu_s390x.go b/src/runtime/virtcontainers/qemu_s390x.go index 29eaafe5b3..4f2605ddef 100644 --- a/src/runtime/virtcontainers/qemu_s390x.go +++ b/src/runtime/virtcontainers/qemu_s390x.go @@ -304,6 +304,15 @@ func (q *qemuS390x) appendIOMMU(devices []govmmQemu.Device) ([]govmmQemu.Device, return devices, fmt.Errorf("S390x does not support appending a vIOMMU") } +func (q *qemuS390x) setEndpointDevicePath(endpoint Endpoint, bridgeAddr int, devAddr string) error { + ccwDev, err := types.CcwDeviceFrom(bridgeAddr, devAddr) + if err != nil { + return err + } + endpoint.SetCcwDevice(ccwDev) + return nil +} + func (q *qemuS390x) addDeviceToBridge(ctx context.Context, ID string, t types.Type) (string, types.Bridge, error) { addr, b, err := genericAddDeviceToBridge(ctx, q.Bridges, ID, types.CCW) if err != nil {