diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2af6f2..abbf791f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/machine.go b/machine.go index e039081f..d9c15c60 100644 --- a/machine.go +++ b/machine.go @@ -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) } diff --git a/machine_test.go b/machine_test.go index ad7a9976..f52c0d51 100644 --- a/machine_test.go +++ b/machine_test.go @@ -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 {