@@ -18,8 +18,10 @@ import (
1818 "time"
1919
2020 "github.com/containers/gvisor-tap-vsock/pkg/net/stdio"
21+ "github.com/containers/gvisor-tap-vsock/pkg/notification"
2122 "github.com/containers/gvisor-tap-vsock/pkg/sshclient"
2223 "github.com/containers/gvisor-tap-vsock/pkg/transport"
24+ "github.com/containers/gvisor-tap-vsock/pkg/types"
2325 "github.com/containers/gvisor-tap-vsock/pkg/virtualnetwork"
2426 "github.com/containers/winquit/pkg/winquit"
2527 humanize "github.com/dustin/go-humanize"
@@ -126,6 +128,14 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
126128 }
127129 log .Info ("waiting for clients..." )
128130
131+ var notificationSender * notification.NotificationSender
132+ if config .NotificationSocket != "" {
133+ notificationSender = notification .NewNotificationSender (config .NotificationSocket )
134+ g .Go (func () error {
135+ notificationSender .Start (ctx )
136+ return nil
137+ })
138+ }
129139 for _ , endpoint := range config .Listen {
130140 log .Infof ("listening %s" , endpoint )
131141 ln , err := transport .Listen (endpoint )
@@ -134,6 +144,7 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
134144 }
135145 httpServe (ctx , g , ln , withProfiler (vn ))
136146 }
147+ notificationSender .Send (types.NotificationMessage {NotificationType : types .Ready })
137148
138149 if config .Services != "" {
139150 log .Infof ("enabling services API. Listening %s" , config .Services )
@@ -188,6 +199,7 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
188199 log .Errorf ("vpnkit accept error: %s" , err )
189200 continue
190201 }
202+ notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
191203 g .Go (func () error {
192204 return vn .AcceptVpnKit (conn )
193205 })
@@ -213,8 +225,10 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
213225 g .Go (func () error {
214226 conn , err := qemuListener .Accept ()
215227 if err != nil {
228+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
216229 return fmt .Errorf ("qemu accept error: %w" , err )
217230 }
231+ notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
218232 return vn .AcceptQemu (ctx , conn )
219233 })
220234 }
@@ -236,15 +250,18 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
236250 g .Go (func () error {
237251 conn , err := bessListener .Accept ()
238252 if err != nil {
253+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
239254 return fmt .Errorf ("bess accept error: %w" , err )
240255 }
256+ notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
241257 return vn .AcceptBess (ctx , conn )
242258 })
243259 }
244260
245261 if config .Interfaces .Vfkit != "" {
246262 conn , err := transport .ListenUnixgram (config .Interfaces .Vfkit )
247263 if err != nil {
264+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
248265 return fmt .Errorf ("vfkit listen error: %w" , err )
249266 }
250267
@@ -260,15 +277,19 @@ func run(ctx context.Context, g *errgroup.Group, config *GvproxyConfig) error {
260277 g .Go (func () error {
261278 vfkitConn , err := transport .AcceptVfkit (conn )
262279 if err != nil {
280+ notificationSender .Send (types.NotificationMessage {NotificationType : types .HypervisorError })
263281 return fmt .Errorf ("vfkit accept error: %w" , err )
264282 }
283+
284+ notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
265285 return vn .AcceptVfkit (ctx , vfkitConn )
266286 })
267287 }
268288
269289 if config .Interfaces .Stdio != "" {
270290 g .Go (func () error {
271291 conn := stdio .GetStdioConn ()
292+ notificationSender .Send (types.NotificationMessage {NotificationType : types .ConnectionEstablished })
272293 return vn .AcceptStdio (ctx , conn )
273294 })
274295 }
0 commit comments