mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
virtcontainers: Fix missing contexts in s390x
#1389 has added a context for many signatures to improve trace spans. Functions specific to s390x lack this. Add context where required. This affects some common code signatures, since some functions that do not require context on other architectures do require it on s390x. Also remove an unnecessary import in test_qemu_s390x.go. Fixes: #1562 Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
This commit is contained in:
parent
594c47ab6c
commit
31ced01eba
@ -346,14 +346,14 @@ func (q *qemu) getQemuMachine() (govmmQemu.Machine, error) {
|
|||||||
return machine, nil
|
return machine, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemu) appendImage(devices []govmmQemu.Device) ([]govmmQemu.Device, error) {
|
func (q *qemu) appendImage(ctx context.Context, devices []govmmQemu.Device) ([]govmmQemu.Device, error) {
|
||||||
imagePath, err := q.config.ImageAssetPath()
|
imagePath, err := q.config.ImageAssetPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if imagePath != "" {
|
if imagePath != "" {
|
||||||
devices, err = q.arch.appendImage(devices, imagePath)
|
devices, err = q.arch.appendImage(ctx, devices, imagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -395,13 +395,13 @@ func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu
|
|||||||
// bridge gets the first available PCI address i.e bridgePCIStartAddr
|
// bridge gets the first available PCI address i.e bridgePCIStartAddr
|
||||||
devices = q.arch.appendBridges(devices)
|
devices = q.arch.appendBridges(devices)
|
||||||
|
|
||||||
devices, err = q.arch.appendConsole(devices, console)
|
devices, err = q.arch.appendConsole(ctx, devices, console)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if initrdPath == "" {
|
if initrdPath == "" {
|
||||||
devices, err = q.appendImage(devices)
|
devices, err = q.appendImage(ctx, devices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ func (q *qemu) buildDevices(ctx context.Context, initrdPath string) ([]govmmQemu
|
|||||||
|
|
||||||
var ioThread *govmmQemu.IOThread
|
var ioThread *govmmQemu.IOThread
|
||||||
if q.config.BlockDeviceDriver == config.VirtioSCSI {
|
if q.config.BlockDeviceDriver == config.VirtioSCSI {
|
||||||
return q.arch.appendSCSIController(devices, q.config.EnableIOThreads)
|
return q.arch.appendSCSIController(ctx, devices, q.config.EnableIOThreads)
|
||||||
}
|
}
|
||||||
|
|
||||||
return devices, ioThread, nil
|
return devices, ioThread, nil
|
||||||
@ -611,7 +611,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
|||||||
ID: rngID,
|
ID: rngID,
|
||||||
Filename: q.config.EntropySource,
|
Filename: q.config.EntropySource,
|
||||||
}
|
}
|
||||||
qemuConfig.Devices, err = q.arch.appendRNGDevice(qemuConfig.Devices, rngDev)
|
qemuConfig.Devices, err = q.arch.appendRNGDevice(ctx, qemuConfig.Devices, rngDev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1882,17 +1882,17 @@ func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType devic
|
|||||||
q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, vhostDev)
|
q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, vhostDev)
|
||||||
} else {
|
} else {
|
||||||
q.Logger().WithField("volume-type", "virtio-9p").Info("adding volume")
|
q.Logger().WithField("volume-type", "virtio-9p").Info("adding volume")
|
||||||
q.qemuConfig.Devices, err = q.arch.append9PVolume(q.qemuConfig.Devices, v)
|
q.qemuConfig.Devices, err = q.arch.append9PVolume(ctx, q.qemuConfig.Devices, v)
|
||||||
}
|
}
|
||||||
case types.Socket:
|
case types.Socket:
|
||||||
q.qemuConfig.Devices = q.arch.appendSocket(q.qemuConfig.Devices, v)
|
q.qemuConfig.Devices = q.arch.appendSocket(q.qemuConfig.Devices, v)
|
||||||
case types.VSock:
|
case types.VSock:
|
||||||
q.fds = append(q.fds, v.VhostFd)
|
q.fds = append(q.fds, v.VhostFd)
|
||||||
q.qemuConfig.Devices, err = q.arch.appendVSock(q.qemuConfig.Devices, v)
|
q.qemuConfig.Devices, err = q.arch.appendVSock(ctx, q.qemuConfig.Devices, v)
|
||||||
case Endpoint:
|
case Endpoint:
|
||||||
q.qemuConfig.Devices, err = q.arch.appendNetwork(q.qemuConfig.Devices, v)
|
q.qemuConfig.Devices, err = q.arch.appendNetwork(ctx, q.qemuConfig.Devices, v)
|
||||||
case config.BlockDrive:
|
case config.BlockDrive:
|
||||||
q.qemuConfig.Devices, err = q.arch.appendBlockDevice(q.qemuConfig.Devices, v)
|
q.qemuConfig.Devices, err = q.arch.appendBlockDevice(ctx, q.qemuConfig.Devices, v)
|
||||||
case config.VhostUserDeviceAttrs:
|
case config.VhostUserDeviceAttrs:
|
||||||
q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, v)
|
q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, v)
|
||||||
case config.VFIODev:
|
case config.VFIODev:
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package virtcontainers
|
package virtcontainers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -179,11 +180,11 @@ func (q *qemuAmd64) supportGuestMemoryHotplug() bool {
|
|||||||
return q.qemuMachine.Type != govmmQemu.MachineTypeMicrovm
|
return q.qemuMachine.Type != govmmQemu.MachineTypeMicrovm
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuAmd64) appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuAmd64) appendImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
if !q.disableNvdimm {
|
if !q.disableNvdimm {
|
||||||
return q.appendNvdimmImage(devices, path)
|
return q.appendNvdimmImage(devices, path)
|
||||||
}
|
}
|
||||||
return q.appendBlockImage(devices, path)
|
return q.appendBlockImage(ctx, devices, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// appendBridges appends to devices the given bridges
|
// appendBridges appends to devices the given bridges
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package virtcontainers
|
package virtcontainers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -155,7 +156,7 @@ func TestQemuAmd64AppendImage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
devices, err := amd64.appendImage(nil, f.Name())
|
devices, err := amd64.appendImage(context.Background(), nil, f.Name())
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(expectedOut, devices)
|
assert.Equal(expectedOut, devices)
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ func TestQemuAmd64AppendImage(t *testing.T) {
|
|||||||
assert.NotContains(amd64.machine().Options, qemuNvdimmOption)
|
assert.NotContains(amd64.machine().Options, qemuNvdimmOption)
|
||||||
|
|
||||||
found := false
|
found := false
|
||||||
devices, err = amd64.appendImage(nil, f.Name())
|
devices, err = amd64.appendImage(context.Background(), nil, f.Name())
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
for _, d := range devices {
|
for _, d := range devices {
|
||||||
if b, ok := d.(govmmQemu.BlockDevice); ok {
|
if b, ok := d.(govmmQemu.BlockDevice); ok {
|
||||||
|
@ -63,37 +63,37 @@ type qemuArch interface {
|
|||||||
memoryTopology(memoryMb, hostMemoryMb uint64, slots uint8) govmmQemu.Memory
|
memoryTopology(memoryMb, hostMemoryMb uint64, slots uint8) govmmQemu.Memory
|
||||||
|
|
||||||
// appendConsole appends a console to devices
|
// appendConsole appends a console to devices
|
||||||
appendConsole(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
appendConsole(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendImage appends an image to devices
|
// appendImage appends an image to devices
|
||||||
appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
appendImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendBlockImage appends an image as block device
|
// appendBlockImage appends an image as block device
|
||||||
appendBlockImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
appendBlockImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendNvdimmImage appends an image as nvdimm device
|
// appendNvdimmImage appends an image as nvdimm device
|
||||||
appendNvdimmImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
appendNvdimmImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendSCSIController appens a SCSI controller to devices
|
// appendSCSIController appens a SCSI controller to devices
|
||||||
appendSCSIController(devices []govmmQemu.Device, enableIOThreads bool) ([]govmmQemu.Device, *govmmQemu.IOThread, error)
|
appendSCSIController(context context.Context, devices []govmmQemu.Device, enableIOThreads bool) ([]govmmQemu.Device, *govmmQemu.IOThread, error)
|
||||||
|
|
||||||
// appendBridges appends bridges to devices
|
// appendBridges appends bridges to devices
|
||||||
appendBridges(devices []govmmQemu.Device) []govmmQemu.Device
|
appendBridges(devices []govmmQemu.Device) []govmmQemu.Device
|
||||||
|
|
||||||
// append9PVolume appends a 9P volume to devices
|
// append9PVolume appends a 9P volume to devices
|
||||||
append9PVolume(devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error)
|
append9PVolume(ctx context.Context, devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendSocket appends a socket to devices
|
// appendSocket appends a socket to devices
|
||||||
appendSocket(devices []govmmQemu.Device, socket types.Socket) []govmmQemu.Device
|
appendSocket(devices []govmmQemu.Device, socket types.Socket) []govmmQemu.Device
|
||||||
|
|
||||||
// appendVSock appends a vsock PCI to devices
|
// appendVSock appends a vsock PCI to devices
|
||||||
appendVSock(devices []govmmQemu.Device, vsock types.VSock) ([]govmmQemu.Device, error)
|
appendVSock(ctx context.Context, devices []govmmQemu.Device, vsock types.VSock) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendNetwork appends a endpoint device to devices
|
// appendNetwork appends a endpoint device to devices
|
||||||
appendNetwork(devices []govmmQemu.Device, endpoint Endpoint) ([]govmmQemu.Device, error)
|
appendNetwork(ctx context.Context, devices []govmmQemu.Device, endpoint Endpoint) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendBlockDevice appends a block drive to devices
|
// appendBlockDevice appends a block drive to devices
|
||||||
appendBlockDevice(devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error)
|
appendBlockDevice(ctx context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// appendVhostUserDevice appends a vhost user device to devices
|
// appendVhostUserDevice appends a vhost user device to devices
|
||||||
appendVhostUserDevice(devices []govmmQemu.Device, drive config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error)
|
appendVhostUserDevice(devices []govmmQemu.Device, drive config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error)
|
||||||
@ -102,7 +102,7 @@ type qemuArch interface {
|
|||||||
appendVFIODevice(devices []govmmQemu.Device, vfioDevice config.VFIODev) []govmmQemu.Device
|
appendVFIODevice(devices []govmmQemu.Device, vfioDevice config.VFIODev) []govmmQemu.Device
|
||||||
|
|
||||||
// appendRNGDevice appends a RNG device to devices
|
// appendRNGDevice appends a RNG device to devices
|
||||||
appendRNGDevice(devices []govmmQemu.Device, rngDevice config.RNGDev) ([]govmmQemu.Device, error)
|
appendRNGDevice(ctx context.Context, devices []govmmQemu.Device, rngDevice config.RNGDev) ([]govmmQemu.Device, error)
|
||||||
|
|
||||||
// addDeviceToBridge adds devices to the bus
|
// addDeviceToBridge adds devices to the bus
|
||||||
addDeviceToBridge(ctx context.Context, ID string, t types.Type) (string, types.Bridge, error)
|
addDeviceToBridge(ctx context.Context, ID string, t types.Type) (string, types.Bridge, error)
|
||||||
@ -313,7 +313,7 @@ func (q *qemuArchBase) memoryTopology(memoryMb, hostMemoryMb uint64, slots uint8
|
|||||||
return memory
|
return memory
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendConsole(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendConsole(_ context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
serial := govmmQemu.SerialDevice{
|
serial := govmmQemu.SerialDevice{
|
||||||
Driver: govmmQemu.VirtioSerial,
|
Driver: govmmQemu.VirtioSerial,
|
||||||
ID: "serial0",
|
ID: "serial0",
|
||||||
@ -385,16 +385,16 @@ func (q *qemuArchBase) appendNvdimmImage(devices []govmmQemu.Device, path string
|
|||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
return q.appendBlockImage(devices, path)
|
return q.appendBlockImage(ctx, devices, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendBlockImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendBlockImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
drive, err := genericImage(path)
|
drive, err := genericImage(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
devices, err = q.appendBlockDevice(devices, drive)
|
devices, err = q.appendBlockDevice(ctx, devices, drive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ func genericSCSIController(enableIOThreads, nestedRun bool) (govmmQemu.SCSIContr
|
|||||||
return scsiController, t
|
return scsiController, t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendSCSIController(devices []govmmQemu.Device, enableIOThreads bool) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
func (q *qemuArchBase) appendSCSIController(_ context.Context, devices []govmmQemu.Device, enableIOThreads bool) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
||||||
d, t := genericSCSIController(enableIOThreads, q.nestedRun)
|
d, t := genericSCSIController(enableIOThreads, q.nestedRun)
|
||||||
devices = append(devices, d)
|
devices = append(devices, d)
|
||||||
return devices, t, nil
|
return devices, t, nil
|
||||||
@ -480,7 +480,7 @@ func genericAppend9PVolume(devices []govmmQemu.Device, volume types.Volume, nest
|
|||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) append9PVolume(devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) append9PVolume(_ context.Context, devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error) {
|
||||||
if volume.MountTag == "" || volume.HostPath == "" {
|
if volume.MountTag == "" || volume.HostPath == "" {
|
||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
@ -514,7 +514,7 @@ func (q *qemuArchBase) appendSocket(devices []govmmQemu.Device, socket types.Soc
|
|||||||
return devices
|
return devices
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendVSock(devices []govmmQemu.Device, vsock types.VSock) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendVSock(_ context.Context, devices []govmmQemu.Device, vsock types.VSock) ([]govmmQemu.Device, error) {
|
||||||
devices = append(devices,
|
devices = append(devices,
|
||||||
govmmQemu.VSOCKDevice{
|
govmmQemu.VSOCKDevice{
|
||||||
ID: fmt.Sprintf("vsock-%d", vsock.ContextID),
|
ID: fmt.Sprintf("vsock-%d", vsock.ContextID),
|
||||||
@ -592,7 +592,7 @@ func genericNetwork(endpoint Endpoint, vhost, nestedRun bool, index int) (govmmQ
|
|||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendNetwork(devices []govmmQemu.Device, endpoint Endpoint) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendNetwork(_ context.Context, devices []govmmQemu.Device, endpoint Endpoint) ([]govmmQemu.Device, error) {
|
||||||
d, err := genericNetwork(endpoint, q.vhost, q.nestedRun, q.networkIndex)
|
d, err := genericNetwork(endpoint, q.vhost, q.nestedRun, q.networkIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append network %v", err)
|
return devices, fmt.Errorf("Failed to append network %v", err)
|
||||||
@ -624,7 +624,7 @@ func genericBlockDevice(drive config.BlockDrive, nestedRun bool) (govmmQemu.Bloc
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendBlockDevice(devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendBlockDevice(_ context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) {
|
||||||
d, err := genericBlockDevice(drive, q.nestedRun)
|
d, err := genericBlockDevice(drive, q.nestedRun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append block device %v", err)
|
return devices, fmt.Errorf("Failed to append block device %v", err)
|
||||||
@ -678,7 +678,7 @@ func (q *qemuArchBase) appendVFIODevice(devices []govmmQemu.Device, vfioDev conf
|
|||||||
return devices
|
return devices
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArchBase) appendRNGDevice(devices []govmmQemu.Device, rngDev config.RNGDev) ([]govmmQemu.Device, error) {
|
func (q *qemuArchBase) appendRNGDevice(_ context.Context, devices []govmmQemu.Device, rngDev config.RNGDev) ([]govmmQemu.Device, error) {
|
||||||
devices = append(devices,
|
devices = append(devices,
|
||||||
govmmQemu.RngDevice{
|
govmmQemu.RngDevice{
|
||||||
ID: rngDev.ID,
|
ID: rngDev.ID,
|
||||||
|
@ -216,11 +216,11 @@ func testQemuArchBaseAppend(t *testing.T, structure interface{}, expected []govm
|
|||||||
|
|
||||||
switch s := structure.(type) {
|
switch s := structure.(type) {
|
||||||
case types.Volume:
|
case types.Volume:
|
||||||
devices, err = qemuArchBase.append9PVolume(devices, s)
|
devices, err = qemuArchBase.append9PVolume(context.Background(), devices, s)
|
||||||
case types.Socket:
|
case types.Socket:
|
||||||
devices = qemuArchBase.appendSocket(devices, s)
|
devices = qemuArchBase.appendSocket(devices, s)
|
||||||
case config.BlockDrive:
|
case config.BlockDrive:
|
||||||
devices, err = qemuArchBase.appendBlockDevice(devices, s)
|
devices, err = qemuArchBase.appendBlockDevice(context.Background(), devices, s)
|
||||||
case config.VFIODev:
|
case config.VFIODev:
|
||||||
devices = qemuArchBase.appendVFIODevice(devices, s)
|
devices = qemuArchBase.appendVFIODevice(devices, s)
|
||||||
case config.VhostUserDeviceAttrs:
|
case config.VhostUserDeviceAttrs:
|
||||||
@ -254,7 +254,7 @@ func TestQemuArchBaseAppendConsoles(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
devices, err = qemuArchBase.appendConsole(devices, path)
|
devices, err = qemuArchBase.appendConsole(context.Background(), devices, path)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(expectedOut, devices)
|
assert.Equal(expectedOut, devices)
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ func TestQemuArchBaseAppendImage(t *testing.T) {
|
|||||||
err = image.Close()
|
err = image.Close()
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
devices, err = qemuArchBase.appendImage(devices, image.Name())
|
devices, err = qemuArchBase.appendImage(context.Background(), devices, image.Name())
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Len(devices, 1)
|
assert.Len(devices, 1)
|
||||||
|
|
||||||
@ -469,12 +469,12 @@ func TestQemuArchBaseAppendSCSIController(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
devices, ioThread, err := qemuArchBase.appendSCSIController(devices, false)
|
devices, ioThread, err := qemuArchBase.appendSCSIController(context.Background(), devices, false)
|
||||||
assert.Equal(expectedOut, devices)
|
assert.Equal(expectedOut, devices)
|
||||||
assert.Nil(ioThread)
|
assert.Nil(ioThread)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
_, ioThread, err = qemuArchBase.appendSCSIController(devices, true)
|
_, ioThread, err = qemuArchBase.appendSCSIController(context.Background(), devices, true)
|
||||||
assert.NotNil(ioThread)
|
assert.NotNil(ioThread)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
@ -539,9 +539,9 @@ func TestQemuArchBaseAppendNetwork(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
devices, err = qemuArchBase.appendNetwork(devices, macvlanEp)
|
devices, err = qemuArchBase.appendNetwork(context.Background(), devices, macvlanEp)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
devices, err = qemuArchBase.appendNetwork(devices, macvtapEp)
|
devices, err = qemuArchBase.appendNetwork(context.Background(), devices, macvtapEp)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(expectedOut, devices)
|
assert.Equal(expectedOut, devices)
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,11 @@ func (q *qemuArm64) appendBridges(devices []govmmQemu.Device) []govmmQemu.Device
|
|||||||
return genericAppendBridges(devices, q.Bridges, q.qemuMachine.Type)
|
return genericAppendBridges(devices, q.Bridges, q.qemuMachine.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArm64) appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuArm64) appendImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
if !q.disableNvdimm {
|
if !q.disableNvdimm {
|
||||||
return q.appendNvdimmImage(devices, path)
|
return q.appendNvdimmImage(devices, path)
|
||||||
}
|
}
|
||||||
return q.appendBlockImage(devices, path)
|
return q.appendBlockImage(ctx, devices, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArm64) setIgnoreSharedMemoryMigrationCaps(_ context.Context, _ *govmmQemu.QMP) error {
|
func (q *qemuArm64) setIgnoreSharedMemoryMigrationCaps(_ context.Context, _ *govmmQemu.QMP) error {
|
||||||
@ -109,7 +109,7 @@ func (q *qemuArm64) appendIOMMU(devices []govmmQemu.Device) ([]govmmQemu.Device,
|
|||||||
return devices, fmt.Errorf("Arm64 architecture does not support vIOMMU")
|
return devices, fmt.Errorf("Arm64 architecture does not support vIOMMU")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuArm64) append9PVolume(devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error) {
|
func (q *qemuArm64) append9PVolume(_ context.Context, devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error) {
|
||||||
d, err := genericAppend9PVolume(devices, volume, q.nestedRun)
|
d, err := genericAppend9PVolume(devices, volume, q.nestedRun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package virtcontainers
|
package virtcontainers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -121,7 +122,7 @@ func TestQemuArm64AppendImage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
devices, err = arm64.appendImage(devices, f.Name())
|
devices, err = arm64.appendImage(context.Background(), devices, f.Name())
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(expectedOut, devices)
|
assert.Equal(expectedOut, devices)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package virtcontainers
|
package virtcontainers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -87,9 +88,9 @@ func (q *qemuS390x) bridges(number uint32) {
|
|||||||
|
|
||||||
// appendConsole appends a console to devices.
|
// appendConsole appends a console to devices.
|
||||||
// The function has been overwriten to correctly set the driver to the CCW device
|
// The function has been overwriten to correctly set the driver to the CCW device
|
||||||
func (q *qemuS390x) appendConsole(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendConsole(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
id := "serial0"
|
id := "serial0"
|
||||||
addr, b, err := q.addDeviceToBridge(id, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, id, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append console %v", err)
|
return devices, fmt.Errorf("Failed to append console %v", err)
|
||||||
}
|
}
|
||||||
@ -122,24 +123,24 @@ func (q *qemuS390x) appendConsole(devices []govmmQemu.Device, path string) ([]go
|
|||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendImage(ctx context.Context, devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||||
drive, err := genericImage(path)
|
drive, err := genericImage(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return q.appendCCWBlockDevice(devices, drive)
|
return q.appendCCWBlockDevice(ctx, devices, drive)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendBlockDevice(devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendBlockDevice(ctx context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) {
|
||||||
return q.appendCCWBlockDevice(devices, drive)
|
return q.appendCCWBlockDevice(ctx, devices, drive)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendCCWBlockDevice(devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendCCWBlockDevice(ctx context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) {
|
||||||
d, err := genericBlockDevice(drive, false)
|
d, err := genericBlockDevice(drive, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append blk-dev %v", err)
|
return devices, fmt.Errorf("Failed to append blk-dev %v", err)
|
||||||
}
|
}
|
||||||
addr, b, err := q.addDeviceToBridge(drive.ID, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, drive.ID, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append blk-dev %v", err)
|
return devices, fmt.Errorf("Failed to append blk-dev %v", err)
|
||||||
}
|
}
|
||||||
@ -163,13 +164,13 @@ func (q *qemuS390x) supportGuestMemoryHotplug() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendNetwork(devices []govmmQemu.Device, endpoint Endpoint) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendNetwork(ctx context.Context, devices []govmmQemu.Device, endpoint Endpoint) ([]govmmQemu.Device, error) {
|
||||||
d, err := genericNetwork(endpoint, false, false, q.networkIndex)
|
d, err := genericNetwork(endpoint, false, false, q.networkIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append network %v", err)
|
return devices, fmt.Errorf("Failed to append network %v", err)
|
||||||
}
|
}
|
||||||
q.networkIndex++
|
q.networkIndex++
|
||||||
addr, b, err := q.addDeviceToBridge(d.ID, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, d.ID, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append network %v", err)
|
return devices, fmt.Errorf("Failed to append network %v", err)
|
||||||
}
|
}
|
||||||
@ -182,8 +183,8 @@ func (q *qemuS390x) appendNetwork(devices []govmmQemu.Device, endpoint Endpoint)
|
|||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendRNGDevice(devices []govmmQemu.Device, rngDev config.RNGDev) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendRNGDevice(ctx context.Context, devices []govmmQemu.Device, rngDev config.RNGDev) ([]govmmQemu.Device, error) {
|
||||||
addr, b, err := q.addDeviceToBridge(rngDev.ID, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, rngDev.ID, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append RNG-Device %v", err)
|
return devices, fmt.Errorf("Failed to append RNG-Device %v", err)
|
||||||
}
|
}
|
||||||
@ -204,12 +205,12 @@ func (q *qemuS390x) appendRNGDevice(devices []govmmQemu.Device, rngDev config.RN
|
|||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) append9PVolume(devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) append9PVolume(ctx context.Context, devices []govmmQemu.Device, volume types.Volume) ([]govmmQemu.Device, error) {
|
||||||
if volume.MountTag == "" || volume.HostPath == "" {
|
if volume.MountTag == "" || volume.HostPath == "" {
|
||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
d := generic9PVolume(volume, false)
|
d := generic9PVolume(volume, false)
|
||||||
addr, b, err := q.addDeviceToBridge(d.ID, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, d.ID, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append 9p-Volume %v", err)
|
return devices, fmt.Errorf("Failed to append 9p-Volume %v", err)
|
||||||
}
|
}
|
||||||
@ -226,9 +227,9 @@ func (q *qemuS390x) appendBridges(devices []govmmQemu.Device) []govmmQemu.Device
|
|||||||
return genericAppendBridges(devices, q.Bridges, q.qemuMachine.Type)
|
return genericAppendBridges(devices, q.Bridges, q.qemuMachine.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendSCSIController(devices []govmmQemu.Device, enableIOThreads bool) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
func (q *qemuS390x) appendSCSIController(ctx context.Context, devices []govmmQemu.Device, enableIOThreads bool) ([]govmmQemu.Device, *govmmQemu.IOThread, error) {
|
||||||
d, t := genericSCSIController(enableIOThreads, q.nestedRun)
|
d, t := genericSCSIController(enableIOThreads, q.nestedRun)
|
||||||
addr, b, err := q.addDeviceToBridge(d.ID, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, d.ID, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, nil, fmt.Errorf("Failed to append scsi-controller %v", err)
|
return devices, nil, fmt.Errorf("Failed to append scsi-controller %v", err)
|
||||||
}
|
}
|
||||||
@ -241,10 +242,10 @@ func (q *qemuS390x) appendSCSIController(devices []govmmQemu.Device, enableIOThr
|
|||||||
return devices, t, nil
|
return devices, t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) appendVSock(devices []govmmQemu.Device, vsock types.VSock) ([]govmmQemu.Device, error) {
|
func (q *qemuS390x) appendVSock(ctx context.Context, devices []govmmQemu.Device, vsock types.VSock) ([]govmmQemu.Device, error) {
|
||||||
var devno string
|
var devno string
|
||||||
id := fmt.Sprintf("vsock-%d", vsock.ContextID)
|
id := fmt.Sprintf("vsock-%d", vsock.ContextID)
|
||||||
addr, b, err := q.addDeviceToBridge(id, types.CCW)
|
addr, b, err := q.addDeviceToBridge(ctx, id, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return devices, fmt.Errorf("Failed to append VSock: %v", err)
|
return devices, fmt.Errorf("Failed to append VSock: %v", err)
|
||||||
}
|
}
|
||||||
@ -270,8 +271,8 @@ func (q *qemuS390x) appendIOMMU(devices []govmmQemu.Device) ([]govmmQemu.Device,
|
|||||||
return devices, fmt.Errorf("S390x does not support appending a vIOMMU")
|
return devices, fmt.Errorf("S390x does not support appending a vIOMMU")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemuS390x) addDeviceToBridge(ID string, t types.Type) (string, types.Bridge, error) {
|
func (q *qemuS390x) addDeviceToBridge(ctx context.Context, ID string, t types.Type) (string, types.Bridge, error) {
|
||||||
addr, b, err := genericAddDeviceToBridge(q.Bridges, ID, types.CCW)
|
addr, b, err := genericAddDeviceToBridge(ctx, q.Bridges, ID, types.CCW)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", b, err
|
return "", b, err
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
govmmQemu "github.com/kata-containers/govmm/qemu"
|
govmmQemu "github.com/kata-containers/govmm/qemu"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user