Skip to content

Commit 8739710

Browse files
committed
Support for inotify in mounted directories
Signed-off-by: Balaji Vijayakumar <[email protected]>
1 parent 4d57ff6 commit 8739710

File tree

22 files changed

+410
-31
lines changed

22 files changed

+410
-31
lines changed

cmd/limactl/editflags/editflags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
4949
})
5050

5151
flags.Bool("mount-writable", false, commentPrefix+"make all mounts writable")
52+
flags.Bool("mount-inotify", false, commentPrefix+"enable inotify for mounts")
5253

5354
flags.StringSlice("network", nil, commentPrefix+"additional networks, e.g., \"vzNAT\" or \"lima:shared\" to assign vmnet IP")
5455
_ = cmd.RegisterFlagCompletionFunc("network", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
@@ -154,6 +155,7 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
154155
false,
155156
},
156157
{"mount-type", d(".mountType = %q"), false, false},
158+
{"mount-inotify", d(".mountInotify = %s"), false, true},
157159
{"mount-writable", d(".mounts[].writable = %s"), false, false},
158160
{
159161
"network",

examples/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ mounts:
103103
# 🟢 Builtin default: "reverse-sshfs" (for QEMU), "virtiofs" (for vz)
104104
mountType: null
105105

106+
# Enable inotify support for mounted directories (EXPERIMENTAL)
107+
# 🟢 Builtin default: Disabled by default
108+
mountInotify: null
109+
106110
# Lima disks to attach to the instance. The disks will be accessible from inside the
107111
# instance, labeled by name. (e.g. if the disk is named "data", it will be labeled
108112
# "lima-data" inside the instance). The disk will be mounted inside the instance at

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ require (
3535
github.com/nxadm/tail v1.4.11
3636
github.com/opencontainers/go-digest v1.0.0
3737
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
38+
github.com/rjeczalik/notify v0.9.3
3839
github.com/sethvargo/go-password v0.2.0
3940
github.com/sirupsen/logrus v1.9.3
4041
github.com/spf13/cobra v1.8.0

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
236236
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
237237
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
238238
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
239+
github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY=
240+
github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc=
239241
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
240242
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
241243
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
@@ -335,6 +337,7 @@ golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
335337
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
336338
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
337339
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
340+
golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
338341
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
339342
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
340343
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

pkg/guestagent/api/client/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ func (c *GuestAgentClient) Events(ctx context.Context, eventCb func(response *ap
4949
eventCb(recv)
5050
}
5151
}
52+
53+
func (c *GuestAgentClient) Inotify(ctx context.Context) (api.GuestService_PostInotifyClient, error) {
54+
inotify, err := c.cli.PostInotify(ctx)
55+
if err != nil {
56+
return nil, err
57+
}
58+
return inotify, nil
59+
}

pkg/guestagent/api/guestservice.pb.desc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-

2+

33
guestservice.protogoogle/protobuf/empty.protogoogle/protobuf/timestamp.proto"0
44
Info(
55
local_ports ( 2.IPPortR
@@ -11,7 +11,12 @@ localPorts"
1111
errors ( Rerrors",
1212
IPPort
1313
ip ( Rip
14-
port (Rport2g
14+
port (Rport"X
15+
Inotify
16+
17+
mount_path ( R mountPath.
18+
time ( 2.google.protobuf.TimestampRtime2�
1519
GuestService(
1620
GetInfo.google.protobuf.Empty.Info-
17-
GetEvents.google.protobuf.Empty.Event0B!Zgithub.1485827954.workers.dev/lima-vm/lima/pkg/apibproto3
21+
GetEvents.google.protobuf.Empty.Event01
22+
PostInotify.Inotify.google.protobuf.Empty(B!Zgithub.1485827954.workers.dev/lima-vm/lima/pkg/apibproto3

pkg/guestagent/api/guestservice.pb.go

Lines changed: 104 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/guestagent/api/guestservice.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "google/protobuf/timestamp.proto";
77
service GuestService {
88
rpc GetInfo(google.protobuf.Empty) returns (Info);
99
rpc GetEvents(google.protobuf.Empty) returns (stream Event);
10+
rpc PostInotify(stream Inotify) returns (google.protobuf.Empty);
1011
}
1112

1213
message Info {
@@ -24,3 +25,8 @@ message IPPort {
2425
string ip = 1;
2526
int32 port = 2;
2627
}
28+
29+
message Inotify {
30+
string mount_path = 1;
31+
google.protobuf.Timestamp time = 2;
32+
}

pkg/guestagent/api/guestservice_grpc.pb.go

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)