From 3a9c88c0c51fd11b0d41af07e1306ff4e791464c Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Fri, 7 Jul 2017 21:31:26 +0800 Subject: [PATCH] ARM64: Remove the hardcode of virtual machine type Current implementation hardcodes the virtual machine as "q35" for x86, this patch remove this hardcode and config the machine type according to the arch the VM is running. Also, in order to make sure the qemu can run on arm64 platform, we need to specify the vcpu type in the command line. Signed-off-by: Dennis Chen --- src/cmd/linuxkit/run_qemu.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/cmd/linuxkit/run_qemu.go b/src/cmd/linuxkit/run_qemu.go index a47f20e42..354e1bdae 100644 --- a/src/cmd/linuxkit/run_qemu.go +++ b/src/cmd/linuxkit/run_qemu.go @@ -349,12 +349,27 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) { qemuArgs = append(qemuArgs, "-device", "virtio-rng-pci") qemuArgs = append(qemuArgs, "-smp", config.CPUs) qemuArgs = append(qemuArgs, "-m", config.Memory) + // Need to specify the vcpu type when running qemu on arm64 platform, for security reason, + // the vcpu should be "host" instead of other names such as "cortex-a53"... + if config.Arch == "aarch64" { + qemuArgs = append(qemuArgs, "-cpu", "host") + } if config.KVM { qemuArgs = append(qemuArgs, "-enable-kvm") - qemuArgs = append(qemuArgs, "-machine", "q35,accel=kvm:tcg") + // Remove the hardcode of virtual machine type for x86, since we will + // support aarch64 in future + if config.Arch == "aarch64" { + qemuArgs = append(qemuArgs, "-machine", "virt") + } else { + qemuArgs = append(qemuArgs, "-machine", "q35,accel=kvm:tcg") + } } else { - qemuArgs = append(qemuArgs, "-machine", "q35") + if config.Arch == "aarch64" { + qemuArgs = append(qemuArgs, "-machine", "virt") + } else { + qemuArgs = append(qemuArgs, "-machine", "q35") + } } for i, d := range config.Disks {