Skip to content

Commit bea0f9d

Browse files
author
Roy Lin
committed
fix(pool): gate snapshot-fork trigger_snapshot to unix (Windows build)
warm_pool::trigger_snapshot connects to libkrun's snapshot trigger socket via tokio::net::UnixStream, which does not exist on Windows (E0433). Snapshot-fork is a Linux/KVM feature, so gate the real impl to #[cfg(unix)] and add a #[cfg(not(unix))] stub that errors — mirroring the existing cfg(not(windows)) pattern in the pool CLI. Fixes the v2.1.0 Build Windows (WHPX) failure.
1 parent 33511b0 commit bea0f9d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/runtime/src/pool/warm_pool.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ impl WarmPool {
500500

501501
/// Send a `snapshot <state>` request to libkrun's per-template trigger socket and
502502
/// wait for the `ok` reply (the socket appears once the template's vCPUs run).
503+
///
504+
/// Snapshot-fork is a Linux/KVM (Unix) feature; on non-Unix hosts the trigger
505+
/// socket does not exist, so this is unavailable (see the `not(unix)` stub).
506+
#[cfg(unix)]
503507
async fn trigger_snapshot(sock: &std::path::Path, state_file: &std::path::Path) -> Result<()> {
504508
use tokio::io::{AsyncReadExt, AsyncWriteExt};
505509
// The socket is bound by libkrun after the guest starts; poll briefly.
@@ -534,6 +538,16 @@ impl WarmPool {
534538
}
535539
}
536540

541+
/// Non-Unix stub: snapshot-fork relies on libkrun's Unix trigger socket and KVM
542+
/// state save/restore, neither of which exist on Windows. `--snapshot-fork` is
543+
/// Linux/KVM-only, so this path is never reached there in practice.
544+
#[cfg(not(unix))]
545+
async fn trigger_snapshot(_sock: &std::path::Path, _state_file: &std::path::Path) -> Result<()> {
546+
Err(BoxError::PoolError(
547+
"snapshot-fork is only supported on Linux/KVM hosts".to_string(),
548+
))
549+
}
550+
537551
/// Fill the pool to the minimum idle count.
538552
async fn fill_to_min(&self) {
539553
let current = self.idle.lock().await.len();

0 commit comments

Comments
 (0)