| 201 | } |
| 202 | |
| 203 | fn networking_from_proto(proto: &rpc::NetworkingConfig) -> Option<crate::config::Networking> { |
| 204 | use crate::config::NetworkingMode; |
| 205 | let mode = match proto.mode.as_str() { |
| 206 | "bridge" => NetworkingMode::Bridge, |
| 207 | |
| 208 | "user" => NetworkingMode::User, |
| 209 | "custom" => NetworkingMode::Custom, |
| 210 | "" => return None, // not set, use global default |
| 211 | other => { |
| 212 | tracing::warn!("unsupported per-VM networking mode '{other}', using global default"); |
| 213 | return None; |
| 214 | } |
| 215 | }; |
| 216 | // Only set mode; other fields will be merged from global config at runtime |
| 217 | Some(crate::config::Networking { |
| 218 | mode, |
| 219 | bridge: String::new(), |
| 220 | mac_prefix: String::new(), |
| 221 | net: String::new(), |
| 222 | dhcp_start: String::new(), |
| 223 | restrict: false, |
| 224 | netdev: String::new(), |
| 225 | forward_service_enabled: false, |
| 226 | }) |
| 227 | } |
| 228 | |
| 229 | impl RpcHandler { |
| 230 | fn resolve_gpus(&self, gpu_cfg: &rpc::GpuConfig) -> Result<GpuConfig> { |