Skip to content

Commit 57448b6

Browse files
authored
Merge pull request #84 from xibz/socketpath_fix
Fixes bug where default socket path would be used
2 parents 9e8f8b2 + 77e1b38 commit 57448b6

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,31 @@ 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+
break
777+
}
778+
779+
if !found {
780+
t.Errorf("Failed to find socket path")
781+
}
782+
}
783+
759784
func copyFile(src, dst string, uid, gid int) error {
760785
srcFd, err := os.Open(src)
761786
if err != nil {

0 commit comments

Comments
 (0)