Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2034 from alicefr/vsock-func
Browse files Browse the repository at this point in the history
s390x: add appendVSock with devno
  • Loading branch information
GabyCT authored Sep 9, 2019
2 parents 0cc1a6f + a0e09df commit 90184f1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -457,7 +457,7 @@ func (q *qemuArchBase) appendVSockPCI(devices []govmmQemu.Device, vsock kataVSOC
},
)

return devices
return devices, nil

}

Expand Down
28 changes: 26 additions & 2 deletions virtcontainers/qemu_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

}

0 comments on commit 90184f1

Please sign in to comment.