diff --git a/vmrunner/vmrunner.py b/vmrunner/vmrunner.py index d79f8e4ff7..c74af0f898 100644 --- a/vmrunner/vmrunner.py +++ b/vmrunner/vmrunner.py @@ -10,6 +10,8 @@ import validate_vm import signal import psutil +import platform + from shutil import copyfile from prettify import color @@ -424,6 +426,10 @@ def kvm_present(self): self.info("KVM OFF") return False + # Check if we should use the hvf accel (MacOS only) + def hvf_present(self): + return (platform.system() == "Darwin") + # Start a process and preserve in- and output pipes # Note: if the command failed, we can't know until we have exit status, # but we can't wait since we expect no exit. Checking for program start error @@ -556,6 +562,10 @@ def boot(self, multiboot, debug = False, kernel_args = "", image_name = None): command = ["sudo", qemu_binary] if self._kvm_present: command.extend(["--enable-kvm"]) + # If hvf is present, use it and enable cpu features (needed for rdrand/rdseed) + if self.hvf_present(): + command.extend(["-accel","hvf","-cpu","host"]) + command += kernel_args command += disk_args + debug_args + net_args + mem_arg + mod_args command += vga_arg + trace_arg + pci_arg