mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
virtcontainers: x86: Support microvm machine type
[ port from runtime commit 6aff077901021d9a0075c446dfe281b2487e1487 ] With the addition of support to govmm for multiple transports (intel/govmm#111) and microvm (intel/govmm#121) we can now enable support for the 'microvm' machine type in kata-runtime. Signed-off-by: Liam Merwick <liam.merwick@oracle.com> Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
198339367b
commit
d3b3e8bee6
@ -14,6 +14,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
govmmQemu "github.com/intel/govmm/qemu"
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
||||
exp "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/experimental"
|
||||
@ -626,6 +627,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
|
||||
|
@ -32,9 +32,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{
|
||||
@ -71,6 +72,10 @@ var supportedQemuMachines = []govmmQemu.Machine{
|
||||
Type: QemuVirt,
|
||||
Options: defaultQemuMachineOptions,
|
||||
},
|
||||
{
|
||||
Type: QemuMicrovm,
|
||||
Options: defaultQemuMachineOptions,
|
||||
},
|
||||
}
|
||||
|
||||
// MaxQemuVCPUs returns the maximum number of vCPUs supported
|
||||
@ -115,14 +120,14 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
||||
|
||||
q := &qemuAmd64{
|
||||
qemuArchBase: qemuArchBase{
|
||||
qemuMachine: *mp,
|
||||
qemuExePath: qemuPaths[machineType],
|
||||
memoryOffset: config.MemOffset,
|
||||
kernelParamsNonDebug: kernelParamsNonDebug,
|
||||
kernelParamsDebug: kernelParamsDebug,
|
||||
kernelParams: kernelParams,
|
||||
disableNvdimm: config.DisableImageNvdimm,
|
||||
dax: true,
|
||||
qemuMachine: *mp,
|
||||
qemuExePath: qemuPaths[machineType],
|
||||
memoryOffset: config.MemOffset,
|
||||
kernelParamsNonDebug: kernelParamsNonDebug,
|
||||
kernelParamsDebug: kernelParamsDebug,
|
||||
kernelParams: kernelParams,
|
||||
disableNvdimm: config.DisableImageNvdimm,
|
||||
dax: true,
|
||||
},
|
||||
vmFactory: factory,
|
||||
}
|
||||
@ -171,6 +176,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.qemuMachine.Type != govmmQemu.MachineTypeMicrovm
|
||||
}
|
||||
|
||||
func (q *qemuAmd64) appendImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||
if !q.disableNvdimm {
|
||||
return q.appendNvdimmImage(devices, path)
|
||||
|
@ -47,6 +47,10 @@ func TestQemuAmd64Capabilities(t *testing.T) {
|
||||
amd64 = newTestQemu(assert, QemuQ35)
|
||||
caps = amd64.capabilities()
|
||||
assert.True(caps.IsBlockDeviceHotplugSupported())
|
||||
|
||||
amd64 = newTestQemu(assert, QemuMicrovm)
|
||||
caps = amd64.capabilities()
|
||||
assert.False(caps.IsBlockDeviceHotplugSupported())
|
||||
}
|
||||
|
||||
func TestQemuAmd64Bridges(t *testing.T) {
|
||||
@ -65,6 +69,11 @@ func TestQemuAmd64Bridges(t *testing.T) {
|
||||
assert.NotNil(b.Devices)
|
||||
}
|
||||
|
||||
amd64 = newTestQemu(assert, QemuMicrovm)
|
||||
amd64.bridges(uint32(len))
|
||||
bridges = amd64.getBridges()
|
||||
assert.Nil(bridges)
|
||||
|
||||
amd64 = newTestQemu(assert, QemuQ35)
|
||||
amd64.bridges(uint32(len))
|
||||
bridges = amd64.getBridges()
|
||||
@ -256,3 +265,18 @@ func TestQemuAmd64Iommu(t *testing.T) {
|
||||
m := qemu.machine()
|
||||
assert.Contains(m.Options, "kernel_irqchip=split")
|
||||
}
|
||||
|
||||
func TestQemuAmd64Microvm(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cfg := qemuConfig(QemuMicrovm)
|
||||
amd64, err := newQemuArch(cfg)
|
||||
assert.NoError(err)
|
||||
assert.False(cfg.DisableImageNvdimm)
|
||||
|
||||
for _, m := range supportedQemuMachines {
|
||||
assert.NotContains(m.Options, qemuNvdimmOption)
|
||||
}
|
||||
|
||||
assert.False(amd64.supportGuestMemoryHotplug())
|
||||
}
|
||||
|
@ -177,6 +177,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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user