Skip to content

Commit c81fac6

Browse files
committed
Fixes bug where default socket path would be used
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
1 parent 9e8f8b2 commit c81fac6

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [ Unreleased ]
2+
3+
* Fixes bug where default socketpath would always be used when not using jailer (#84)
4+
15
# 0.15.1
26

37
* Add the machine.Shutdown() method, enabling access to the SendCtrlAltDel API

machine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func NewMachine(ctx context.Context, cfg Config, opts ...Opt) (*Machine, error)
216216
} else {
217217
m.Handlers.Validation = m.Handlers.Validation.Append(ConfigValidationHandler)
218218
m.cmd = defaultFirecrackerVMMCommandBuilder.
219-
WithSocketPath(m.cfg.SocketPath).
219+
WithSocketPath(cfg.SocketPath).
220220
Build(ctx)
221221
}
222222

machine_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,30 @@ func TestCaptureFifoToFile(t *testing.T) {
756756
}
757757
}
758758

759+
func TestSocketPathSet(t *testing.T) {
760+
socketpath := "foo/bar"
761+
m, err := NewMachine(context.Background(), Config{SocketPath: socketpath})
762+
if err != nil {
763+
t.Fatalf("Failed to create machine: %v", err)
764+
}
765+
766+
found := false
767+
for i := 0; i < len(m.cmd.Args); i++ {
768+
if m.cmd.Args[i] != "--api-sock" {
769+
continue
770+
}
771+
772+
found = true
773+
if m.cmd.Args[i+1] != socketpath {
774+
t.Errorf("Incorrect socket path: %v", m.cmd.Args[i+1])
775+
}
776+
}
777+
778+
if !found {
779+
t.Errorf("Failed to find socket path")
780+
}
781+
}
782+
759783
func copyFile(src, dst string, uid, gid int) error {
760784
srcFd, err := os.Open(src)
761785
if err != nil {

0 commit comments

Comments
 (0)