Browse Source

Allow QEMU to fall back

Tamir Duberstein 4 months ago
parent
commit
e3bfeb9dd6
1 changed files with 3 additions and 24 deletions
  1. 3 24
      xtask/src/run.rs

+ 3 - 24
xtask/src/run.rs

@@ -1,9 +1,8 @@
 use std::{
-    env::consts::{ARCH, OS},
     ffi::OsString,
     fmt::Write as _,
     fs::{copy, create_dir_all, OpenOptions},
-    io::{BufRead as _, BufReader, ErrorKind, Write as _},
+    io::{BufRead as _, BufReader, Write as _},
     path::{Path, PathBuf},
     process::{Child, ChildStdin, Command, Output, Stdio},
     sync::{Arc, Mutex},
@@ -358,28 +357,8 @@ pub fn run(opts: Options) -> Result<()> {
                 if let Some(cpu) = cpu {
                     qemu.args(["-cpu", cpu]);
                 }
-                if guest_arch == ARCH {
-                    match OS {
-                        "linux" => {
-                            const KVM: &str = "/dev/kvm";
-                            match OpenOptions::new().read(true).write(true).open(KVM) {
-                                Ok(_file) => {
-                                    qemu.args(["-accel", "kvm"]);
-                                }
-                                Err(error) => match error.kind() {
-                                    ErrorKind::NotFound | ErrorKind::PermissionDenied => {}
-                                    _kind => {
-                                        return Err(error)
-                                            .with_context(|| format!("failed to open {KVM}"));
-                                    }
-                                },
-                            }
-                        }
-                        "macos" => {
-                            qemu.args(["-accel", "hvf"]);
-                        }
-                        os => bail!("unsupported OS: {os}"),
-                    }
+                for accel in ["kvm", "hvf", "tcg"] {
+                    qemu.args(["-accel", accel]);
                 }
                 let console = OsString::from(console);
                 let mut kernel_args = std::iter::once(("console", &console))