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

Commit

Permalink
Configure CPUs #209
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitsoni committed Feb 7, 2015
1 parent 74d53ab commit 0428a02
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ DiskSize = 20000
# VM memory size in MB
Memory = 2048

# Number of CPUs
CPUs = 1

# host port forwarding to port 22 in the VM
SSHPort = 2022

Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func config() (*flag.FlagSet, error) {
flags.StringVar(&B2D.SSHKey, "sshkey", filepath.Join(sshdir, "id_boot2docker"), "path to SSH key to use.")
flags.UintVarP(&B2D.DiskSize, "disksize", "s", 20000, "boot2docker disk image size (in MB).")
flags.UintVarP(&B2D.Memory, "memory", "m", 2048, "virtual machine memory size (in MB).")
flags.UintVarP(&B2D.CPUs, "cpus", "c", 1, "number of cpus for boot2docker.")
flags.Uint16Var(&B2D.SSHPort, "sshport", 2022, "host SSH port (forward to port 22 in VM).")
flags.Uint16Var(&B2D.DockerPort, "dockerport", 0, "host Docker port (forward to port 2376 in VM). (deprecated - use with care)")
flags.IPVar(&B2D.HostIP, "hostip", net.ParseIP("192.168.59.3"), "VirtualBox host-only network IP address.")
Expand Down
1 change: 1 addition & 0 deletions driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type MachineConfig struct {
ISO string // boot2docker ISO image path
DiskSize uint // VM disk image size (MB)
Memory uint // VM memory size (MB)
CPUs uint // Number of CPUs

// NAT network: port forwarding
SSHPort uint16 // host SSH port (forward to port 22 in VM)
Expand Down
6 changes: 5 additions & 1 deletion virtualbox/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,11 @@ func CreateMachine(mc *driver.MachineConfig) (*Machine, error) {
// Configure VM for Boot2docker
SetExtra(mc.VM, "VBoxInternal/CPUM/EnableHVP", "1")
m.OSType = "Linux26_64"
m.CPUs = uint(runtime.NumCPU())
if mc.CPUs > 0 {
m.CPUs = mc.CPUs
} else {
m.CPUs = uint(runtime.NumCPU())
}
if m.CPUs > 32 {
m.CPUs = 32
}
Expand Down

0 comments on commit 0428a02

Please sign in to comment.