Skip to content

Commit d6a1586

Browse files
authoredMar 27, 2019
Merge pull request #2102 from MagnusS/add-hvf
Update vmrunner.py on master to use hvf backend if available
2 parents 35605b0 + 4b08df5 commit d6a1586

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎vmrunner/vmrunner.py

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import validate_vm
1111
import signal
1212
import psutil
13+
import platform
14+
1315
from shutil import copyfile
1416

1517
from prettify import color
@@ -424,6 +426,10 @@ def kvm_present(self):
424426
self.info("KVM OFF")
425427
return False
426428

429+
# Check if we should use the hvf accel (MacOS only)
430+
def hvf_present(self):
431+
return (platform.system() == "Darwin")
432+
427433
# Start a process and preserve in- and output pipes
428434
# Note: if the command failed, we can't know until we have exit status,
429435
# 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):
556562
command = ["sudo", qemu_binary]
557563
if self._kvm_present: command.extend(["--enable-kvm"])
558564

565+
# If hvf is present, use it and enable cpu features (needed for rdrand/rdseed)
566+
if self.hvf_present():
567+
command.extend(["-accel","hvf","-cpu","host"])
568+
559569
command += kernel_args
560570
command += disk_args + debug_args + net_args + mem_arg + mod_args
561571
command += vga_arg + trace_arg + pci_arg

0 commit comments

Comments
 (0)