Skip to content

runtime: default CPU count is 1 #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ configuration file has the following fields:
* `root_drive` (optional) - A path where the root drive image file is located. A
fully-qualified path is recommended. If left undefined, the runtime looks for
a file named `/var/lib/firecracker-containerd/runtime/default-rootfs.img`.
* `cpu_count` (required) - The number of vCPUs to make available to a microVM.
* `cpu_count` (optional) - The number of vCPUs to make available to a microVM.
If left undefined, the default is 1.
* `cpu_template` (required) - The Firecracker CPU emulation template. Supported
values are "C3" and "T2".
* `additional_drives` (unused)
Expand Down
1 change: 0 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ sudo mkdir -p /etc/containerd
sudo tee -a /etc/containerd/firecracker-runtime.json <<EOF
{
"firecracker_binary_path": "/usr/local/bin/firecracker",
"cpu_count": 1,
"cpu_template": "T2",
"log_fifo": "/tmp/fc-logs.fifo",
"log_level": "Debug",
Expand Down
3 changes: 2 additions & 1 deletion runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ configuration file has the following fields:
* `root_drive` (optional) - A path where the root drive image file is located. A
fully-qualified path is recommended. If left undefined, the runtime looks for
a file named `/var/lib/firecracker-containerd/runtime/default-rootfs.img`.
* `cpu_count` (required) - The number of vCPUs to make available to a microVM.
* `cpu_count` (optional) - The number of vCPUs to make available to a microVM.
If left undefined, the default is 1.
* `cpu_template` (required) - The Firecracker CPU emulation template. Supported
values are "C3" and "T2".
* `additional_drives` (unused)
Expand Down
2 changes: 2 additions & 0 deletions runtime/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
defaultFilesPath = "/var/lib/firecracker-containerd/runtime/"
defaultKernelPath = defaultFilesPath + "default-vmlinux.bin"
defaultRootfsPath = defaultFilesPath + "default-rootfs.img"
defaultCPUCount = 1
)

// Config represents runtime configuration parameters
Expand Down Expand Up @@ -66,6 +67,7 @@ func LoadConfig(path string) (*Config, error) {
KernelArgs: defaultKernelArgs,
KernelImagePath: defaultKernelPath,
RootDrive: defaultRootfsPath,
CPUCount: defaultCPUCount,
}
if err := json.Unmarshal(data, cfg); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal config from %q", path)
Expand Down
8 changes: 6 additions & 2 deletions runtime/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ func TestLoadConfigDefaults(t *testing.T) {
assert.Equal(t, defaultKernelArgs, cfg.KernelArgs, "expected default kernel args")
assert.Equal(t, defaultKernelPath, cfg.KernelImagePath, "expected default kernel path")
assert.Equal(t, defaultRootfsPath, cfg.RootDrive, "expected default rootfs path")
assert.Equal(t, defaultCPUCount, cfg.CPUCount, "expected default CPU count")
}

func TestLoadConfigOverrides(t *testing.T) {
overrideKernelArgs := "OVERRIDE KERNEL ARGS"
overrideKernelPath := "OVERRIDE KERNEL PATH"
overrideRootfsPath := "OVERRIDE ROOTFS PATH"
overrideCPUCount := 42
configContent := fmt.Sprintf(
`{
"kernel_args":"%s",
"kernel_image_path":"%s",
"root_drive":"%s"
}`, overrideKernelArgs, overrideKernelPath, overrideRootfsPath)
"root_drive":"%s",
"cpu_count": %d
}`, overrideKernelArgs, overrideKernelPath, overrideRootfsPath, overrideCPUCount)
configFile, cleanup := createTempConfig(t, configContent)
defer cleanup()
cfg, err := LoadConfig(configFile)
Expand All @@ -52,6 +55,7 @@ func TestLoadConfigOverrides(t *testing.T) {
assert.Equal(t, overrideKernelArgs, cfg.KernelArgs, "expected overridden kernel args")
assert.Equal(t, overrideKernelPath, cfg.KernelImagePath, "expected overridden kernel path")
assert.Equal(t, overrideRootfsPath, cfg.RootDrive, "expected overridden rootfs path")
assert.Equal(t, overrideCPUCount, cfg.CPUCount, "expected overridden cpu count")
}

func createTempConfig(t *testing.T, contents string) (string, func()) {
Expand Down