Skip to content

Commit fdd4e41

Browse files
committed
driver(external): clean code and fix driver discovery in libexec
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
1 parent b8d96e6 commit fdd4e41

File tree

6 files changed

+4
-201
lines changed

6 files changed

+4
-201
lines changed

pkg/driver/external/client/client.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type DriverClient struct {
2121
}
2222

2323
func NewDriverClient(socketPath string, logger *logrus.Logger) (*DriverClient, error) {
24-
// pipeConn := newPipeConn(stdin, stdout)
2524
opts := []grpc.DialOption{
2625
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(16 << 20)),
2726
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(16 << 20)),
@@ -31,14 +30,6 @@ func NewDriverClient(socketPath string, logger *logrus.Logger) (*DriverClient, e
3130
grpc.WithTransportCredentials(insecure.NewCredentials()),
3231
}
3332

34-
// conn, err := grpc.NewClient("pipe", opts...)
35-
// if err != nil {
36-
// logger.Errorf("failed to create gRPC driver client connection: %v", err)
37-
// return nil, err
38-
// }
39-
// -> ERRO[2025-06-04T21:32:54+05:30] Failed to set config: rpc error: code =
40-
// Unavailable desc = name resolver error: produced zero addresses
41-
4233
conn, err := grpc.Dial("unix://"+socketPath, opts...)
4334
if err != nil {
4435
logger.Errorf("failed to dial gRPC driver client connection: %v", err)

pkg/driver/external/client/pipe.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

pkg/driver/external/server/pipe.go

Lines changed: 0 additions & 99 deletions
This file was deleted.

pkg/driver/external/server/server.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package server
55

66
import (
7-
"context"
87
"fmt"
98
"net"
109
"os"
@@ -17,7 +16,6 @@ import (
1716
"google.golang.org/grpc"
1817
"google.golang.org/grpc/keepalive"
1918

20-
"github.com/lima-vm/lima/pkg/bicopy"
2119
"github.com/lima-vm/lima/pkg/driver"
2220
pb "github.com/lima-vm/lima/pkg/driver/external"
2321
)
@@ -31,13 +29,6 @@ type DriverServer struct {
3129
func Serve(driver driver.Driver) {
3230
logger := logrus.New()
3331
logger.SetLevel(logrus.DebugLevel)
34-
// pipeConn := &PipeConn{
35-
// Reader: os.Stdin,
36-
// Writer: os.Stdout,
37-
// Closer: os.Stdout,
38-
// }
39-
40-
// listener := NewPipeListener(pipeConn)
4132

4233
socketPath := filepath.Join(os.TempDir(), fmt.Sprintf("lima-driver-%s-%d.sock", driver.GetInfo().DriverName, os.Getpid()))
4334

@@ -95,20 +86,3 @@ func Serve(driver driver.Driver) {
9586
logger.Fatalf("Failed to serve: %v", err)
9687
}
9788
}
98-
99-
func HandleProxyConnection(ctx context.Context, conn net.Conn, unixSocketPath string) {
100-
logrus.Infof("Handling proxy connection from %s", conn.LocalAddr())
101-
102-
var d net.Dialer
103-
unixConn, err := d.DialContext(ctx, "unix", unixSocketPath)
104-
if err != nil {
105-
logrus.Errorf("Failed to connect to unix socket %s: %v", unixSocketPath, err)
106-
return
107-
}
108-
109-
logrus.Infof("Successfully established proxy tunnel: %s <--> %s", conn.LocalAddr(), unixSocketPath)
110-
111-
go bicopy.Bicopy(unixConn, conn, nil)
112-
113-
logrus.Infof("Proxy session ended for %s", conn.LocalAddr())
114-
}

pkg/registry/registry.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/lima-vm/lima/pkg/driver/external/client"
1919
"github.com/lima-vm/lima/pkg/store"
2020
"github.com/lima-vm/lima/pkg/store/filenames"
21-
"github.com/lima-vm/lima/pkg/usrlocalsharelima"
2221
"github.com/sirupsen/logrus"
2322
)
2423

@@ -216,12 +215,13 @@ func (r *Registry) RegisterDriver(name, path string) {
216215
}
217216

218217
func (r *Registry) DiscoverDrivers() error {
219-
limaShareDir, err := usrlocalsharelima.Dir()
218+
homeDir, err := os.UserHomeDir()
220219
if err != nil {
221-
return fmt.Errorf("failed to determine Lima share directory: %w", err)
220+
return err
222221
}
223-
stdDriverDir := filepath.Join(filepath.Dir(limaShareDir), "libexec", "lima", "drivers")
222+
stdDriverDir := filepath.Join(homeDir, ".local", "libexec", "lima", "drivers")
224223

224+
logrus.Infof("Discovering drivers in %s", stdDriverDir)
225225
if _, err := os.Stat(stdDriverDir); err == nil {
226226
if err := r.discoverDriversInDir(stdDriverDir); err != nil {
227227
logrus.Warnf("Error discovering drivers in %s: %v", stdDriverDir, err)

pkg/store/filenames/filenames.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const (
6060
HostAgentStdoutLog = "ha.stdout.log"
6161
HostAgentStderrLog = "ha.stderr.log"
6262
ExternalDriverStderrLog = "driver.stderr.log"
63-
ExternalDriverSock = "driver.sock"
6463
VzIdentifier = "vz-identifier"
6564
VzEfi = "vz-efi" // efi variable store
6665
QemuEfiCodeFD = "qemu-efi-code.fd" // efi code; not always created

0 commit comments

Comments
 (0)