1010//! - [`VmHandler`] — lifecycle operations on a running VM
1111
1212use std:: net:: Ipv4Addr ;
13+ #[ cfg( target_os = "macos" ) ]
14+ use std:: os:: fd:: RawFd ;
1315use std:: path:: PathBuf ;
1416
1517use async_trait:: async_trait;
@@ -51,11 +53,21 @@ pub struct TeeInstanceConfig {
5153 pub tee_type : String ,
5254}
5355
54- /// Network instance configuration for passt-based networking .
56+ /// Network instance configuration for the network backend ( passt on Linux, gvproxy on macOS) .
5557#[ derive( Debug , Clone , Serialize , Deserialize ) ]
5658pub struct NetworkInstanceConfig {
57- /// Path to the passt Unix socket.
58- pub passt_socket_path : PathBuf ,
59+ /// Path to the network backend Unix socket (passt on Linux, gvproxy on macOS).
60+ pub net_socket_path : PathBuf ,
61+
62+ /// Pre-opened Unix datagram socket fd inherited by the shim on macOS.
63+ #[ cfg( target_os = "macos" ) ]
64+ #[ serde( default ) ]
65+ pub net_socket_fd : Option < RawFd > ,
66+
67+ /// Proxy-side Unix datagram socket fd inherited by the shim on macOS.
68+ #[ cfg( target_os = "macos" ) ]
69+ #[ serde( default ) ]
70+ pub net_proxy_fd : Option < RawFd > ,
5971
6072 /// Assigned IPv4 address for this VM.
6173 pub ip_address : Ipv4Addr ,
@@ -127,8 +139,8 @@ pub struct InstanceSpec {
127139 #[ serde( default ) ]
128140 pub user : Option < String > ,
129141
130- /// Network configuration for passt-based networking.
131- /// None = TSI mode (default), Some = passt virtio-net mode.
142+ /// Network configuration for virtio-net networking.
143+ /// None = TSI mode (default), Some = virtio-net mode (passt on Linux, gvproxy on macOS) .
132144 #[ serde( default ) ]
133145 pub network : Option < NetworkInstanceConfig > ,
134146
@@ -371,7 +383,11 @@ mod tests {
371383 fn test_instance_spec_with_network ( ) {
372384 let spec = InstanceSpec {
373385 network : Some ( NetworkInstanceConfig {
374- passt_socket_path : PathBuf :: from ( "/tmp/passt.sock" ) ,
386+ net_socket_path : PathBuf :: from ( "/tmp/net.sock" ) ,
387+ #[ cfg( target_os = "macos" ) ]
388+ net_socket_fd : Some ( 42 ) ,
389+ #[ cfg( target_os = "macos" ) ]
390+ net_proxy_fd : Some ( 43 ) ,
375391 ip_address : "10.0.0.2" . parse ( ) . unwrap ( ) ,
376392 gateway : "10.0.0.1" . parse ( ) . unwrap ( ) ,
377393 prefix_len : 24 ,
@@ -385,6 +401,10 @@ mod tests {
385401 let deserialized: InstanceSpec = serde_json:: from_str ( & json) . unwrap ( ) ;
386402
387403 let net = deserialized. network . unwrap ( ) ;
404+ #[ cfg( target_os = "macos" ) ]
405+ assert_eq ! ( net. net_socket_fd, Some ( 42 ) ) ;
406+ #[ cfg( target_os = "macos" ) ]
407+ assert_eq ! ( net. net_proxy_fd, Some ( 43 ) ) ;
388408 assert_eq ! ( net. ip_address, "10.0.0.2" . parse:: <Ipv4Addr >( ) . unwrap( ) ) ;
389409 assert_eq ! ( net. gateway, "10.0.0.1" . parse:: <Ipv4Addr >( ) . unwrap( ) ) ;
390410 assert_eq ! ( net. prefix_len, 24 ) ;
0 commit comments