Skip to content

Conversation

@cgwalters
Copy link
Collaborator

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

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly adds support for RHEL-based systems by checking for /usr/libexec/qemu-kvm as a fallback for the QEMU binary. The logic is sound. I have one suggestion to refactor the implementation slightly to improve readability.

Comment on lines +385 to +399
let qemu = std::env::var("QEMU_BIN")
.ok()
.map(Ok)
.unwrap_or_else(|| -> Result<_> {
// RHEL only supports non-emulated, and qemu is an implementation detail
// of higher level virt.
let libexec_qemu = Utf8Path::new("/usr/libexec/qemu-kvm");
if libexec_qemu.try_exists()? {
Ok(libexec_qemu.to_string())
} else {
let arch = std::env::consts::ARCH;
Ok(format!("qemu-system-{arch}"))
}
})
.context("Checking for qemu")?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the functional-style chain with map(Ok).unwrap_or_else is correct, it can be a bit dense and harder to read for logic involving fallbacks and potential errors. Refactoring this into an immediately-invoked closure with a more traditional if/else structure makes the sequence of checks clearer and improves overall readability.

Suggested change
let qemu = std::env::var("QEMU_BIN")
.ok()
.map(Ok)
.unwrap_or_else(|| -> Result<_> {
// RHEL only supports non-emulated, and qemu is an implementation detail
// of higher level virt.
let libexec_qemu = Utf8Path::new("/usr/libexec/qemu-kvm");
if libexec_qemu.try_exists()? {
Ok(libexec_qemu.to_string())
} else {
let arch = std::env::consts::ARCH;
Ok(format!("qemu-system-{arch}"))
}
})
.context("Checking for qemu")?;
let qemu = (|| -> Result<_> {
if let Some(qemu_bin) = std::env::var("QEMU_BIN").ok() {
Ok(qemu_bin)
} else {
// RHEL only supports non-emulated, and qemu is an implementation detail
// of higher level virt.
let libexec_qemu = Utf8Path::new("/usr/libexec/qemu-kvm");
if libexec_qemu.try_exists()? {
Ok(libexec_qemu.to_string())
} else {
let arch = std::env::consts::ARCH;
Ok(format!("qemu-system-{arch}"))
}
}
})()
.context("Checking for qemu")?;

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: bootc-dev#111
Signed-off-by: Colin Walters <walters@verbum.org>
Copy link
Collaborator

@jmarrero jmarrero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@cgwalters cgwalters merged commit ae915e8 into bootc-dev:main Nov 4, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bcvk get stuck at waiting for systemd on rhel-10.0

2 participants