From 787c86b7e53b448684da5f0aaf3549750295900a Mon Sep 17 00:00:00 2001 From: Liam Merwick Date: Wed, 22 Apr 2020 14:28:37 +0000 Subject: [PATCH] qemu: Add microvm machine type support Following on from #111 which added support for multiple virtio transports, add code to use virtio-mmio as the transport when booting a guest with the microvm machine type and add a microvm case when checking for NUMA support. Also add a test case for machine string parsing. Signed-off-by: Liam Merwick --- qemu/qemu.go | 12 ++++++++++++ qemu/qemu_test.go | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/qemu/qemu.go b/qemu/qemu.go index a5e5dfaf96..ed211d3ccb 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -51,6 +51,11 @@ type Machine struct { Options string } +const ( + // MachineTypeMicrovm is the QEMU microvm machine type for amd64 + MachineTypeMicrovm string = "microvm" +) + // Device is the qemu device interface. type Device interface { Valid() bool @@ -128,6 +133,10 @@ const ( func isDimmSupported(config *Config) bool { switch runtime.GOARCH { case "amd64", "386": + if config != nil && config.Machine.Type == MachineTypeMicrovm { + // microvm does not support NUMA + return false + } return true default: return false @@ -153,6 +162,9 @@ const ( func (transport VirtioTransport) defaultTransport(config *Config) VirtioTransport { switch runtime.GOARCH { case "amd64", "386": + if config != nil && config.Machine.Type == MachineTypeMicrovm { + return TransportMMIO + } return TransportPCI case "s390x": return TransportCCW diff --git a/qemu/qemu_test.go b/qemu/qemu_test.go index 02f9bd88c2..f1de632c81 100644 --- a/qemu/qemu_test.go +++ b/qemu/qemu_test.go @@ -108,6 +108,14 @@ func TestAppendMachine(t *testing.T) { Options: "gic-version=host,usb=off", } testAppend(machine, machineString, t) + + machineString = "-machine microvm,accel=kvm,pic=off,pit=off" + machine = Machine{ + Type: "microvm", + Acceleration: "kvm", + Options: "pic=off,pit=off", + } + testAppend(machine, machineString, t) } func TestAppendEmptyMachine(t *testing.T) {