@@ -5,12 +5,10 @@ import (
5
5
"fmt"
6
6
"os"
7
7
8
- "github.com/docker/go-units"
9
8
"github.com/hashicorp/go-multierror"
10
9
11
10
"github.com/lima-vm/lima/pkg/limayaml"
12
11
"github.com/lima-vm/lima/pkg/localpathutil"
13
- "github.com/lima-vm/lima/pkg/remotemount"
14
12
"github.com/lima-vm/sshocker/pkg/reversesshfs"
15
13
"github.com/sirupsen/logrus"
16
14
)
@@ -24,8 +22,8 @@ func (a *HostAgent) setupMounts(ctx context.Context) ([]*mount, error) {
24
22
res []* mount
25
23
mErr error
26
24
)
27
- for i , f := range a .y .Mounts {
28
- m , err := a .setupMount (ctx , i , f )
25
+ for _ , f := range a .y .Mounts {
26
+ m , err := a .setupMount (ctx , f )
29
27
if err != nil {
30
28
mErr = multierror .Append (mErr , err )
31
29
continue
@@ -35,17 +33,7 @@ func (a *HostAgent) setupMounts(ctx context.Context) ([]*mount, error) {
35
33
return res , mErr
36
34
}
37
35
38
- func (a * HostAgent ) setupMount (ctx context.Context , i int , m limayaml.Mount ) (* mount , error ) {
39
- switch * a .y .MountType {
40
- case limayaml .REVSSHFS :
41
- return a .setupMountReverseSSHFS (ctx , m )
42
- case limayaml .NINEP :
43
- return a .setupMount9P (ctx , i , m )
44
- }
45
- return nil , fmt .Errorf ("unknown mount type: %v" , * a .y .MountType )
46
- }
47
-
48
- func (a * HostAgent ) setupMountReverseSSHFS (ctx context.Context , m limayaml.Mount ) (* mount , error ) {
36
+ func (a * HostAgent ) setupMount (ctx context.Context , m limayaml.Mount ) (* mount , error ) {
49
37
expanded , err := localpathutil .Expand (m .Location )
50
38
if err != nil {
51
39
return nil , err
@@ -94,51 +82,3 @@ func (a *HostAgent) setupMountReverseSSHFS(ctx context.Context, m limayaml.Mount
94
82
}
95
83
return res , nil
96
84
}
97
-
98
- func (a * HostAgent ) setupMount9P (ctx context.Context , i int , m limayaml.Mount ) (* mount , error ) {
99
- expanded , err := localpathutil .Expand (m .Location )
100
- if err != nil {
101
- return nil , err
102
- }
103
- if err := os .MkdirAll (expanded , 0755 ); err != nil {
104
- return nil , err
105
- }
106
- mountOptions := "trans=virtio"
107
- mountOptions += fmt .Sprintf (",version=%s" , * m .NineP .ProtocolVersion )
108
- msize , err := units .RAMInBytes (* m .NineP .Msize )
109
- if err != nil {
110
- return nil , fmt .Errorf ("failed to parse msize for %q: %w" , expanded , err )
111
- }
112
- mountOptions += fmt .Sprintf (",msize=%d" , msize )
113
- mountOptions += fmt .Sprintf (",cache=%s" , * m .NineP .Cache )
114
-
115
- logrus .Infof ("Mounting %q" , expanded )
116
- rsf := & remotemount.RemoteMount {
117
- SSHConfig : a .sshConfig ,
118
- LocalPath : expanded ,
119
- Host : "127.0.0.1" ,
120
- Port : a .sshLocalPort ,
121
- RemotePath : expanded ,
122
- Readonly : ! (* m .Writable ),
123
- MountType : "9p" ,
124
- MountTag : fmt .Sprintf ("mount%d" , i ),
125
- MountAdditionalArgs : []string {"-o" , mountOptions },
126
- }
127
- if err := rsf .Prepare (); err != nil {
128
- return nil , fmt .Errorf ("failed to prepare 9p for %q: %w" , expanded , err )
129
- }
130
- if err := rsf .Start (); err != nil {
131
- return nil , fmt .Errorf ("failed to mount 9p for %q: %w" , expanded , err )
132
- }
133
-
134
- res := & mount {
135
- close : func () error {
136
- logrus .Infof ("Unmounting %q" , expanded )
137
- if closeErr := rsf .Close (); closeErr != nil {
138
- return fmt .Errorf ("failed to unmount 9p for %q: %w" , expanded , err )
139
- }
140
- return nil
141
- },
142
- }
143
- return res , nil
144
- }
0 commit comments