Skip to content

Commit ae915e8

Browse files
committed
qemu: Handle /usr/libexec/qemu-kvm for RHEL systems
RHEL-based distributions (including CentOS Stream) use /usr/libexec/qemu-kvm as the qemu binary path, rather than the standard qemu-system-{arch}. This causes bcvk to fail when trying to start VMs on these systems. Check for the existence of /usr/libexec/qemu-kvm first, and fall back to the standard qemu-system-{arch} if it doesn't exist. Fixes: #111 Signed-off-by: Colin Walters <walters@verbum.org>
1 parent c0c76e2 commit ae915e8

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

crates/kit/src/qemu.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::process::{Child, Command, Output, Stdio};
1313
use std::sync::Arc;
1414
use std::time::Duration;
1515

16-
use camino::Utf8PathBuf;
16+
use camino::{Utf8Path, Utf8PathBuf};
1717
use cap_std_ext::cmdext::CapStdExtCommandExt;
1818
use color_eyre::eyre::{eyre, Context};
1919
use color_eyre::Result;
@@ -382,10 +382,21 @@ fn spawn(
382382
config.memory_mb
383383
);
384384

385-
let qemu = std::env::var("QEMU_BIN").ok().unwrap_or_else(|| {
386-
let arch = std::env::consts::ARCH;
387-
format!("qemu-system-{arch}")
388-
});
385+
let qemu = std::env::var("QEMU_BIN")
386+
.ok()
387+
.map(Ok)
388+
.unwrap_or_else(|| -> Result<_> {
389+
// RHEL only supports non-emulated, and qemu is an implementation detail
390+
// of higher level virt.
391+
let libexec_qemu = Utf8Path::new("/usr/libexec/qemu-kvm");
392+
if libexec_qemu.try_exists()? {
393+
Ok(libexec_qemu.to_string())
394+
} else {
395+
let arch = std::env::consts::ARCH;
396+
Ok(format!("qemu-system-{arch}"))
397+
}
398+
})
399+
.context("Checking for qemu")?;
389400

390401
let mut cmd = Command::new(qemu);
391402
// SAFETY: This API is safe to call in a forked child.

0 commit comments

Comments
 (0)