Skip to content

Commit 085f21d

Browse files
committed
Merge remote-tracking branch 'origin/pr/145'
2 parents 6fc1606 + 34cc925 commit 085f21d

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

docs/getting-started.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,16 @@ configuration file has the following fields:
212212
`firecracker` located in its working directory. A fully-qualified path to the
213213
`firecracker` binary is recommended, as the working directory typically
214214
changes every execution when run by containerd.
215-
* `kernel_image_path` (required) - A path where the kernel image file is
216-
located. A fully-qualified path is recommended.
215+
* `kernel_image_path` (optional) - A path where the kernel image file is
216+
located. A fully-qualified path is recommended. If left undefined, the
217+
runtime looks for a file named
218+
`/var/lib/firecracker-containerd/runtime/default-vmlinux.bin`.
217219
* `kernel_args` (optional) - Arguments for the kernel command line. If left
218220
undefined, the runtime specifies "console=ttyS0 noapic reboot=k panic=1
219221
pci=off nomodules rw".
220-
* `root_drive` (required) - A path where the root drive image file is located. A
221-
fully-qualified path is recommended.
222+
* `root_drive` (optional) - A path where the root drive image file is located. A
223+
fully-qualified path is recommended. If left undefined, the runtime looks for
224+
a file named `/var/lib/firecracker-containerd/runtime/default-rootfs.img`.
222225
* `cpu_count` (required) - The number of vCPUs to make available to a microVM.
223226
* `cpu_template` (required) - The Firecracker CPU emulation template. Supported
224227
values are "C3" and "T2".

docs/quickstart.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,12 @@ cd ~
133133

134134
# Configure the aws.firecracker runtime
135135
sudo mkdir -p /var/lib/firecracker-containerd/runtime
136-
sudo cp hello-rootfs.ext4 hello-vmlinux.bin /var/lib/firecracker-containerd/runtime
136+
sudo cp hello-rootfs.ext4 /var/lib/firecracker-containerd/runtime/default-rootfs.img
137+
sudo cp hello-vmlinux.bin /var/lib/firecracker-containerd/runtime/default-vmlinux.bin
137138
sudo mkdir -p /etc/containerd
138139
sudo tee -a /etc/containerd/firecracker-runtime.json <<EOF
139140
{
140141
"firecracker_binary_path": "/usr/local/bin/firecracker",
141-
"kernel_image_path": "/var/lib/firecracker-containerd/runtime/hello-vmlinux.bin",
142-
"root_drive": "/var/lib/firecracker-containerd/runtime/hello-rootfs.ext4",
143142
"cpu_count": 1,
144143
"cpu_template": "T2",
145144
"log_fifo": "/tmp/fc-logs.fifo",

runtime/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ configuration file has the following fields:
3838
`firecracker` located in its working directory. A fully-qualified path to the
3939
`firecracker` binary is recommended, as the working directory typically
4040
changes every execution when run by containerd.
41-
* `kernel_image_path` (required) - A path where the kernel image file is
42-
located. A fully-qualified path is recommended.
41+
* `kernel_image_path` (optional) - A path where the kernel image file is
42+
located. A fully-qualified path is recommended. If left undefined, the
43+
runtime looks for a file named
44+
`/var/lib/firecracker-containerd/runtime/default-vmlinux.bin`.
4345
* `kernel_args` (optional) - Arguments for the kernel command line. If left
4446
undefined, the runtime specifies "console=ttyS0 noapic reboot=k panic=1
4547
pci=off nomodules rw".
46-
* `root_drive` (required) - A path where the root drive image file is located. A
47-
fully-qualified path is recommended.
48+
* `root_drive` (optional) - A path where the root drive image file is located. A
49+
fully-qualified path is recommended. If left undefined, the runtime looks for
50+
a file named `/var/lib/firecracker-containerd/runtime/default-rootfs.img`.
4851
* `cpu_count` (required) - The number of vCPUs to make available to a microVM.
4952
* `cpu_template` (required) - The Firecracker CPU emulation template. Supported
5053
values are "C3" and "T2".

runtime/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const (
2626
defaultConfigPath = "/etc/containerd/firecracker-runtime.json"
2727
defaultSocketPath = "./firecracker.sock"
2828
defaultKernelArgs = "console=ttyS0 noapic reboot=k panic=1 pci=off nomodules rw"
29+
defaultFilesPath = "/var/lib/firecracker-containerd/runtime/"
30+
defaultKernelPath = defaultFilesPath + "default-vmlinux.bin"
31+
defaultRootfsPath = defaultFilesPath + "default-rootfs.img"
2932
)
3033

3134
// Config represents runtime configuration parameters
@@ -60,7 +63,9 @@ func LoadConfig(path string) (*Config, error) {
6063
}
6164

6265
cfg := &Config{
63-
KernelArgs: defaultKernelArgs,
66+
KernelArgs: defaultKernelArgs,
67+
KernelImagePath: defaultKernelPath,
68+
RootDrive: defaultRootfsPath,
6469
}
6570
if err := json.Unmarshal(data, cfg); err != nil {
6671
return nil, errors.Wrapf(err, "failed to unmarshal config from %q", path)

runtime/config_test.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,31 @@ func TestLoadConfigDefaults(t *testing.T) {
2727
configFile, cleanup := createTempConfig(t, configContent)
2828
defer cleanup()
2929
cfg, err := LoadConfig(configFile)
30-
if err != nil {
31-
t.Error(err, "failed to load config")
32-
}
30+
assert.NoError(t, err, "failed to load config")
3331

34-
assert.Equal(t, cfg.KernelArgs, defaultKernelArgs, "expected default kernel args")
32+
assert.Equal(t, defaultKernelArgs, cfg.KernelArgs, "expected default kernel args")
33+
assert.Equal(t, defaultKernelPath, cfg.KernelImagePath, "expected default kernel path")
34+
assert.Equal(t, defaultRootfsPath, cfg.RootDrive, "expected default rootfs path")
3535
}
3636

3737
func TestLoadConfigOverrides(t *testing.T) {
3838
overrideKernelArgs := "OVERRIDE KERNEL ARGS"
39-
configContent := fmt.Sprintf(`{"kernel_args":"%s"}`, overrideKernelArgs)
39+
overrideKernelPath := "OVERRIDE KERNEL PATH"
40+
overrideRootfsPath := "OVERRIDE ROOTFS PATH"
41+
configContent := fmt.Sprintf(
42+
`{
43+
"kernel_args":"%s",
44+
"kernel_image_path":"%s",
45+
"root_drive":"%s"
46+
}`, overrideKernelArgs, overrideKernelPath, overrideRootfsPath)
4047
configFile, cleanup := createTempConfig(t, configContent)
4148
defer cleanup()
4249
cfg, err := LoadConfig(configFile)
43-
if err != nil {
44-
t.Error(err, "failed to load config")
45-
}
50+
assert.NoError(t, err, "failed to load config")
4651

47-
assert.Equal(t, cfg.KernelArgs, overrideKernelArgs, "expected overridden kernel args")
52+
assert.Equal(t, overrideKernelArgs, cfg.KernelArgs, "expected overridden kernel args")
53+
assert.Equal(t, overrideKernelPath, cfg.KernelImagePath, "expected overridden kernel path")
54+
assert.Equal(t, overrideRootfsPath, cfg.RootDrive, "expected overridden rootfs path")
4855
}
4956

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

0 commit comments

Comments
 (0)