Skip to content

Commit

Permalink
Update vmrunner.py on master to use hvf backend if available
Browse files Browse the repository at this point in the history
This is needed for rdrand/rdseed support

Signed-off-by: Magnus Skjegstad <[email protected]>
  • Loading branch information
MagnusS committed Mar 26, 2019
1 parent 35605b0 commit 4b08df5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vmrunner/vmrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import validate_vm
import signal
import psutil
import platform

from shutil import copyfile

from prettify import color
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4b08df5

Please sign in to comment.