@@ -4,6 +4,7 @@ package qemu
44import (
55 "context"
66 "fmt"
7+ "net"
78 "os"
89 "os/exec"
910 "path/filepath"
@@ -153,7 +154,7 @@ func qemuBinaryName() (string, error) {
153154
154155// isSocketInUse checks if a Unix socket is actively being used
155156func isSocketInUse (socketPath string ) bool {
156- conn , err := dialUnixTimeout ( socketPath , 100 * time .Millisecond )
157+ conn , err := net . DialTimeout ( "unix" , socketPath , 100 * time .Millisecond )
157158 if err != nil {
158159 return false
159160 }
@@ -165,26 +166,12 @@ func isSocketInUse(socketPath string) bool {
165166func waitForSocket (socketPath string , timeout time.Duration ) error {
166167 deadline := time .Now ().Add (timeout )
167168 for time .Now ().Before (deadline ) {
168- if _ , err := os .Stat (socketPath ); err == nil {
169- // Socket file exists, try to connect
170- conn , err := dialUnixTimeout (socketPath , 100 * time .Millisecond )
171- if err == nil {
172- conn .Close ()
173- return nil
174- }
169+ conn , err := net .DialTimeout ("unix" , socketPath , 100 * time .Millisecond )
170+ if err == nil {
171+ conn .Close ()
172+ return nil
175173 }
176174 time .Sleep (50 * time .Millisecond )
177175 }
178176 return fmt .Errorf ("timeout waiting for socket" )
179177}
180-
181- // dialUnixTimeout dials a Unix socket with a timeout
182- func dialUnixTimeout (path string , timeout time.Duration ) (* os.File , error ) {
183- // Use a simple stat check - actual connection will be done by go-qemu
184- if _ , err := os .Stat (path ); err != nil {
185- return nil , err
186- }
187- // For now, just return nil to indicate socket exists
188- // The actual QMP connection will be made by the QEMU client
189- return nil , nil
190- }
0 commit comments