Skip to content

Commit 25b61de

Browse files
committed
runtime: hard-code Firecracker API socket path
The Firecracker API socket is important for the runtime, as it uses the socket to communicate with Firecracker. Allowing the runtime to fully control the API socket (including its path) removes a potential failure condition from misconfiguration. The API socket is hard-coded to exist within the current working directory. Part of the contract that containerd exposes for runtimes is that they are started with the current working directory changed to be that of the OCI bundle. Using an API socket in the OCI bundle makes its location well-known and predictable to the runtime. Related: #59 Related: firecracker-microvm/firecracker-go-sdk#88 Signed-off-by: Samuel Karp <[email protected]>
1 parent 13f5383 commit 25b61de

File tree

6 files changed

+3
-14
lines changed

6 files changed

+3
-14
lines changed

docs/getting-started.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ 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-
* `socket_path` (required) - A path where a socket file should be created for
216-
communicating with the Firecracker API. A relative path like
217-
`./firecracker.sock` is recommended so that the socket is created in the
218-
temporary working directory allocated by containerd.
219215
* `kernel_image_path` (required) - A path where the kernel image file is
220216
located. A fully-qualified path is recommended.
221217
* `kernel_args` (required) - Arguments for the kernel command line.
@@ -241,7 +237,6 @@ configuration file has the following fields:
241237
```json
242238
{
243239
"firecracker_binary_path": "/usr/local/bin/firecracker",
244-
"socket_path": "./firecracker.sock",
245240
"kernel_image_path": "/var/lib/firecracker-containerd/runtime/hello-vmlinux.bin",
246241
"kernel_args": "console=ttyS0 noapic reboot=k panic=1 pci=off nomodules rw",
247242
"root_drive": "/var/lib/firecracker-containerd/runtime/hello-rootfs.ext4",

docs/quickstart.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ sudo mkdir -p /etc/containerd
138138
sudo tee -a /etc/containerd/firecracker-runtime.json <<EOF
139139
{
140140
"firecracker_binary_path": "/usr/local/bin/firecracker",
141-
"socket_path": "./firecracker.sock",
142141
"kernel_image_path": "/var/lib/firecracker-containerd/runtime/hello-vmlinux.bin",
143142
"kernel_args": "console=ttyS0 noapic reboot=k panic=1 pci=off nomodules rw",
144143
"root_drive": "/var/lib/firecracker-containerd/runtime/hello-rootfs.ext4",

runtime/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ 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-
* `socket_path` (required) - A path where a socket file should be created for
42-
communicating with the Firecracker API. A relative path like
43-
`./firecracker.sock` is recommended so that the socket is created in the
44-
temporary working directory allocated by containerd.
4541
* `kernel_image_path` (required) - A path where the kernel image file is
4642
located. A fully-qualified path is recommended.
4743
* `kernel_args` (required) - Arguments for the kernel command line.

runtime/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import (
2424
const (
2525
configPathEnvName = "FIRECRACKER_CONTAINERD_RUNTIME_CONFIG_PATH"
2626
defaultConfigPath = "/etc/containerd/firecracker-runtime.json"
27+
defaultSocketPath = "./firecracker.sock"
2728
)
2829

2930
// Config represents runtime configuration parameters
3031
type Config struct {
3132
FirecrackerBinaryPath string `json:"firecracker_binary_path"`
32-
SocketPath string `json:"socket_path"`
3333
KernelImagePath string `json:"kernel_image_path"`
3434
KernelArgs string `json:"kernel_args"`
3535
RootDrive string `json:"root_drive"`

runtime/config.json.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"firecracker_binary_path": "./firecracker",
3-
"socket_path": "./firecracker.sock",
43
"kernel_image_path": "vmlinux",
54
"kernel_args": "console=ttyS0 noapic reboot=k panic=1 pci=off nomodules rw",
65
"root_drive": "./vsock.img",

runtime/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ func (s *service) startVM(ctx context.Context,
637637
}
638638

639639
cfg := firecracker.Config{
640-
SocketPath: s.config.SocketPath,
640+
SocketPath: defaultSocketPath,
641641
VsockDevices: []firecracker.VsockDevice{{Path: "root", CID: cid}},
642642
KernelImagePath: s.config.KernelImagePath,
643643
KernelArgs: s.config.KernelArgs,
@@ -673,7 +673,7 @@ func (s *service) startVM(ctx context.Context,
673673
cfg.Drives = driveBuilder.Build()
674674
cmd := firecracker.VMCommandBuilder{}.
675675
WithBin(s.config.FirecrackerBinaryPath).
676-
WithSocketPath(s.config.SocketPath).
676+
WithSocketPath(defaultSocketPath).
677677
Build(ctx)
678678
machineOpts := []firecracker.Opt{
679679
firecracker.WithProcessRunner(cmd),

0 commit comments

Comments
 (0)