Skip to content

Commit

Permalink
Ignore PCI devices on non-0000 domain instead of crashing
Browse files Browse the repository at this point in the history
This is a quick band-aid to unbreak Qubes on systems having such device.
Later change should implement handling them properly instead of
ignoring.

Fixes QubesOS/qubes-issues#6932
  • Loading branch information
marmarek committed Oct 10, 2023
1 parent c965d85 commit 3384d98
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions qubes/ext/pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
pci_classes = None


#: emit warning on unspported device only once
unsupported_devices_warned = set()


class UnsupportedDevice(Exception):
pass


def load_pci_classes():
''' List of known device classes, subclasses and programming interfaces. '''
# Syntax:
Expand Down Expand Up @@ -138,7 +146,8 @@ class PCIDevice(qubes.devices.DeviceInfo):
def __init__(self, backend_domain, ident, libvirt_name=None):
if libvirt_name:
dev_match = self._libvirt_regex.match(libvirt_name)
assert dev_match
if not dev_match:
raise UnsupportedDevice(libvirt_name)
ident = '{bus}_{device}.{function}'.format(**dev_match.groupdict())

super().__init__(backend_domain, ident, None)
Expand Down Expand Up @@ -170,6 +179,7 @@ def frontend_domain(self):
return all_attached.get(self.ident, None)



class PCIDeviceExtension(qubes.ext.Extension):
def __init__(self):
super().__init__()
Expand All @@ -189,7 +199,12 @@ def on_device_list_pci(self, vm, event):

xml_desc = lxml.etree.fromstring(dev.XMLDesc())
libvirt_name = xml_desc.findtext('name')
yield PCIDevice(vm, None, libvirt_name=libvirt_name)
try:
yield PCIDevice(vm, None, libvirt_name=libvirt_name)
except UnsupportedDevice:
if libvirt_name not in unsupported_devices_warned:
vm.log.warning("Unsupported device: %s", libvirt_name)
unsupported_devices_warned.add(libvirt_name)

@qubes.ext.handler('device-get:pci')
def on_device_get_pci(self, vm, event, ident):
Expand Down

0 comments on commit 3384d98

Please sign in to comment.