From 6b2a90a9e55c99c1582dfa09b879b46353a8f24c Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Thu, 5 Sep 2019 11:13:47 +0200 Subject: [PATCH 1/2] virtcontainer: rename appendVSockPCI Rename function appendVSockPCI to appendVSock to be general. The function could use PCI or CCW devices. Added return error to appendVSock. Signed-off-by: Alice Frosi --- virtcontainers/qemu.go | 2 +- virtcontainers/qemu_arch_base.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 2a6143caad..64b882c50e 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -1584,7 +1584,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 } From a0e09df1df6ce203cc46bd0da7691300948bee4b Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Mon, 26 Aug 2019 14:21:13 +0200 Subject: [PATCH 2/2] s390x: add appendVSock with devno Reimplementation of appendVSock in order to assign the devno to the vsock device. Fixes: #2033 Signed-off-by: Alice Frosi --- virtcontainers/qemu_s390x.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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 + +}