aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-14 16:38:48 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-15 16:02:37 +0200
commit25f4fe0662f7f3b390d16b2e786f2ba0aa0293f1 (patch)
tree63c8a232de10d34f154430ae54c6daf92b7541ab
parent4503776d2bc15a9e2738402760ff731252e4d2ec (diff)
vm/qemu: tune some qemu arguments based on target arch
-rw-r--r--docs/setup_linux-host_qemu-vm_arm64-kernel.md5
-rw-r--r--vm/qemu/qemu.go44
2 files changed, 33 insertions, 16 deletions
diff --git a/docs/setup_linux-host_qemu-vm_arm64-kernel.md b/docs/setup_linux-host_qemu-vm_arm64-kernel.md
index 61335d354..b9f60533d 100644
--- a/docs/setup_linux-host_qemu-vm_arm64-kernel.md
+++ b/docs/setup_linux-host_qemu-vm_arm64-kernel.md
@@ -21,8 +21,8 @@ Choose the following options.
Target packages
[*] Show packages that are also provided by busybox
Networking applications
- [*] dhcpcd
- [*] openssh
+ [*] dhcpcd
+ [*] openssh
Filesystem images
[*] ext2/3/4 root filesystem
ext2/3/4 variant - ext3
@@ -151,7 +151,6 @@ A sample config file that exercises the required options are shown below. Modify
"vm": {
"count": 1,
"qemu": "/path/to/qemu-system-aarch64",
- "qemu_args": "-machine virt -cpu cortex-a57",
"cmdline": "console=ttyAMA0 root=/dev/vda",
"kernel": “/path/to/Image",
"cpu": 2,
diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go
index dc6c0158e..b623fc8cc 100644
--- a/vm/qemu/qemu.go
+++ b/vm/qemu/qemu.go
@@ -31,7 +31,7 @@ func init() {
type Config struct {
Count int // number of VMs to use
- Qemu string // qemu binary name (qemu-system-x86_64 by default)
+ Qemu string // qemu binary name (qemu-system-arch by default)
Qemu_Args string // additional command line arguments for qemu binary
Kernel string // kernel for injected boot (e.g. arch/x86/boot/bzImage)
Cmdline string // kernel command line (can only be specified with kernel)
@@ -59,10 +59,37 @@ type instance struct {
merger *vmimpl.OutputMerger
}
+type archConfig struct {
+ Qemu string
+ QemuArgs string
+}
+
+var archConfigs = map[string]archConfig{
+ "amd64": {
+ Qemu: "qemu-system-x86_64",
+ QemuArgs: "-enable-kvm -usb -usbdevice mouse -usbdevice tablet -soundhw all",
+ },
+ "386": {
+ Qemu: "qemu-system-i386",
+ },
+ "arm64": {
+ Qemu: "qemu-system-aarch64",
+ QemuArgs: "-machine virt -cpu cortex-a57",
+ },
+ "arm": {
+ Qemu: "qemu-system-arm",
+ },
+ "ppc64le": {
+ Qemu: "qemu-system-ppc64",
+ },
+}
+
func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
+ archConfig := archConfigs[env.Arch]
cfg := &Config{
- Count: 1,
- Qemu: "qemu-system-x86_64",
+ Count: 1,
+ Qemu: archConfig.Qemu,
+ Qemu_Args: archConfig.QemuArgs,
}
if err := config.LoadData(env.Config, cfg); err != nil {
return nil, fmt.Errorf("failed to parse qemu vm config: %v", err)
@@ -200,16 +227,7 @@ func (inst *instance) Boot() error {
"-numa", "node,nodeid=0,cpus=0-1", "-numa", "node,nodeid=1,cpus=2-3",
"-smp", "sockets=2,cores=2,threads=1",
}
- if inst.cfg.Qemu_Args == "" {
- // This is reasonable defaults for x86 kvm-enabled host.
- args = append(args,
- "-enable-kvm",
- "-usb", "-usbdevice", "mouse", "-usbdevice", "tablet",
- "-soundhw", "all",
- )
- } else {
- args = append(args, strings.Split(inst.cfg.Qemu_Args, " ")...)
- }
+ args = append(args, strings.Split(inst.cfg.Qemu_Args, " ")...)
if inst.image == "9p" {
args = append(args,
"-fsdev", "local,id=fsdev0,path=/,security_model=none,readonly",