diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index d127c12736..5e2bb85932 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -1924,7 +1924,7 @@ func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType devic vhostDev.SocketPath = sockPath vhostDev.DevID = id - q.qemuConfig.Devices = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, vhostDev) + q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, vhostDev) } else { q.Logger().WithField("volume-type", "virtio-9p").Info("adding volume") q.qemuConfig.Devices, err = q.arch.append9PVolume(ctx, q.qemuConfig.Devices, v) @@ -1939,7 +1939,7 @@ func (q *qemu) addDevice(ctx context.Context, devInfo interface{}, devType devic case config.BlockDrive: q.qemuConfig.Devices, err = q.arch.appendBlockDevice(ctx, q.qemuConfig.Devices, v) case config.VhostUserDeviceAttrs: - q.qemuConfig.Devices = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, v) + q.qemuConfig.Devices, err = q.arch.appendVhostUserDevice(q.qemuConfig.Devices, v) case config.VFIODev: q.qemuConfig.Devices = q.arch.appendVFIODevice(q.qemuConfig.Devices, v) default: diff --git a/src/runtime/virtcontainers/qemu_arch_base.go b/src/runtime/virtcontainers/qemu_arch_base.go index aa8e4d59fd..ae0ce3a13e 100644 --- a/src/runtime/virtcontainers/qemu_arch_base.go +++ b/src/runtime/virtcontainers/qemu_arch_base.go @@ -96,7 +96,7 @@ type qemuArch interface { appendBlockDevice(ctx context.Context, devices []govmmQemu.Device, drive config.BlockDrive) ([]govmmQemu.Device, error) // appendVhostUserDevice appends a vhost user device to devices - appendVhostUserDevice(devices []govmmQemu.Device, drive config.VhostUserDeviceAttrs) []govmmQemu.Device + appendVhostUserDevice(devices []govmmQemu.Device, drive config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error) // appendVFIODevice appends a VFIO device to devices appendVFIODevice(devices []govmmQemu.Device, vfioDevice config.VFIODev) []govmmQemu.Device @@ -633,7 +633,7 @@ func (q *qemuArchBase) appendBlockDevice(_ context.Context, devices []govmmQemu. return devices, nil } -func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr config.VhostUserDeviceAttrs) []govmmQemu.Device { +func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error) { qemuVhostUserDevice := govmmQemu.VhostUserDevice{} switch attr.Type { @@ -658,7 +658,7 @@ func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr co devices = append(devices, qemuVhostUserDevice) - return devices + return devices, nil } func (q *qemuArchBase) appendVFIODevice(devices []govmmQemu.Device, vfioDev config.VFIODev) []govmmQemu.Device { diff --git a/src/runtime/virtcontainers/qemu_arch_base_test.go b/src/runtime/virtcontainers/qemu_arch_base_test.go index f134a15ae3..d4aba54fac 100644 --- a/src/runtime/virtcontainers/qemu_arch_base_test.go +++ b/src/runtime/virtcontainers/qemu_arch_base_test.go @@ -224,7 +224,7 @@ func testQemuArchBaseAppend(t *testing.T, structure interface{}, expected []govm case config.VFIODev: devices = qemuArchBase.appendVFIODevice(devices, s) case config.VhostUserDeviceAttrs: - devices = qemuArchBase.appendVhostUserDevice(devices, s) + devices, err = qemuArchBase.appendVhostUserDevice(devices, s) } assert.NoError(err) diff --git a/src/runtime/virtcontainers/qemu_s390x.go b/src/runtime/virtcontainers/qemu_s390x.go index 6a4c78264f..01968b6b1f 100644 --- a/src/runtime/virtcontainers/qemu_s390x.go +++ b/src/runtime/virtcontainers/qemu_s390x.go @@ -152,6 +152,12 @@ func (q *qemuS390x) appendCCWBlockDevice(ctx context.Context, devices []govmmQem return devices, nil } +// appendVhostUserDevice throws an error if vhost devices are tried to be used. +// See issue https://github.com/kata-containers/runtime/issues/659 +func (q *qemuS390x) appendVhostUserDevice(devices []govmmQemu.Device, attr config.VhostUserDeviceAttrs) ([]govmmQemu.Device, error) { + return nil, fmt.Errorf("No vhost-user devices supported on s390x") +} + // supportGuestMemoryHotplug return false for s390x architecture. The pc-dimm backend device for s390x // is not support. PC-DIMM is not listed in the devices supported by qemu-system-s390x -device help func (q *qemuS390x) supportGuestMemoryHotplug() bool { diff --git a/src/runtime/virtcontainers/qemu_s390x_test.go b/src/runtime/virtcontainers/qemu_s390x_test.go index 3355680bb1..70ddf3ff21 100644 --- a/src/runtime/virtcontainers/qemu_s390x_test.go +++ b/src/runtime/virtcontainers/qemu_s390x_test.go @@ -52,3 +52,17 @@ func TestQemuS390xMemoryTopology(t *testing.T) { m := s390x.memoryTopology(mem, hostMem, slots) assert.Equal(expectedMemory, m) } + +func TestQemuS390xAppendVhostUserDevice(t *testing.T) { + macAddress := "00:11:22:33:44:55:66" + qemu := qemuS390x{} + assert := assert.New(t) + + vhostUserDevice := config.VhostUserDeviceAttrs{ + Type: config.VhostUserNet, + MacAddress: macAddress, + } + + _, err := qemu.appendVhostUserDevice(nil, vhostUserDevice) + assert.Error(err) +}