Skip to content

Commit

Permalink
Fixes bug where default socket path would be used
Browse files Browse the repository at this point in the history
Due to using an empty value, this would cause Firecracker to use their
default socket path which is /tmp/firecracker.socket. This change uses
the config that actually has the socket path value
  • Loading branch information
xibz committed Mar 7, 2019
1 parent 9e8f8b2 commit 8dbd885
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func NewMachine(ctx context.Context, cfg Config, opts ...Opt) (*Machine, error)
} else {
m.Handlers.Validation = m.Handlers.Validation.Append(ConfigValidationHandler)
m.cmd = defaultFirecrackerVMMCommandBuilder.
WithSocketPath(m.cfg.SocketPath).
WithSocketPath(cfg.SocketPath).
Build(ctx)
}

Expand Down
24 changes: 24 additions & 0 deletions machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,30 @@ func TestCaptureFifoToFile(t *testing.T) {
}
}

func TestSocketPathSet(t *testing.T) {
socketpath := "foo/bar"
m, err := NewMachine(context.Background(), Config{SocketPath: socketpath})
if err != nil {
t.Fatalf("Failed to create machine: %v", err)
}

found := false
for i := 0; i < len(m.cmd.Args); i++ {
if m.cmd.Args[i] != "--api-sock" {
continue
}

found = true
if m.cmd.Args[i+1] != socketpath {
t.Errorf("Incorrect socket path: %v", m.cmd.Args[i+1])
}
}

if !found {
t.Errorf("Failed to find socket path")
}
}

func copyFile(src, dst string, uid, gid int) error {
srcFd, err := os.Open(src)
if err != nil {
Expand Down

0 comments on commit 8dbd885

Please sign in to comment.