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

Commit

Permalink
virtcontainers: x86: Support microvm machine type
Browse files Browse the repository at this point in the history
With the addition of support to govmm for multiple transports (kata-containers/govmm#111)
and microvm (kata-containers/govmm#121) we can now enable support for the 'microvm'
machine type in kata-runtime.

Fixes: #2360

Signed-off-by: Liam Merwick <[email protected]>
  • Loading branch information
merwick committed Apr 28, 2020
1 parent c98ef48 commit 6aff077
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"

"github.com/BurntSushi/toml"
govmmQemu "github.com/intel/govmm/qemu"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/device/config"
exp "github.com/kata-containers/runtime/virtcontainers/experimental"
Expand Down Expand Up @@ -595,6 +596,14 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
kernelParams := h.kernelParams()
machineType := h.machineType()

// The "microvm" machine type doesn't support NVDIMM so override the
// config setting to explicitly disable it (i.e. don't require the
// user to add 'disable_image_nvdimm = true' in the .toml file).
if machineType == govmmQemu.MachineTypeMicrovm && !h.DisableImageNvdimm {
h.DisableImageNvdimm = true
kataUtilsLogger.Info("Setting 'disable_image_nvdimm = true' as microvm does not support NVDIMM")
}

blockDriver, err := h.blockDeviceDriver()
if err != nil {
return vc.HypervisorConfig{}, err
Expand Down
17 changes: 14 additions & 3 deletions virtcontainers/qemu_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ const (
)

var qemuPaths = map[string]string{
QemuPCLite: "/usr/bin/qemu-lite-system-x86_64",
QemuPC: defaultQemuPath,
QemuQ35: defaultQemuPath,
QemuPCLite: "/usr/bin/qemu-lite-system-x86_64",
QemuPC: defaultQemuPath,
QemuQ35: defaultQemuPath,
QemuMicrovm: defaultQemuPath,
}

var kernelParams = []Param{
Expand Down Expand Up @@ -71,6 +72,10 @@ var supportedQemuMachines = []govmmQemu.Machine{
Type: QemuVirt,
Options: defaultQemuMachineOptions,
},
{
Type: QemuMicrovm,
Options: defaultQemuMachineOptions,
},
}

// MaxQemuVCPUs returns the maximum number of vCPUs supported
Expand Down Expand Up @@ -148,6 +153,12 @@ func (q *qemuAmd64) memoryTopology(memoryMb, hostMemoryMb uint64, slots uint8) g
return genericMemoryTopology(memoryMb, hostMemoryMb, slots, q.memoryOffset)
}

// Is Memory Hotplug supported by this architecture/machine type combination?
func (q *qemuAmd64) supportGuestMemoryHotplug() bool {
// true for all amd64 machine types except for microvm.
return q.machineType != govmmQemu.MachineTypeMicrovm
}

func (q *qemuAmd64) appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
if !q.disableNvdimm {
return q.appendNvdimmImage(devices, path)
Expand Down
23 changes: 23 additions & 0 deletions virtcontainers/qemu_amd64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func TestQemuAmd64Capabilities(t *testing.T) {
amd64 = newTestQemu(QemuQ35)
caps = amd64.capabilities()
assert.True(caps.IsBlockDeviceHotplugSupported())

amd64 = newTestQemu(QemuMicrovm)
caps = amd64.capabilities()
assert.False(caps.IsBlockDeviceHotplugSupported())
}

func TestQemuAmd64Bridges(t *testing.T) {
Expand Down Expand Up @@ -67,6 +71,11 @@ func TestQemuAmd64Bridges(t *testing.T) {
assert.NotNil(b.Devices)
}

amd64 = newTestQemu(QemuMicrovm)
amd64.bridges(uint32(len))
bridges = amd64.getBridges()
assert.Nil(bridges)

amd64 = newTestQemu(QemuQ35 + QemuPC)
amd64.bridges(uint32(len))
bridges = amd64.getBridges()
Expand Down Expand Up @@ -239,3 +248,17 @@ func TestQemuAmd64WithInitrd(t *testing.T) {
assert.NotContains(m.Options, qemuNvdimmOption)
}
}

func TestQemuAmd64Microvm(t *testing.T) {
assert := assert.New(t)

cfg := qemuConfig(QemuMicrovm)
amd64 := newQemuArch(cfg)
assert.False(cfg.DisableImageNvdimm)

for _, m := range amd64.(*qemuAmd64).supportedQemuMachines {
assert.NotContains(m.Options, qemuNvdimmOption)
}

assert.False(amd64.supportGuestMemoryHotplug())
}
3 changes: 3 additions & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ const (
// QemuQ35 is the QEMU Q35 machine type for amd64
QemuQ35 = "q35"

// QemuMicrovm is the QEMU microvm machine type for amd64
QemuMicrovm = "microvm"

// QemuVirt is the QEMU virt machine type for aarch64 or amd64
QemuVirt = "virt"

Expand Down

0 comments on commit 6aff077

Please sign in to comment.