From 90f69891d7a47ccfe3ed2ca7ff8b5617be06586f Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 12 Jan 2024 10:41:03 -0500 Subject: [PATCH 1/2] applehv: Remove unneeded cmd.ExtraFiles assignment `applehv.Start()` has this line of code: ``` cmd.ExtraFiles = []*os.File{ioEater, ioEater, ioEater} ``` whose purpose is not clear. The intent may have been to redirect stdin/stdout/stderr to /dev/null in the child process. This should be done by setting cmd.Stdin/cmd.Stdout/cmd/Stderr to nil, which is the case by default. The way it's done could also cause issues as `Vfkit.VirtualMachine.Cmd()` sometimes adds files it needs to keep open to `ExtraFiles`, so at the very least this should be an `append()` This commit removes this code. [NO NEW TESTS NEEDED] Signed-off-by: Christophe Fergeau --- pkg/machine/applehv/machine.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index fad985d959..afd86e0a32 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -572,12 +572,6 @@ func (m *MacMachine) Start(name string, opts machine.StartOptions) error { return machine.ErrVMAlreadyRunning } - ioEater, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0755) - if err != nil { - return err - } - defer ioEater.Close() - // TODO handle returns from startHostNetworking forwardSock, forwardState, err := m.startHostNetworking() if err != nil { @@ -641,8 +635,6 @@ func (m *MacMachine) Start(name string, opts machine.StartOptions) error { cmd.Args = append(cmd.Args, "--gui") // add command line switch to pop the gui open } - cmd.ExtraFiles = []*os.File{ioEater, ioEater, ioEater} - readSocketBaseDir := filepath.Dir(m.ReadySocket.GetPath()) if err := os.MkdirAll(readSocketBaseDir, 0755); err != nil { return err From 3fef531d96b100bfc96cd177753ebe904359c9fa Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 12 Jan 2024 10:57:38 -0500 Subject: [PATCH 2/2] applehv: return socket path from setupAPIForwarding When starting podman machine with applehv, this warning is printed: WARN[0025] API socket failed ping test This is due to a bug in applehv.setupAPIForwarding which is not returning the path to the socket, which causes `WaitAndPingAPI` to be called with `""` as the socket path, triggering the warning. This commit changes setupAPIForwarding to be similar to the implementation in the other machine implementations. I don't know how to add a test for this, but this can be handled in podman-machine end to end tests by making sure that there are no warnings when running `podman machine start` with applehv. [NO NEW TESTS NEEDED] Signed-off-by: Christophe Fergeau --- pkg/machine/applehv/machine.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index afd86e0a32..ca96d959b9 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -1031,7 +1031,8 @@ func (m *MacMachine) setupAPIForwarding(cmd gvproxy.GvproxyCommand) (gvproxy.Gvp } } - return cmd, "", machine.MachineLocal + return cmd, socket.GetPath(), machine.MachineLocal + } func (m *MacMachine) dockerSock() (string, error) {