Merge pull request 'update comments, require less sudo' (#1) from update-win10-script into master
Reviewed-on: https://git.jlay.dev/jlay/vfio/pulls/1
This commit is contained in:
commit
139b65a2cd
1 changed files with 42 additions and 28 deletions
70
start-win10
70
start-win10
|
@ -1,50 +1,64 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# requires `cset`
|
#
|
||||||
|
# script to create cpusets to isolate CPU threads for KVM/libvirt VMs
|
||||||
|
# requires 'cset'
|
||||||
# available on Fedora through my COPR:
|
# available on Fedora through my COPR:
|
||||||
# - https://copr.fedorainfracloud.org/coprs/jlay/cpuset/
|
# - https://copr.fedorainfracloud.org/coprs/jlay/cpuset/
|
||||||
# review notes regarding XML entries
|
# review comments below regarding CPUs and XML entries
|
||||||
|
#
|
||||||
# this script:
|
# this script:
|
||||||
# - isolates host tasks from the VM CPUs
|
# - isolates host tasks from the VM CPUs
|
||||||
# - applies some generic tweaks
|
# - applies some generic tweaks
|
||||||
# - resets host isolation on VM shutdown
|
# - resets host isolation on VM shutdown
|
||||||
|
#
|
||||||
# Set the range of cores assigned to the windows VM
|
# define the CPUs (cores/threads) to isolate for the VM
|
||||||
# on an i9-7920x this is the first 8 cores and the corresponding hyperthreads
|
VM_CORES='0-11,24-35'
|
||||||
VM_CORES='0-7,12-19'
|
# Tip: refer to 'virsh capabilities | grep siblings'
|
||||||
|
# this will show CPU topology information for the host
|
||||||
# based on the assignments of pinned CPUs in libvirt XML, eg:
|
# allows one to pick optimal layout for the VM
|
||||||
|
#
|
||||||
|
# the pinned CPUs are definend like so in the VM libvirt XML:
|
||||||
# <vcpupin vcpu='0' cpuset='0'/>
|
# <vcpupin vcpu='0' cpuset='0'/>
|
||||||
# <vcpupin vcpu='1' cpuset='12'/>
|
# <vcpupin vcpu='1' cpuset='24'/>
|
||||||
# [...]
|
# <vcpupin vcpu='2' cpuset='1'/>
|
||||||
# <vcpupin vcpu='14' cpuset='7'/>
|
# <vcpupin vcpu='3' cpuset='25'/>
|
||||||
# <vcpupin vcpu='15' cpuset='19'/>
|
# [...]
|
||||||
#
|
# <emulatorpin cpuset='10-11'/>
|
||||||
# `lscpu -e` and `virsh capabilities` are helpful for determining valid pinning settings
|
#
|
||||||
# on example system (i9 7920x), vCPUs 0-15 are pinned (alternating between) cores 0-7 and hyperthreads 12-19
|
# NOTE: the pinned emulator CPUs must be included in VM_CORES
|
||||||
|
# probably any iothreads too
|
||||||
|
#
|
||||||
|
# example above is based on a threadripper 3960x:
|
||||||
|
# - one NUMA node
|
||||||
|
# - SMT enabled
|
||||||
|
#
|
||||||
# reduce kernel jitter
|
# reduce kernel jitter
|
||||||
sudo sysctl vm.stat_interval=120
|
sudo sysctl vm.stat_interval=120
|
||||||
sudo sysctl kernel.watchdog=0
|
sudo sysctl kernel.watchdog=0
|
||||||
|
|
||||||
# isolate VM CPUs from host tasks
|
# attempt to reset shielding, we want to create it with current params
|
||||||
# VM must have the partition cset uses w/ userset below defined in libvirt XML, eg:
|
# and remove any existing slices from previous VM boots
|
||||||
#
|
# we want it to be created with current params, such as possibly-changed pinned CPUs
|
||||||
# </cputune> ... reference line
|
|
||||||
# <resource>
|
|
||||||
# <partition>/windows10</partition>
|
|
||||||
# </resource>
|
|
||||||
# <os> ... reference line
|
|
||||||
|
|
||||||
# first, attempt to reset shielding. we want to recreate conflicting names with set params
|
|
||||||
sudo cset shield --reset --sysset=host.slice --userset=windows10.slice
|
sudo cset shield --reset --sysset=host.slice --userset=windows10.slice
|
||||||
sudo cset set -d windows10.slice
|
sudo cset set -d windows10.slice
|
||||||
|
|
||||||
# shield cores
|
# shield cores
|
||||||
|
# userset slice must match the partition defined in libvirt xml, eg:
|
||||||
|
#
|
||||||
|
# </cputune>
|
||||||
|
# <resource>
|
||||||
|
# <partition>/windows10</partition>
|
||||||
|
# </resource>
|
||||||
|
# <os>
|
||||||
sudo cset shield -c $VM_CORES --sysset=host.slice --userset=windows10.slice
|
sudo cset shield -c $VM_CORES --sysset=host.slice --userset=windows10.slice
|
||||||
|
|
||||||
|
# setup looking glass
|
||||||
|
#sudo touch /dev/shm/looking-glass
|
||||||
|
#sudo chown jlay:kvm /dev/shm/looking-glass
|
||||||
|
#sudo chmod 660 /dev/shm/looking-glass
|
||||||
|
|
||||||
# start the VM
|
# start the VM
|
||||||
sudo virsh start windows10
|
virsh start windows10
|
||||||
|
|
||||||
# set higher priority
|
# set higher priority
|
||||||
QEMU_PID=$(sudo ps fauxww | awk '$0 ~ /qemu.*windows1[0]/ {print $2}')
|
QEMU_PID=$(sudo ps fauxww | awk '$0 ~ /qemu.*windows1[0]/ {print $2}')
|
||||||
|
|
Loading…
Reference in a new issue