Skip to content

Commit

Permalink
Partial fix for PCI devices reordering
Browse files Browse the repository at this point in the history
See QubesOS/qubes-issues#6587.

Attempt to fix the rest of PCI device reordering
  • Loading branch information
Vít Šesták authored and marmarek committed Oct 11, 2023
1 parent c965d85 commit 4282dec
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions qubes/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
`domain-qdb-change:path`) to detect changes and fire
`device-list-change:class` event.
'''
from typing import Optional

import qubes.utils

class DeviceNotAttached(qubes.exc.QubesException, KeyError):
Expand Down Expand Up @@ -339,7 +341,7 @@ def assignments(self, persistent=None):
:file:`qubes.xml`) or not. Device can also be in :file:`qubes.xml`,
but be temporarily detached.
:param bool persistent: only include devices which are or are not
:param Optional[bool] persistent: only include devices which are or are not
attached persistently.
'''

Expand All @@ -351,24 +353,19 @@ def assignments(self, persistent=None):
self._bus))
if persistent is True:
# don't break app.save()
return self._set
return list(self._set)
raise
result = set()
for dev, options in devices:
if dev in self._set and not persistent:
continue
if dev in self._set:
result.add(self._set.get(dev))
elif dev not in self._set and persistent:
continue
else:
result.add(
DeviceAssignment(
backend_domain=dev.backend_domain,
ident=dev.ident, options=options,
bus=self._bus))
if persistent is not False:
result.update(self._set)
result = []
if persistent is not False: # None or True
result.extend(self._set)
if not persistent: # None or False
for dev, options in devices:
if dev not in self._set:
result.append(
DeviceAssignment(
backend_domain=dev.backend_domain,
ident=dev.ident, options=options,
bus=self._bus))
return result

def available(self):
Expand Down

0 comments on commit 4282dec

Please sign in to comment.