Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 0428a02

Browse files
committed
Configure CPUs #209
1 parent 74d53ab commit 0428a02

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ DiskSize = 20000
166166
# VM memory size in MB
167167
Memory = 2048
168168

169+
# Number of CPUs
170+
CPUs = 1
171+
169172
# host port forwarding to port 22 in the VM
170173
SSHPort = 2022
171174

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func config() (*flag.FlagSet, error) {
116116
flags.StringVar(&B2D.SSHKey, "sshkey", filepath.Join(sshdir, "id_boot2docker"), "path to SSH key to use.")
117117
flags.UintVarP(&B2D.DiskSize, "disksize", "s", 20000, "boot2docker disk image size (in MB).")
118118
flags.UintVarP(&B2D.Memory, "memory", "m", 2048, "virtual machine memory size (in MB).")
119+
flags.UintVarP(&B2D.CPUs, "cpus", "c", 1, "number of cpus for boot2docker.")
119120
flags.Uint16Var(&B2D.SSHPort, "sshport", 2022, "host SSH port (forward to port 22 in VM).")
120121
flags.Uint16Var(&B2D.DockerPort, "dockerport", 0, "host Docker port (forward to port 2376 in VM). (deprecated - use with care)")
121122
flags.IPVar(&B2D.HostIP, "hostip", net.ParseIP("192.168.59.3"), "VirtualBox host-only network IP address.")

driver/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type MachineConfig struct {
2626
ISO string // boot2docker ISO image path
2727
DiskSize uint // VM disk image size (MB)
2828
Memory uint // VM memory size (MB)
29+
CPUs uint // Number of CPUs
2930

3031
// NAT network: port forwarding
3132
SSHPort uint16 // host SSH port (forward to port 22 in VM)

virtualbox/machine.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ func CreateMachine(mc *driver.MachineConfig) (*Machine, error) {
466466
// Configure VM for Boot2docker
467467
SetExtra(mc.VM, "VBoxInternal/CPUM/EnableHVP", "1")
468468
m.OSType = "Linux26_64"
469-
m.CPUs = uint(runtime.NumCPU())
469+
if mc.CPUs > 0 {
470+
m.CPUs = mc.CPUs
471+
} else {
472+
m.CPUs = uint(runtime.NumCPU())
473+
}
470474
if m.CPUs > 32 {
471475
m.CPUs = 32
472476
}

0 commit comments

Comments
 (0)