Files
kata-containers/virtcontainers/qemu_s390x_test.go
Alice Frosi 6f83061139 s390x: add support for s390x
The PR adds the support for s390x.

In the case of CCW devices, the vhost-user devices are not supported.
See #659. An error message is thrown if they tried to be used.

Memory hotplug is not supported on s390 yet and an error message is thrown.

The VirtioNetPCI has been changed to VirtioNet. The generalization
allows to set the VirtioNet to the correct CCW device for s390x.

Fixes: #666

Co-authored-by: Yash D Jain ydjainopensource@gmail.com
Signed-off-by: Alice Frosi <afrosi@de.ibm.com>
2018-12-11 12:32:17 +01:00

69 lines
1.5 KiB
Go

// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//
package virtcontainers
import (
"fmt"
"testing"
govmmQemu "github.com/intel/govmm/qemu"
"github.com/kata-containers/runtime/virtcontainers/device/config"
"github.com/stretchr/testify/assert"
)
func newTestQemu(machineType string) qemuArch {
config := HypervisorConfig{
HypervisorMachineType: machineType,
}
return newQemuArch(config)
}
func TestQemuS390xCPUModel(t *testing.T) {
assert := assert.New(t)
s390x := newTestQemu(QemuCCWVirtio)
expectedOut := defaultCPUModel
model := s390x.cpuModel()
assert.Equal(expectedOut, model)
s390x.enableNestingChecks()
expectedOut = defaultCPUModel + ",pmu=off"
model = s390x.cpuModel()
assert.Equal(expectedOut, model)
}
func TestQemuS390xMemoryTopology(t *testing.T) {
assert := assert.New(t)
s390x := newTestQemu(QemuCCWVirtio)
memoryOffset := 1024
hostMem := uint64(1024)
mem := uint64(120)
slots := uint8(10)
expectedMemory := govmmQemu.Memory{
Size: fmt.Sprintf("%dM", mem),
Slots: slots,
MaxMem: fmt.Sprintf("%dM", hostMem+uint64(memoryOffset)),
}
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)
}