cgroupsv2 partial compat + update audio config format
This commit is contained in:
parent
2e0f4c91b4
commit
513ab94563
|
@ -9,6 +9,8 @@
|
|||
- '054c:05c4' # Sony Corp. DualShock 4 [CUH-ZCT1x]
|
||||
- '046d:c539' # Logitech, Inc. USB Receiver
|
||||
- '046d:c08d' # Logitech, Inc. G502 LIGHTSPEED Wireless Gaming Mouse
|
||||
kbd_device_path: '/dev/input/by-id/usb-0d3d_USBPS2-event-kbd'
|
||||
keyboards:
|
||||
- '/dev/input/by-id/usb-0d3d_USBPS2-event-kbd'
|
||||
mice: []
|
||||
roles:
|
||||
- win10
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
pcie_device_ids: []
|
||||
usb_device_ids: []
|
||||
kbd_device_path: ''
|
||||
keyboards: []
|
||||
mice: []
|
|
@ -2,5 +2,5 @@ title Archlinux w/ VFIO
|
|||
linux /vmlinuz-linux
|
||||
initrd /intel-ucode.img
|
||||
initrd /initramfs-linux.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
|
||||
options mitigations=off intel_iommu=on iommu=pt intel_iommu=igfx_off experimental_zcopytx=1 kvm.ignore_msrs=1 acpi_backlight=none root=LABEL=ARCHLINUX rw
|
||||
|
||||
|
|
|
@ -2,15 +2,28 @@
|
|||
|
||||
prepare() {
|
||||
systemctl start win10-usb
|
||||
|
||||
# setup cgroupv2
|
||||
systemctl set-property --runtime -- user.slice AllowedCPUs=0,4
|
||||
systemctl set-property --runtime -- system.slice AllowedCPUs=0,4
|
||||
systemctl set-property --runtime -- init.scope AllowedCPUs=0,4
|
||||
|
||||
|
||||
vfio-isolate -u /tmp/win10.undo \
|
||||
drop-caches \
|
||||
compact-memory \
|
||||
irq-affinity mask C1-3,5-7 \
|
||||
cpuset-create --cpus C0,4 /host.slice \
|
||||
cpuset-create --cpus C1-3,5-7 -nlb /win10.slice \
|
||||
move-tasks / /host.slice \
|
||||
cpu-governor performance C0-7
|
||||
|
||||
# vfio-isolate -u /tmp/win10.undo \
|
||||
# drop-caches \
|
||||
# compact-memory \
|
||||
# irq-affinity mask C1-3,5-7 \
|
||||
# cpuset-create --cpus C0,4 /host.slice \
|
||||
# cpuset-create --cpus C1-3,5-7 -nlb /win10.slice \
|
||||
# move-tasks / /host.slice \
|
||||
# cpu-governor performance C0-7
|
||||
|
||||
for _ in $(seq 5); do
|
||||
sleep 3
|
||||
# assign hugepages
|
||||
|
@ -21,6 +34,12 @@ prepare() {
|
|||
|
||||
release() {
|
||||
echo "Restore system"
|
||||
|
||||
# restore cgroupv2
|
||||
systemctl set-property --runtime -- user.slice AllowedCPUs=0,1,2,3,4,5,6,7
|
||||
systemctl set-property --runtime -- system.slice AllowedCPUs=0,1,2,3,4,5,6,7
|
||||
systemctl set-property --runtime -- init.scope AllowedCPUs=0,1,2,3,4,5,6,7
|
||||
|
||||
vfio-isolate restore /tmp/win10.undo
|
||||
systemctl stop win10-usb
|
||||
sysctl -w vm.nr_hugepages=0
|
||||
|
|
|
@ -16,3 +16,9 @@
|
|||
name: virtlogd.socket
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
- name: restart persistent-evdev
|
||||
systemd:
|
||||
name: persistent-evdev.service
|
||||
enabled: yes
|
||||
state: restarted
|
|
@ -5,15 +5,17 @@
|
|||
- libvirt
|
||||
- ovmf
|
||||
- virt-manager
|
||||
- python-evdev
|
||||
- python-pyudev
|
||||
notify:
|
||||
- restart libvirtd.socket
|
||||
- restart libvirtd.service
|
||||
- restart virtlogd.socket
|
||||
|
||||
# TODO
|
||||
# - name: install required packages from aur
|
||||
# aur:
|
||||
# name:
|
||||
# - vfio-isolate
|
||||
- name: install required aur packages
|
||||
aur:
|
||||
name:
|
||||
- vfio-isolate
|
||||
- persistent-evdev-git
|
||||
|
||||
- name: create hooks directory
|
||||
file:
|
||||
|
@ -92,12 +94,17 @@
|
|||
marker: '# {mark} DEVICE ACL CONFIGURATION'
|
||||
block: |
|
||||
cgroup_device_acl = [
|
||||
{% for item in keyboards %}
|
||||
"/dev/input/by-id/uinput-persist-keyboard{{ loop.index0 }}",
|
||||
{% endfor %}
|
||||
{% for item in mice %}
|
||||
"/dev/input/by-id/uinput-persist-mouse{{ loop.index0 }}",
|
||||
{% endfor %}
|
||||
"/dev/kvm",
|
||||
"/dev/null", "/dev/full", "/dev/zero",
|
||||
"/dev/random", "/dev/urandom",
|
||||
"/dev/ptmx", "/dev/kvm", "/dev/kqemu",
|
||||
"/dev/rtc","/dev/hpet", "/dev/sev",
|
||||
"{{ kbd_device_path }}"
|
||||
"/dev/rtc","/dev/hpet", "/dev/sev"
|
||||
]
|
||||
|
||||
- name: install domain configuration
|
||||
|
@ -113,8 +120,14 @@
|
|||
# regexp: '^#?CPUAffinity'
|
||||
# line: 'CPUAffinity=0 4'
|
||||
|
||||
- name: configure persistent-evedev
|
||||
template:
|
||||
src: persistent-evdev/config.json.j2
|
||||
dest: /opt/persistent-evdev/etc/config.json
|
||||
notify: restart persistent-evdev
|
||||
|
||||
- name: enable libvirtd.socket
|
||||
systemd:
|
||||
name: libvirtd.socket
|
||||
enabled: yes
|
||||
|
||||
state: started
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"cache": "/opt/persistent-evdev/cache",
|
||||
"devices": {
|
||||
{% for item in keyboards %}
|
||||
"persist-keyboard{{loop.index0}}": "{{ item }}",
|
||||
{% endfor %}
|
||||
{% for item in mice %}
|
||||
"persist-mouse{{loop.index0}}": "{{ item }}",
|
||||
{% endfor %}
|
||||
"dummy" : "/dev/null"
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
Description=Attach usb devices to vm
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/vfio-usb win10 --evdev-kbd "{{ kbd_device_path }}" {{ ' '.join(usb_device_ids) }}
|
||||
ExecStart=/usr/bin/vfio-usb win10 --evdev-kbd "/dev/input/by-id/uinput-persist-keyboard0" {{ ' '.join(usb_device_ids) }}
|
||||
Restart=always
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='raw' io='threads'/>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source file='/home/marchambault/Documents/virtualmachines/img/win10.img'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
<boot order='1'/>
|
||||
|
@ -180,7 +180,9 @@
|
|||
</graphics>
|
||||
<sound model='ich9'>
|
||||
<address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
|
||||
<audio id='1'/>
|
||||
</sound>
|
||||
<audio id='1' type='pulseaudio' serverName='/run/user/1000/pulse/native'/>
|
||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||
<source>
|
||||
<address domain='0x0000' bus='0x00' slot='0x1f' function='0x6'/>
|
||||
|
@ -205,9 +207,10 @@
|
|||
<redirdev bus='usb' type='spicevmc'>
|
||||
<address type='usb' bus='0' port='3'/>
|
||||
</redirdev>
|
||||
<memballoon model='virtio'>
|
||||
<memballoon model='none'/>
|
||||
<!-- <memballoon model='virtio'>
|
||||
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||
</memballoon>
|
||||
</memballoon> -->
|
||||
<shmem name='looking-glass'>
|
||||
<model type='ivshmem-plain'/>
|
||||
<size unit='M'>32</size>
|
||||
|
@ -216,11 +219,14 @@
|
|||
</devices>
|
||||
<qemu:commandline>
|
||||
<!-- keyboard evdev passthrough -->
|
||||
{% for item in keyboards %}
|
||||
<qemu:arg value='-object'/>
|
||||
<qemu:arg value='input-linux,id=kbd1,evdev={{ kbd_device_path }},grab_all=off,repeat=on'/>
|
||||
<!-- audio passthrough -->
|
||||
<qemu:arg value='-audiodev'/>
|
||||
<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:arg value='input-linux,id=kbd1,evdev=/dev/input/by-id/uinput-persist-keyboard{{ loop.index0 }},grab_all=off,repeat=on'/>
|
||||
{% endfor %}
|
||||
<!-- mouse evdev passthrough -->
|
||||
{% for item in mice %}
|
||||
<qemu:arg value='-object'/>
|
||||
<qemu:arg value='input-linux,id=input5,evdev=/dev/input/by-id/uinput-persist-mouse{{ loop.index0 }}'/>
|
||||
{% endfor %}
|
||||
</qemu:commandline>
|
||||
</domain>
|
||||
|
|
Loading…
Reference in New Issue