Skip to content

Commit

Permalink
Merge pull request #84 from xibz/socketpath_fix
Browse files Browse the repository at this point in the history
Fixes bug where default socket path would be used
  • Loading branch information
xibz authored Mar 7, 2019
2 parents 9e8f8b2 + 77e1b38 commit 57448b6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [ Unreleased ]

* Fixes bug where default socketpath would always be used when not using jailer (#84)

# 0.15.1

* Add the machine.Shutdown() method, enabling access to the SendCtrlAltDel API
Expand Down
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
25 changes: 25 additions & 0 deletions machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,31 @@ 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])
}
break
}

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 57448b6

Please sign in to comment.