|
5 | 5 | //! QEMU related code |
6 | 6 | use crate::{ |
7 | 7 | app::Manifest, |
8 | | - config::{CvmConfig, GatewayConfig, Networking, NetworkingMode, ProcessAnnotation, Protocol}, |
| 8 | + config::{CvmConfig, GatewayConfig, Networking, NetworkingMode, ProcessAnnotation}, |
9 | 9 | }; |
10 | 10 | use std::{collections::HashMap, os::unix::fs::PermissionsExt}; |
11 | 11 | use std::{ |
@@ -63,7 +63,7 @@ fn networking_to_proto(n: &Networking) -> pb::NetworkingConfig { |
63 | 63 | let mode = match n.mode { |
64 | 64 | NetworkingMode::Bridge => "bridge", |
65 | 65 | NetworkingMode::User => "user", |
66 | | - NetworkingMode::Passt => "passt", |
| 66 | + |
67 | 67 | NetworkingMode::Custom => "custom", |
68 | 68 | }; |
69 | 69 | pb::NetworkingConfig { mode: mode.into() } |
@@ -351,113 +351,6 @@ impl VmState { |
351 | 351 | } |
352 | 352 |
|
353 | 353 | impl VmConfig { |
354 | | - fn config_passt(&self, workdir: &VmWorkDir, netcfg: &Networking) -> Result<ProcessConfig> { |
355 | | - let Networking { |
356 | | - passt_exec, |
357 | | - interface, |
358 | | - address, |
359 | | - netmask, |
360 | | - gateway, |
361 | | - dns, |
362 | | - map_host_loopback, |
363 | | - map_guest_addr, |
364 | | - no_map_gw, |
365 | | - ipv4_only, |
366 | | - .. |
367 | | - } = netcfg; |
368 | | - |
369 | | - let passt_socket = workdir.passt_socket(); |
370 | | - if passt_socket.exists() { |
371 | | - fs_err::remove_file(&passt_socket).context("Failed to remove passt socket")?; |
372 | | - } |
373 | | - let passt_exec = if passt_exec.is_empty() { |
374 | | - "passt" |
375 | | - } else { |
376 | | - passt_exec |
377 | | - }; |
378 | | - |
379 | | - let passt_log = workdir.passt_log(); |
380 | | - |
381 | | - let mut passt_cmd = Command::new(passt_exec); |
382 | | - passt_cmd.arg("--socket").arg(&passt_socket); |
383 | | - passt_cmd.arg("--log-file").arg(&passt_log); |
384 | | - |
385 | | - if !interface.is_empty() { |
386 | | - passt_cmd.arg("--interface").arg(interface); |
387 | | - } |
388 | | - if !address.is_empty() { |
389 | | - passt_cmd.arg("--address").arg(address); |
390 | | - } |
391 | | - if !netmask.is_empty() { |
392 | | - passt_cmd.arg("--netmask").arg(netmask); |
393 | | - } |
394 | | - if !gateway.is_empty() { |
395 | | - passt_cmd.arg("--gateway").arg(gateway); |
396 | | - } |
397 | | - for dns in dns { |
398 | | - passt_cmd.arg("--dns").arg(dns); |
399 | | - } |
400 | | - if !map_host_loopback.is_empty() { |
401 | | - passt_cmd.arg("--map-host-loopback").arg(map_host_loopback); |
402 | | - } |
403 | | - if !map_guest_addr.is_empty() { |
404 | | - passt_cmd.arg("--map-guest-addr").arg(map_guest_addr); |
405 | | - } |
406 | | - if *no_map_gw { |
407 | | - passt_cmd.arg("--no-map-gw"); |
408 | | - } |
409 | | - if *ipv4_only { |
410 | | - passt_cmd.arg("--ipv4-only"); |
411 | | - } |
412 | | - // Group port mappings by protocol |
413 | | - let mut tcp_ports = Vec::new(); |
414 | | - let mut udp_ports = Vec::new(); |
415 | | - |
416 | | - for pm in &self.manifest.port_map { |
417 | | - let port_spec = format!("{}/{}:{}", pm.address, pm.from, pm.to); |
418 | | - match pm.protocol { |
419 | | - Protocol::Tcp => tcp_ports.push(port_spec), |
420 | | - Protocol::Udp => udp_ports.push(port_spec), |
421 | | - } |
422 | | - } |
423 | | - // Add TCP port forwarding — one --tcp-ports per spec to avoid |
424 | | - // exceeding passt's single-argument parser limit. |
425 | | - for spec in &tcp_ports { |
426 | | - passt_cmd.arg("--tcp-ports").arg(spec); |
427 | | - } |
428 | | - // Add UDP port forwarding |
429 | | - for spec in &udp_ports { |
430 | | - passt_cmd.arg("--udp-ports").arg(spec); |
431 | | - } |
432 | | - passt_cmd.arg("-f").arg("-1"); |
433 | | - |
434 | | - let args = passt_cmd |
435 | | - .get_args() |
436 | | - .map(|arg| arg.to_string_lossy().to_string()) |
437 | | - .collect::<Vec<_>>(); |
438 | | - let stdout_path = workdir.passt_stdout(); |
439 | | - let stderr_path = workdir.passt_stderr(); |
440 | | - let note = ProcessAnnotation { |
441 | | - kind: "passt".to_string(), |
442 | | - live_for: Some(self.manifest.id.clone()), |
443 | | - }; |
444 | | - let note = serde_json::to_string(¬e)?; |
445 | | - let process_config = ProcessConfig { |
446 | | - id: format!("passt-{}", self.manifest.id), |
447 | | - args, |
448 | | - name: format!("passt-{}", self.manifest.name), |
449 | | - command: passt_exec.to_string(), |
450 | | - env: Default::default(), |
451 | | - cwd: workdir.to_string_lossy().to_string(), |
452 | | - stdout: stdout_path.to_string_lossy().to_string(), |
453 | | - stderr: stderr_path.to_string_lossy().to_string(), |
454 | | - pidfile: Default::default(), |
455 | | - cid: None, |
456 | | - note, |
457 | | - }; |
458 | | - Ok(process_config) |
459 | | - } |
460 | | - |
461 | 354 | pub fn config_qemu( |
462 | 355 | &self, |
463 | 356 | workdir: impl AsRef<Path>, |
@@ -592,16 +485,6 @@ impl VmConfig { |
592 | 485 | } |
593 | 486 | netdev |
594 | 487 | } |
595 | | - NetworkingMode::Passt => { |
596 | | - processes.push( |
597 | | - self.config_passt(&workdir, networking) |
598 | | - .context("Failed to configure passt")?, |
599 | | - ); |
600 | | - format!( |
601 | | - "stream,id=net0,server=off,addr.type=unix,addr.path={}", |
602 | | - workdir.passt_socket().display() |
603 | | - ) |
604 | | - } |
605 | 488 | NetworkingMode::Bridge => { |
606 | 489 | tracing::info!("bridge networking: mac={mac} bridge={}", networking.bridge); |
607 | 490 | format!("bridge,id=net0,br={}", networking.bridge) |
@@ -1183,22 +1066,6 @@ impl VmWorkDir { |
1183 | 1066 | self.workdir.join("qmp.sock") |
1184 | 1067 | } |
1185 | 1068 |
|
1186 | | - pub fn passt_socket(&self) -> PathBuf { |
1187 | | - self.workdir.join("passt.sock") |
1188 | | - } |
1189 | | - |
1190 | | - pub fn passt_stdout(&self) -> PathBuf { |
1191 | | - self.workdir.join("passt.stdout") |
1192 | | - } |
1193 | | - |
1194 | | - pub fn passt_stderr(&self) -> PathBuf { |
1195 | | - self.workdir.join("passt.stderr") |
1196 | | - } |
1197 | | - |
1198 | | - pub fn passt_log(&self) -> PathBuf { |
1199 | | - self.workdir.join("passt.log") |
1200 | | - } |
1201 | | - |
1202 | 1069 | pub fn path(&self) -> &Path { |
1203 | 1070 | &self.workdir |
1204 | 1071 | } |
|
0 commit comments