@@ -11,11 +11,12 @@ import (
1111)
1212
1313const (
14- QEMU_SYSTEM_EXE = "qemu-system-aarch64"
15- VM_MIN_MEMORY_SIZE = 128
14+ QEMU_SYSTEM_EXE = "qemu-system-aarch64"
15+ VM_MIN_MEMORY_SIZE = 128
16+ AARCH64_CONFIG_NR_CPUS = 8
1617)
1718
18- func (qc * QemuContext ) arguments (ctx * hypervisor.VmContext ) []string {
19+ func (qc * QemuContext ) arguments (ctx * hypervisor.VmContext , maxmem , maxcpus int ) []string {
1920 if ctx .Boot == nil {
2021 ctx .Boot = & hypervisor.BootConfig {
2122 CPU : 1 ,
@@ -27,13 +28,17 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
2728 boot := ctx .Boot
2829 qc .cpus = boot .CPU
2930
31+ if maxcpus > AARCH64_CONFIG_NR_CPUS {
32+ maxcpus = AARCH64_CONFIG_NR_CPUS
33+ }
34+
3035 // Currently the default memory size is fixed to 128 MiB.
3136 if boot .Memory < VM_MIN_MEMORY_SIZE {
3237 boot .Memory = VM_MIN_MEMORY_SIZE
3338 }
3439
35- memParams := fmt .Sprintf ("size=%d,slots=1,maxmem=%dM" , boot .Memory , hypervisor . DefaultMaxMem )
36- cpuParams := fmt .Sprintf ("cpus=%d,maxcpus=%d" , boot .CPU , hypervisor . DefaultMaxCpus )
40+ memParams := fmt .Sprintf ("size=%d,slots=1,maxmem=%dM" , boot .Memory , maxmem )
41+ cpuParams := fmt .Sprintf ("cpus=%d,maxcpus=%d" , boot .CPU , maxcpus )
3742
3843 params := []string {"-machine" , "virt,accel=kvm,gic-version=host,usb=off" , "-global" , "kvm-pit.lost_tick_policy=discard" , "-cpu" , "host" }
3944 if _ , err := os .Stat ("/dev/kvm" ); os .IsNotExist (err ) {
0 commit comments