Files
kata-containers/virtcontainers/qemu_ppc64le_test.go
Jose Carlos Venegas Munoz 19801bf784 config: Add Memory slots configuration.
Add configuration to decide the amount of slots that will be used in a VM

- This will limit the amount of times that memory can be hotplugged.
- Use memory slots provided by user.
- tests: aling struct

cli: kata-env: Add memory slots info.

- Show the slots to be added to the VM.

```diff
[Hypervisor]
  MachineType = "pc"
  Version = "QEMU ..."
  Path = "/opt/kata/bin/qemu-system-x86_64"
  BlockDeviceDriver = "virtio-scsi"
  Msize9p = 8192
+  MemorySlots = 10
  Debug = false
  UseVSock = false
```

Fixes: #751

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2018-09-21 10:57:00 -05:00

54 lines
1.1 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/stretchr/testify/assert"
)
func newTestQemu(machineType string) qemuArch {
config := HypervisorConfig{
HypervisorMachineType: machineType,
}
return newQemuArch(config)
}
func TestQemuPPC64leCPUModel(t *testing.T) {
assert := assert.New(t)
ppc64le := newTestQemu(QemuPseries)
expectedOut := defaultCPUModel
model := ppc64le.cpuModel()
assert.Equal(expectedOut, model)
ppc64le.enableNestingChecks()
expectedOut = defaultCPUModel + ",pmu=off"
model = ppc64le.cpuModel()
assert.Equal(expectedOut, model)
}
func TestQemuPPC64leMemoryTopology(t *testing.T) {
assert := assert.New(t)
ppc64le := newTestQemu(QemuPseries)
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 := ppc64le.memoryTopology(mem, hostMem, slots)
assert.Equal(expectedMemory, m)
}