Skip to content

Commit c90e64d

Browse files
joei4cmclaude
andcommitted
Name the WSL provider for the machine OpenBot makes on Windows
Podman's Windows installer asks whether to use WSL or Hyper-V and writes the answer to 99-podman-machine-provider.conf, so `podman machine init` followed it. With Hyper-V remembered, init goes through Podman's Hyper-V backend and enumerates root\virtualization\v2 over WMI: on Windows 11 Home that namespace does not exist, and the step fails with "could not find virtual machine: failure advancing enumeration" (#1860). On the editions that do have Hyper-V it makes a machine OpenBot cannot use, because the user-mode networking that follows belongs to the WSL provider. The rest of the Windows setup already assumes a WSL machine: init registers a WSL distribution, the disk is placed by provisionWSLDist under the machine home, and user-mode networking is the WSL provider's own podman-net-usermode distribution. So the provider is named on Windows, and only there. Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent d96528b commit c90e64d

2 files changed

Lines changed: 76 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
9797
address anybody else can open.
9898
- **Moving to OpenBot Cloud carries artifacts,** each with every version and the files it uses.
9999

100+
**OpenBot Desktop.**
101+
102+
- **On Windows, setup makes its Podman machine with WSL.** Podman's Windows installer asks whether
103+
to use WSL or Hyper-V and remembers the answer. With Hyper-V remembered, the machine could not
104+
be made on a Windows that has no Hyper-V, such as Windows 11 Home, and setup stopped with
105+
`could not find virtual machine: failure advancing enumeration`. On the Windows editions that do
106+
have Hyper-V, it made a machine OpenBot could not use, because the user-mode networking that
107+
follows belongs to the WSL provider. OpenBot now asks Podman for WSL itself, which is what the
108+
rest of the Windows setup expects.
109+
100110
**Security.**
101111

102112
- **The web app turns on Trusted Types** (`require-trusted-types-for 'script'`), so the browser

‎desktop/src-tauri/src/acquire.rs‎

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,11 @@ pub fn machine_exists() -> Result<bool, String> {
468468

469469
/// Create the machine.
470470
///
471-
/// No `--provider`: `applehv` has been the default on Apple silicon since Podman 6.1, and pinning it
472-
/// asks for what you already get. The libkrun bind-mount trouble that the pin was written for
473-
/// belonged to 5.7, where libkrun was the default.
471+
/// No `--provider` on macOS: `applehv` has been the default on Apple silicon since Podman 6.1, and
472+
/// pinning it asks for what you already get. The libkrun bind-mount trouble that the pin was
473+
/// written for belonged to 5.7, where libkrun was the default.
474+
///
475+
/// On Windows the provider IS named, and it is WSL: see `WSL_PROVIDER`.
474476
///
475477
/// `--rootful`, for local Intelligence: see the module comment.
476478
///
@@ -559,6 +561,9 @@ fn create_machine_on(
559561
Err(error) => return StepOutcome::stopped(Step::CreateMachine, &error),
560562
}
561563
let mut args = create_machine_args(cpus, memory_mib, disk_gib);
564+
if target_is_windows {
565+
args.extend(WSL_PROVIDER.map(String::from));
566+
}
562567
if let Some(image) = image {
563568
args.extend(["--image".to_string(), image.to_string_lossy().into_owned()]);
564569
}
@@ -578,6 +583,20 @@ fn create_machine_on(
578583
/// Turns user-mode networking on for the stopped machine, on Windows.
579584
const USER_MODE_NETWORKING_ON: [&str; 4] = ["machine", "set", USER_MODE_NETWORKING_FLAG, MACHINE];
580585

586+
/// The provider named on Windows, where this app's machine is a WSL machine.
587+
///
588+
/// Podman's Windows installer asks whether to use WSL or Hyper-V and writes the answer to
589+
/// `99-podman-machine-provider.conf` under `%APPDATA%\containers\containers.conf.d\`, so
590+
/// `podman machine init` follows that file when it is told nothing. A Hyper-V machine cannot be
591+
/// made on Windows 11 Home, where Hyper-V does not exist, and Podman then fails with the raw WMI
592+
/// words `could not find virtual machine: failure advancing enumeration` (the report in #1860).
593+
///
594+
/// The rest of the Windows setup already assumes a WSL machine: init registers a WSL
595+
/// distribution, the disk is placed by `provisionWSLDist` under the machine home, and user-mode
596+
/// networking is the WSL provider's own `podman-net-usermode` distribution. Naming the provider
597+
/// says what that setup needs.
598+
const WSL_PROVIDER: [&str; 2] = ["--provider", "wsl"];
599+
581600
fn create_machine_args(cpus: u32, memory_mib: u32, disk_gib: u32) -> Vec<String> {
582601
vec![
583602
"machine".to_string(),
@@ -2376,7 +2395,9 @@ mod tests {
23762395
"8192",
23772396
"--disk-size",
23782397
"64",
2379-
"--rootful"
2398+
"--rootful",
2399+
"--provider",
2400+
"wsl"
23802401
],
23812402
vec!["machine", "set", "--user-mode-networking=true", "openbot"]
23822403
]
@@ -2420,6 +2441,47 @@ mod tests {
24202441
assert_eq!(ran, ["machine init"]);
24212442
}
24222443

2444+
/// The provider is named on Windows, where this app's machine is a WSL machine. Podman
2445+
/// otherwise follows the choice its Windows installer wrote down, and a Hyper-V machine cannot
2446+
/// be made on Windows 11 Home at all (#1860).
2447+
#[test]
2448+
fn windows_names_the_wsl_provider_and_other_systems_name_none() {
2449+
let (result, ran) = windows_create(Ok(String::new()));
2450+
assert!(result.ok, "{result:?}");
2451+
let init = &ran[0];
2452+
let provider = init.iter().position(|arg| arg == "--provider");
2453+
assert_eq!(
2454+
provider.map(|at| init[at + 1].as_str()),
2455+
Some("wsl"),
2456+
"{init:?}"
2457+
);
2458+
2459+
let mut ran = Vec::new();
2460+
let result = create_machine_on(
2461+
false,
2462+
4,
2463+
8192,
2464+
64,
2465+
None,
2466+
|| Ok(false),
2467+
|| {},
2468+
|args| {
2469+
ran.push(
2470+
args.iter()
2471+
.map(|arg| (*arg).to_string())
2472+
.collect::<Vec<String>>(),
2473+
);
2474+
Ok(String::new())
2475+
},
2476+
);
2477+
assert!(result.ok, "{result:?}");
2478+
assert!(
2479+
!ran[0].iter().any(|arg| arg == "--provider"),
2480+
"{:?}",
2481+
ran[0]
2482+
);
2483+
}
2484+
24232485
/// Local Intelligence's k3d needs a rootful engine, on macOS as on Windows.
24242486
#[test]
24252487
fn the_machine_is_created_rootful_on_every_platform() {

0 commit comments

Comments
 (0)