Skip to content

Commit

Permalink
Script cleanup, changes to hugepages, romfile specification and more.
Browse files Browse the repository at this point in the history
Readme touchup
Hugepage --help clarification
Removed broken quotes from romfile var
Removed +1 from hugepage allocation, as in future it could be a 2MB or 1GB difference.
Added -vbios as alternative to -romfile flag.
Added conditional '[ "$driver" != "vfio-pci" ]' to restorebind in case

More script cleanup (various echoing changes, functions for repetitive calls etc)

-Hugepages rework to support custom hugepage mountpoints where one may have specified 1G page sizes. However will no longer mount /dev/hugepages on its own anymore as it'll be expected by default on a Linux system.

-Hugepages also now supports preallocation now and if enough preallocated pages are free for a guest it'll use what's already present. Useful if someone wants to do `hugepagesz=1G hugepages=10` on their cmdline for early allocation at boot time and mount their own hugetlbfs with -o pagesize=1G and point the script to that. Doing this also skips cache drops and memory compaction

-romfile argument added to support using a custom vbios file for when a when GPU pci device is detected and arguments for it get created for qemu.

Changed memory-backend-file id for future reference
  • Loading branch information
Jared J committed Jun 6, 2021
1 parent e649cb6 commit 8d0184f
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 150 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ Using example 2:
Set how much memory the VM gets for this run. Argument assumes megabytes unless you explicitly use a suffix like K, M, or G.
If this argument isn't specified the default value is HALF of the host total.

`-hugepages / -huge`
`-hugepages / -huge / -hugepages /optional/mountpoint/to/custom/hugepage`

Try to mount (if not already) and allocate some hugepages based on the VM's total memory defined with -memory (or default).
If successful, qemu is given the arguments to use it. Gets unallocated after VM exit in the cleanup routine.
Tries to allocate hugepages for the VM based on it's total memory defined with -memory. Hugepages for a VM with frequent random memory access such as gaming contexts can be much snappier than your regular process doing the same thing across many small pages.
If no argument is given it'll use /dev/hugepages which is often 2MB per page. The script drops host memory cache and then compact_memory before allocating to aim for less hugepage fragmentation and will clean up after itself by setting pages back to 0 to reclaim memory for the host to use later.
Also supports preallocation, so if you reserved some 1GB pages at boot time and mounted a pagesize=1G hugetlbfs to some directory, specifying that can skip the above line if there's enough for the VM to use. Allocating hugepages at boot time sacrifices a lot of memory but doing it so early prevents fragmentation.

`-hyperv`

Expand Down Expand Up @@ -158,6 +159,11 @@ This example would catch any:

If set adds extra arbitrary commands to the cmdline of qemu (Once invoked)
Useful for `-device ac97` to get some quick and easy audio support if the host is running pulseaudio.

`-romfile/-vbios /path/to/vbios.bin`
Accepts a file path to a rom file to use on any detected GPU during -pci argument processing.
You should check the vbios dump you're about to use is safe before using it on a GPU, rom-parser is a good project for this.
Otherwise you can often download your model's vbios from TechPowerup and patch it with a project like NVIDIA-vBIOS-VFIO-Patcher before using it.

`-run`

Expand Down
Loading

0 comments on commit 8d0184f

Please sign in to comment.