Skip to content

Commit c097b6f

Browse files
committed
q-dev: make pci can be only assigned as required
1. `ask-to-attach` is not even implemented for PCI (assigned devices will be ignored) 2. manual attaching could lead to unusable devices 3. `auto-attach` there is no good reason for ignoring absent of PCI device
1 parent 0ccf3a5 commit c097b6f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

qubesadmin/devices.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def attach(self, assignment: DeviceAssignment) -> None:
6464
6565
:param DeviceAssignment assignment: device object
6666
"""
67+
if assignment.devclass == 'pci':
68+
raise qubesadmin.exc.QubesValueError(
69+
f"PCI devices cannot be attached manually, "
70+
f"did you mean `qvm-pci assign --required ...`")
6771
self._add(assignment, 'attach')
6872

6973
def detach(self, assignment: DeviceAssignment) -> None:
@@ -85,7 +89,10 @@ def assign(self, assignment: DeviceAssignment) -> None:
8589
and assignment.required):
8690
raise qubesadmin.exc.QubesValueError(
8791
"Only pci and block devices can be assigned as required.")
88-
if (assignment.devclass not in ('pci', 'testclass', 'usb', 'block')
92+
if assignment.devclass == 'pci' and not assignment.required:
93+
raise qubesadmin.exc.QubesValueError(
94+
f"PCI devices cannot be assigned as not required.")
95+
if (assignment.devclass not in ('testclass', 'usb', 'block')
8996
and assignment.attach_automatically):
9097
raise qubesadmin.exc.QubesValueError(
9198
f"{assignment.devclass} devices cannot be assigned "

0 commit comments

Comments
 (0)