diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 361b8105f2..b881b87382 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -1587,7 +1587,7 @@ func (q *qemu) addDevice(devInfo interface{}, devType deviceType) error { q.qemuConfig.Devices = q.arch.appendSocket(q.qemuConfig.Devices, v) case kataVSOCK: q.fds = append(q.fds, v.vhostFd) - q.qemuConfig.Devices = q.arch.appendVSockPCI(q.qemuConfig.Devices, v) + q.qemuConfig.Devices, err = q.arch.appendVSock(q.qemuConfig.Devices, v) case Endpoint: q.qemuConfig.Devices = q.arch.appendNetwork(q.qemuConfig.Devices, v) case config.BlockDrive: diff --git a/virtcontainers/qemu_arch_base.go b/virtcontainers/qemu_arch_base.go index 20d73505c3..ee4491e680 100644 --- a/virtcontainers/qemu_arch_base.go +++ b/virtcontainers/qemu_arch_base.go @@ -79,8 +79,8 @@ type qemuArch interface { // appendSocket appends a socket to devices appendSocket(devices []govmmQemu.Device, socket types.Socket) []govmmQemu.Device - // appendVSockPCI appends a vsock PCI to devices - appendVSockPCI(devices []govmmQemu.Device, vsock kataVSOCK) []govmmQemu.Device + // appendVSock appends a vsock PCI to devices + appendVSock(devices []govmmQemu.Device, vsock kataVSOCK) ([]govmmQemu.Device, error) // appendNetwork appends a endpoint device to devices appendNetwork(devices []govmmQemu.Device, endpoint Endpoint) []govmmQemu.Device @@ -447,7 +447,7 @@ func (q *qemuArchBase) appendSocket(devices []govmmQemu.Device, socket types.Soc return devices } -func (q *qemuArchBase) appendVSockPCI(devices []govmmQemu.Device, vsock kataVSOCK) []govmmQemu.Device { +func (q *qemuArchBase) appendVSock(devices []govmmQemu.Device, vsock kataVSOCK) ([]govmmQemu.Device, error) { devices = append(devices, govmmQemu.VSOCKDevice{ ID: fmt.Sprintf("vsock-%d", vsock.contextID), @@ -457,7 +457,7 @@ func (q *qemuArchBase) appendVSockPCI(devices []govmmQemu.Device, vsock kataVSOC }, ) - return devices + return devices, nil } diff --git a/virtcontainers/qemu_s390x.go b/virtcontainers/qemu_s390x.go index 25350a46ff..8c9dc8ff18 100644 --- a/virtcontainers/qemu_s390x.go +++ b/virtcontainers/qemu_s390x.go @@ -7,11 +7,10 @@ package virtcontainers import ( "fmt" - "time" - govmmQemu "github.com/intel/govmm/qemu" "github.com/kata-containers/runtime/virtcontainers/device/config" "github.com/kata-containers/runtime/virtcontainers/types" + "time" ) type qemuS390x struct { @@ -257,3 +256,28 @@ func (q *qemuS390x) appendSCSIController(devices []govmmQemu.Device, enableIOThr devices = append(devices, d) return devices, t } + +func (q *qemuS390x) appendVSock(devices []govmmQemu.Device, vsock kataVSOCK) ([]govmmQemu.Device, error) { + var devno string + id := fmt.Sprintf("vsock-%d", vsock.contextID) + addr, b, err := q.addDeviceToBridge(id, types.CCW) + if err != nil { + return devices, fmt.Errorf("Failed to append VSock: %v", err) + } + devno, err = b.AddressFormatCCW(addr) + if err != nil { + return devices, fmt.Errorf("Failed to append VSock: %v", err) + } + devices = append(devices, + govmmQemu.VSOCKDevice{ + ID: id, + ContextID: vsock.contextID, + VHostFD: vsock.vhostFd, + DisableModern: false, + DevNo: devno, + }, + ) + + return devices, nil + +}