1
0
Fork 0

network bridging, fix vendor-reset

This commit is contained in:
Massaki Archambault 2022-01-31 09:16:38 -05:00
parent bcbd8b7535
commit 8e1c5e609e
5 changed files with 77 additions and 48 deletions

View File

@ -1,10 +1,26 @@
- hosts: all, localhost
become: yes
vars:
pcie_device_ids:
- '8086:15b8' # Intel Corporation Ethernet Connection (2) I219-V
vfio_pci_ids:
# - '8086:15b8' # Intel Corporation Ethernet Connection (2) I219-V
- '1002:731f' # Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5700 / 5700 XT]
- '1002:ab38' # Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 HDMI Audio
pci_device_ids:
# Intel Corporation Ethernet Connection (2) I219-V
# - domain: '0000'
# bus: '00'
# slot: '1f'
# function: '6'
# Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5700 / 5700 XT]
- domain: '0000'
bus: '03'
slot: '00'
function: '0'
# Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 HDMI Audio
- domain: '0000'
bus: '03'
slot: '00'
function: '1'
usb_device_ids:
- '054c:05c4' # Sony Corp. DualShock 4 [CUH-ZCT1x]
- '046d:c539' # Logitech, Inc. USB Receiver

View File

@ -3,11 +3,12 @@
name:
- qemu
- libvirt
- bridge-utils
- ovmf
- virt-manager
- python-evdev
- python-pyudev
# - vendor-reset-dkms-git
- vendor-reset-dkms-git
notify:
- restart libvirtd.service
- restart virtlogd.socket
@ -24,7 +25,7 @@
state: directory
- name: install qemu hook
copy:
template:
src: hooks/qemu
dest: /etc/libvirt/hooks/qemu
mode: '755'

View File

@ -3,6 +3,11 @@
prepare() {
systemctl start win10-usb
# https://github.com/gnif/vendor-reset/issues/46#issuecomment-992282166
{% for pci_device_id in pci_device_ids %}
echo 'device_specific' >'/sys/bus/pci/devices/{{ pci_device_id.domain }}:{{ pci_device_id.bus }}:{{ pci_device_id.slot }}.{{ pci_device_id.function }}/reset_method'
{% endfor %}
vfio-isolate -u /tmp/win10.undo \
drop-caches \
compact-memory \

View File

@ -1 +1 @@
options vfio-pci ids={{ ','.join(pcie_device_ids) }}
options vfio-pci ids={{ ','.join(vfio_pci_ids) }}

View File

@ -77,7 +77,7 @@
</clock>
<on_poweroff>destroy</on_poweroff>
<!-- Because of the AMD reset bug, we cannot actually restart normally -->
<on_reboot>restart</on_reboot>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
@ -166,58 +166,26 @@
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</controller>
<interface type='bridge'>
<!-- networking -->
<!-- <interface type='bridge'>
<mac address='52:54:00:f5:2c:df'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<link state='up'/>
<address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
</interface> -->
<interface type='bridge'>
<source bridge='br0'/>
<!-- <mac address='00:16:3e:1a:b3:4a'/> -->
<model type='virtio'/>
</interface>
<!-- HID -->
<input type='mouse' bus='ps2'/>
<input type='mouse' bus='virtio'/>
<input type='keyboard' bus='ps2'/>
<input type='keyboard' bus='virtio'/>
<graphics type='spice' listen='127.0.0.1' port='5900' defaultMode='insecure'>
<listen type='address' address='127.0.0.1'/>
<image compression='off' />
<mouse mode='server'/>
<filetransfer enable='no'/>
</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'/>
</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'/>
</source>
<address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
</source>
<address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
</hostdev>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='2'/>
</redirdev>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='3'/>
</redirdev>
<memballoon model='none'/>
<shmem name='looking-glass'>
<model type='ivshmem-plain'/>
<size unit='M'>32</size>
<address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
</shmem>
<!-- mouse evdev passthrough -->
{% for item in mice %}
<input type='evdev'>
@ -230,6 +198,45 @@
<source dev='/dev/input/by-id/uinput-persist-keyboard{{ loop.index0 }}' grab='all' repeat='on'/>
</input>
{% endfor %}
<!-- audio -->
<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'/>
<!-- pci passthrough -->
{% for pci_device_id in pci_device_ids %}
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x{{ pci_device_id.domain }}' bus='0x{{ pci_device_id.bus }}' slot='0x{{ pci_device_id.slot }}' function='0x{{ pci_device_id.function }}'/>
</source>
</hostdev>
{% endfor %}
<!-- spice -->
<graphics type='spice' listen='127.0.0.1' port='5900' defaultMode='insecure'>
<listen type='address' address='127.0.0.1'/>
<image compression='off' />
<mouse mode='server'/>
<filetransfer enable='no'/>
</graphics>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='2'/>
</redirdev>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='3'/>
</redirdev>
<memballoon model='none'/>
<!-- looking-glass -->
<shmem name='looking-glass'>
<model type='ivshmem-plain'/>
<size unit='M'>32</size>
<address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
</shmem>
</devices>
<qemu:commandline>
</qemu:commandline>