From 4b08df50bd96e6c7a149e61d1bee51e0f019536e Mon Sep 17 00:00:00 2001 From: Magnus Skjegstad Date: Tue, 26 Mar 2019 20:01:00 +0100 Subject: [PATCH] Update vmrunner.py on master to use hvf backend if available This is needed for rdrand/rdseed support Signed-off-by: Magnus Skjegstad --- vmrunner/vmrunner.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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