Skip to content
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

Added support for using a custom QEMU binary #92

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

rdelfin
Copy link

@rdelfin rdelfin commented Oct 21, 2024

I've been looking into getting vmtest to work on a RHEL 8 system. After some digging me and @javierhonduco did, we found that one of the issues is that RHEL's QEMU installation is substantially different from most other Linux distros, as it does not create qemu-system-* binaries, but instead has a binary in /usr/libexec/qemu-kvm. In order to further test, overriding the binary path used to find QEMU would be extremely helpful. This PR does that.

Manual Testing

Ran this on a RHEL machine:

$ cargo run -- -k ~/code/lightswitch-kernels/bzImage_v6.9-rc5 "uname -r"
[...]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.99s
     Running `target/debug/vmtest -k /home/cloud-user/code/lightswitch-kernels/bzImage_v6.9-rc5 'uname -r'`
=> bzImage_v6.9-rc5
Failed to setup QEMU

Caused by:
    0: Did not find QEMU binary qemu-system-x86_64. Make sure QEMU is installed
    1: No such file or directory (os error 2)

$ cargo run -- -k ~/code/lightswitch-kernels/bzImage_v6.9-rc5 -q /usr/libexec/qemu-kvm "uname -r"
[...]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/vmtest -k /home/cloud-user/code/lightswitch-kernels/bzImage_v6.9-rc5 -q /usr/libexec/qemu-kvm 'uname -r'`
=> bzImage_v6.9-rc5
===> Booting
qemu-kvm: -virtfs local,id=root,path=/,mount_tag=/dev/root,security_model=none,multidevs=remap: 'virtio-9p-pci' is not a valid device model name


Caused by:
    0: Failed to connect QMP
    1: Connection refused (os error 111)

The former failed to launch QEMU (with a clearer error message than before), the latter failed to start after launching QEMU (RHEL 8 does not support 9p from what we were able to find).

src/qemu.rs Outdated

let mut c = Command::new(format!("qemu-system-{}", target.arch));
//

This comment was marked as outdated.

@rdelfin rdelfin force-pushed the custom-qemu-binary branch from b1ef914 to 3a7ea09 Compare October 21, 2024 15:27
Copy link
Owner

@danobi danobi left a comment

Choose a reason for hiding this comment

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

thanks for the PR! lgtm modulo nit

src/qemu.rs Outdated
Comment on lines 662 to 676
// Confirm QEMU exists first
if let Err(e) = Command::new(&program)
.arg("--help")
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
{
if let ErrorKind::NotFound = e.kind() {
return Err(e).context(format!(
"Did not find QEMU binary {program}. Make sure QEMU is installed"
));
} else {
warn!("Failed to verify that qemu is installed due to error, continuing... {e}");
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Mind pulling this out into a helper function? Just so the main logic in this function is a bit more compact

Copy link
Author

Choose a reason for hiding this comment

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

Yep! Let me do that. I'll take a little bit to continue, I need to wait for a thumbs up from work about a couple things, but I'll get back to you

Copy link
Author

@rdelfin rdelfin Oct 25, 2024

Choose a reason for hiding this comment

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

Sorry for the delay. Lmk if this is what you meant

@rdelfin rdelfin force-pushed the custom-qemu-binary branch from 3a7ea09 to 13c072c Compare October 25, 2024 13:31
@rdelfin rdelfin requested a review from danobi October 25, 2024 13:31
@rdelfin rdelfin force-pushed the custom-qemu-binary branch from 13c072c to 8749032 Compare October 25, 2024 13:35
Copy link
Owner

@danobi danobi left a comment

Choose a reason for hiding this comment

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

lgtm! thanks!

@danobi danobi merged commit fd741bb into danobi:master Oct 25, 2024
1 check 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.

3 participants