1
0
Fork 0

various ajustements

This commit is contained in:
Massaki Archambault 2020-08-21 16:19:00 -04:00
parent 3fc57c2279
commit 7c4e5b9a17
4 changed files with 79 additions and 23 deletions

View File

@ -1,6 +1,6 @@
title Archlinux w/ VFIO
linux /vmlinuz-linux
linux /vmlinuz-linux-xanmod
initrd /intel-ucode.img
initrd /initramfs-linux.img
options intel_iommu=on iommu=pt intel_iommu=igfx_off experimental_zcopytx=1 kvm.ignore_msrs=1 acpi_backlight=none root=LABEL=ARCHROOT rw
initrd /initramfs-linux-xanmod.img
options mitigations=off intel_iommu=on iommu=pt intel_iommu=igfx_off experimental_zcopytx=1 kvm.ignore_msrs=1 acpi_backlight=none root=LABEL=ARCHROOT rw

View File

@ -1,18 +1,64 @@
#!/bin/bash
prepare() {
systemctl start vm-usb-helper
echo "Defrag RAM"
echo 1 > /proc/sys/vm/compact_memory
for _ in $(seq 5); do
sleep 3
# assign hugepages
sysctl -w vm.nr_hugepages=8192 && break
done
sleep 10
echo "Setup cpuset cgroup for host"
sudo cset set -c 0,4 -s system
sudo cset proc -m -f root -t system
sudo cset proc -k -f root -t system --force
echo "Setup cpumask"
for i in /sys/devices/virtual/workqueue/*/cpumask; do
sudo sh -c "echo 001 > $i"
done;
echo "Setup interrupt affinity"
for i in $(sed -n -e 's/ \([0-9]\+\):.*vfio.*/\1/p' /proc/interrupts); do
sudo sh -c "echo 0,4 > /proc/irq/$i/smp_affinity_list"
done
echo "Set the CPU frequency governor to performance"
for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo performance >$f
done
}
release() {
echo "Restore system"
# irq
for i in $(sed -n -e 's/ \([0-9]\+\):.*vfio.*/\1/p' /proc/interrupts); do
sudo sh -c "echo ff > /proc/irq/$i/smp_affinity"
done
# cpumask
for i in /sys/devices/virtual/workqueue/*/cpumask; do
sudo sh -c "echo ff > $i"
done;
# cpuset
sudo cset set -d system &>/dev/null
for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo powersave >$f
done
systemctl stop vm-usb-helper
sysctl -w vm.nr_hugepages=0
}
if [ "$1" == "win10" ]; then
if [ "$2" == "prepare" ]; then
systemctl start vm-usb-helper
# defrag ram
echo 1 > /proc/sys/vm/compact_memory
for _ in $(seq 5); do
sleep 3
# assign hugepages
sysctl -w vm.nr_hugepages=8192 && break
done
sleep 10
prepare
fi
if [ "$2" == "release" ]; then
systemctl stop vm-usb-helper
sysctl -w vm.nr_hugepages=0
release
fi
fi

View File

@ -73,8 +73,9 @@
<timer name='tsc' present='yes' mode='native'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<!-- Because of the reset bug, we cannot actually restart without restarting the host -->
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
@ -171,17 +172,18 @@
</interface>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='spice' autoport='yes' defaultMode="insecure" listen="127.0.0.1" port="5900">
<listen type='address' address="127.0.0.1"/>
</graphics>
<sound model='ich9'>
<address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
</sound>
<!--
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x00' slot='0x1f' function='0x6'/>
</source>
<address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
</hostdev>
-->
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
@ -215,6 +217,7 @@
<qemu:arg value='input-linux,id=kbd1,evdev=/dev/input/by-path/platform-i8042-serio-0-event-kbd,grab_all=off,repeat=on'/>
<!-- audio passthrough -->
<qemu:arg value='-audiodev'/>
<qemu:arg value='pa,id=pa1,server=/run/user/1000/pulse/native'/>
<qemu:arg value="driver=pa,id=hda,server=/run/user/1000/pulse/native,out.buffer-length=2000,timer-period=1000"/>
<!-- <qemu:arg value="driver=pa,id=hda,server=127.0.0.1,out.buffer-length=2000,timer-period=1000"/> -->
</qemu:commandline>
</domain>

View File

@ -89,11 +89,18 @@
dest: /etc/libvirt/hooks/qemu
mode: '755'
- name: configure systemd CPUAffinity
# - name: configure systemd CPUAffinity
# lineinfile:
# path: /etc/systemd/system.conf
# regexp: '^#?CPUAffinity'
# line: 'CPUAffinity=0 4'
- name: configure pulseaudio tcp socket
lineinfile:
path: /etc/systemd/system.conf
regexp: '^#?CPUAffinity'
line: 'CPUAffinity=0 4'
path: /etc/pulse/default.pa
regexp: '^#?load-module module-native-protocol-tcp'
line: 'load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1'
- name: enable libvirtd.socket
systemd: