From 93e88e0c22427e13aa18332d5fe109897f29471d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 3 Sep 2016 20:29:14 +0200 Subject: [PATCH] qubes/ext/pci: implement pci-no-strict-reset/BDF feature Instead of old per-VM flag 'pci_strictreset', now implement this as per-device flag using features. To not fail on particular device assignment set 'pci-no-strict-reset/DEVICE-BDF' to True. For example 'pci-no-strict-reset/00:1b.0'. QubesOS/qubes-issues#2257 --- qubes/ext/pci.py | 4 ++-- qubes/tests/int/devices_pci.py | 1 + templates/libvirt/devices/pci.xml | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qubes/ext/pci.py b/qubes/ext/pci.py index 5e3ef0af..2f08af26 100644 --- a/qubes/ext/pci.py +++ b/qubes/ext/pci.py @@ -231,7 +231,7 @@ class PCIDeviceExtension(qubes.ext.Extension): self.bind_pci_to_pciback(vm.app, device) vm.libvirt_domain.attachDevice( vm.app.env.get_template('libvirt/devices/pci.xml').render( - device=device)) + device=device, vm=vm)) except subprocess.CalledProcessError as e: vm.log.exception('Failed to attach PCI device {!r} on the fly,' ' changes will be seen after VM restart.'.format( @@ -261,7 +261,7 @@ class PCIDeviceExtension(qubes.ext.Extension): user='root', input='00:{}'.format(vmdev)) vm.libvirt_domain.detachDevice( vm.app.env.get_template('libvirt/devices/pci.xml').render( - device=device)) + device=device, vm=vm)) except (subprocess.CalledProcessError, libvirt.libvirtError) as e: vm.log.exception('Failed to detach PCI device {!r} on the fly,' ' changes will be seen after VM restart.'.format( diff --git a/qubes/tests/int/devices_pci.py b/qubes/tests/int/devices_pci.py index a421c32d..73a6c1d2 100644 --- a/qubes/tests/int/devices_pci.py +++ b/qubes/tests/int/devices_pci.py @@ -50,6 +50,7 @@ class TC_00_Devices_PCI(qubes.tests.SystemTestsMixin, label='red', ) self.vm.create_on_disk() + self.vm.features['pci-no-strict-reset/' + pcidev] = True self.app.save() def test_000_list(self): diff --git a/templates/libvirt/devices/pci.xml b/templates/libvirt/devices/pci.xml index 5f81800f..cc33c05c 100644 --- a/templates/libvirt/devices/pci.xml +++ b/templates/libvirt/devices/pci.xml @@ -1,4 +1,8 @@ - +