Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Expose firecracker sockets #132

Merged
merged 3 commits into from
Jul 12, 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
12 changes: 6 additions & 6 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ const (
// Additional timeout in seconds for docker to wait for ignite to save and quit
IGNITE_TIMEOUT = 10

// In-container path for the firecracker socket
SOCKET_PATH = "/tmp/firecracker.sock"
// In-container file name for the firecracker socket
FIRECRACKER_API_SOCKET = "firecracker.sock"

// In-container path for the firecracker log FIFO
LOG_FIFO = "/tmp/firecracker_log.fifo"
// In-container file name for the firecracker log FIFO
LOG_FIFO = "firecracker_log.fifo"

// In-container path for the firecracker metrics FIFO
METRICS_FIFO = "/tmp/firecracker_metrics.fifo"
// In-container file name for the firecracker metrics FIFO
METRICS_FIFO = "firecracker_metrics.fifo"

// Log level for the firecracker VM
VM_LOG_LEVEL = "Error"
Expand Down
15 changes: 9 additions & 6 deletions pkg/container/firecracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ func ExecuteFirecracker(md *vmmd.VM, dhcpIfaces []DHCPInterface) error {
cmdLine = constants.VM_DEFAULT_KERNEL_ARGS
}

firecrackerSocketPath := path.Join(md.ObjectPath(), FIRECRACKER_API_SOCKET)
logSocketPath := path.Join(md.ObjectPath(), LOG_FIFO)
metricsSocketPath := path.Join(md.ObjectPath(), METRICS_FIFO)
cfg := firecracker.Config{
SocketPath: constants.SOCKET_PATH,
SocketPath: firecrackerSocketPath,
KernelImagePath: path.Join(constants.KERNEL_DIR, md.GetKernelUID().String(), constants.KERNEL_FILE),
KernelArgs: cmdLine,
Drives: []models.Drive{{
Expand All @@ -62,20 +65,20 @@ func ExecuteFirecracker(md *vmmd.VM, dhcpIfaces []DHCPInterface) error {

// TODO: We could use /dev/null, but firecracker-go-sdk issues Mkfifo which collides with the existing device
LogLevel: constants.VM_LOG_LEVEL,
LogFifo: constants.LOG_FIFO,
MetricsFifo: constants.METRICS_FIFO,
LogFifo: logSocketPath,
MetricsFifo: metricsSocketPath,
}

// Remove these FIFOs for now
defer os.Remove(constants.LOG_FIFO)
defer os.Remove(constants.METRICS_FIFO)
defer os.Remove(logSocketPath)
defer os.Remove(metricsSocketPath)

ctx, vmmCancel := context.WithCancel(context.Background())
defer vmmCancel()

cmd := firecracker.VMCommandBuilder{}.
WithBin("firecracker").
WithSocketPath(constants.SOCKET_PATH).
WithSocketPath(firecrackerSocketPath).
WithStdin(os.Stdin).
WithStdout(os.Stdout).
WithStderr(os.Stderr).
Expand Down