Skip to content

Commit 7da5cf6

Browse files
hikejsclaude
andcommitted
feat(vsock): integrate Windows TSI proxies into muxer
Wire Windows TSI proxy instantiation into vsock muxer: muxer.rs changes: - Conditional imports: Unix uses TsiStreamProxy/TsiDgramProxy - Windows uses TsiStreamProxyWindowsWrapper/TsiDgramProxyWindowsWrapper - RawFd gated to non-Windows (added RawFdType alias) - SOCK_STREAM proxy creation: dispatch to Windows wrapper on Windows - SOCK_DGRAM proxy creation: dispatch to Windows wrapper on Windows Complete TSI Windows implementation now integrated: - Phase 1-4: Low-level abstractions (socket, stream, dgram, pipe) - Phase 5: Proxy trait wrappers + muxer integration - Total: ~2,100 lines of Windows TSI code TSI on Windows now supports: - TCP connections (AF_INET/AF_INET6) - UDP datagrams (AF_INET/AF_INET6) - Named Pipes (AF_UNIX equivalent) - Credit-based flow control - Event-driven I/O Next: End-to-end testing with guest VM. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b0ad331 commit 7da5cf6

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

src/devices/src/virtio/vsock/muxer.rs

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::HashMap;
2+
#[cfg(not(target_os = "windows"))]
23
use std::os::unix::io::RawFd;
34
use std::path::PathBuf;
45
use std::sync::{Arc, Mutex, RwLock};
@@ -13,8 +14,14 @@ use super::proxy::{Proxy, ProxyRemoval, ProxyUpdate};
1314
use super::reaper::ReaperThread;
1415
#[cfg(target_os = "macos")]
1516
use super::timesync::TimesyncThread;
17+
#[cfg(not(target_os = "windows"))]
1618
use super::tsi_dgram::TsiDgramProxy;
19+
#[cfg(not(target_os = "windows"))]
1720
use super::tsi_stream::TsiStreamProxy;
21+
#[cfg(target_os = "windows")]
22+
use super::tsi_dgram_windows::TsiDgramProxyWindowsWrapper;
23+
#[cfg(target_os = "windows")]
24+
use super::tsi_stream_windows::TsiStreamProxyWindowsWrapper;
1825
use super::unix::UnixProxy;
1926
use super::TsiFlags;
2027
use super::VsockError;
@@ -27,6 +34,11 @@ use std::net::{Ipv4Addr, SocketAddrV4};
2734

2835
pub type ProxyMap = Arc<RwLock<HashMap<u64, Mutex<Box<dyn Proxy>>>>>;
2936

37+
#[cfg(not(target_os = "windows"))]
38+
pub type RawFdType = RawFd;
39+
#[cfg(target_os = "windows")]
40+
pub type RawFdType = i32;
41+
3042
/// A muxer RX queue item.
3143
#[derive(Debug)]
3244
pub enum MuxerRx {
@@ -295,7 +307,20 @@ impl VsockMuxer {
295307
warn!("rejecting stream inet proxy because HIJACK_INET is disabled");
296308
return;
297309
}
298-
match TsiStreamProxy::new(
310+
#[cfg(not(target_os = "windows"))]
311+
let proxy_result = TsiStreamProxy::new(
312+
id,
313+
self.cid,
314+
req.family,
315+
defs::TSI_PROXY_PORT,
316+
req.peer_port,
317+
pkt.src_port(),
318+
mem.clone(),
319+
queue.clone(),
320+
self.rxq.clone(),
321+
);
322+
#[cfg(target_os = "windows")]
323+
let proxy_result = TsiStreamProxyWindowsWrapper::new(
299324
id,
300325
self.cid,
301326
req.family,
@@ -305,7 +330,8 @@ impl VsockMuxer {
305330
mem.clone(),
306331
queue.clone(),
307332
self.rxq.clone(),
308-
) {
333+
);
334+
match proxy_result {
309335
Ok(proxy) => {
310336
self.proxy_map
311337
.write()
@@ -330,15 +356,29 @@ impl VsockMuxer {
330356
warn!("rejecting dgram inet proxy because HIJACK_INET is disabled");
331357
return;
332358
}
333-
match TsiDgramProxy::new(
359+
#[cfg(not(target_os = "windows"))]
360+
let proxy_result = TsiDgramProxy::new(
334361
id,
335362
self.cid,
336363
req.family,
337364
req.peer_port,
338365
mem.clone(),
339366
queue.clone(),
340367
self.rxq.clone(),
341-
) {
368+
);
369+
#[cfg(target_os = "windows")]
370+
let proxy_result = TsiDgramProxyWindowsWrapper::new(
371+
id,
372+
self.cid,
373+
req.family,
374+
defs::TSI_PROXY_PORT,
375+
req.peer_port,
376+
pkt.src_port(),
377+
mem.clone(),
378+
queue.clone(),
379+
self.rxq.clone(),
380+
);
381+
match proxy_result {
342382
Ok(proxy) => {
343383
self.proxy_map
344384
.write()

0 commit comments

Comments
 (0)