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

Commit

Permalink
Merge pull request #132 from envato/expose-firecracker-sockets
Browse files Browse the repository at this point in the history
Expose firecracker sockets
  • Loading branch information
luxas committed Jul 12, 2019
2 parents b82ac1c + a1c3b0c commit ca7c3f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
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

0 comments on commit ca7c3f0

Please sign in to comment.