Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions server/src/vmcompute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ use uuid::Uuid;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
struct ComputeSystem {
pub id: Uuid,
// Not all compute systems use a GUID as their ID (e.g. Docker Desktop), so keep this
// a string and only parse it as a UUID for the systems we actually care about.
pub id: String,
#[serde(default)]
pub system_type: String,
#[serde(default)]
pub owner: String,
pub runtime_id: Uuid,
#[serde(default)]
pub runtime_id: Option<Uuid>,
#[serde(default)]
pub state: String,
}
Expand Down Expand Up @@ -80,7 +85,15 @@ fn get_wsl_vmid_by_hcs() -> std::io::Result<Option<Uuid>> {
let vms = enumerate_compute_systems("{}")?;
for vm in vms {
if vm.owner == "WSL" {
return Ok(Some(vm.id));
// The WSL VM itself must have a GUID as its ID -- we need it to connect. Report
// a parse failure instead of pretending WSL isn't running.
let id = vm.id.parse().map_err(|err| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("WSL compute system has a non-GUID ID {:?}: {}", vm.id, err),
)
})?;
return Ok(Some(id));
}
Comment thread
oxc marked this conversation as resolved.
}
Ok(None)
Expand Down