-
Notifications
You must be signed in to change notification settings - Fork 8
qemu: Handle /usr/libexec/qemu-kvm for RHEL systems #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.
| 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")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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")?; |
3d35c41 to
9d918e0
Compare
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>
9d918e0 to
d91c0c5
Compare
jmarrero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
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