Skip to content

Commit

Permalink
q-dev: add short way to create DeviceAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 15, 2024
1 parent 1109708 commit a3b781c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions qubes/device_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,26 @@ def __init__(
self.mode = AssignmentMode(mode)
self.frontend_domain = frontend_domain

@classmethod
def new(
cls,
backend_domain: QubesVM,
port_id: str,
devclass: str,
device_id: Optional[str] = None,
frontend_domain: Optional[QubesVM] = None,
options=None,
mode: Union[str, AssignmentMode] = "manual",
) -> 'DeviceAssignment':
return cls(
VirtualDevice(
Port(backend_domain, port_id, devclass),
device_id),
frontend_domain,
options,
mode
)

def clone(self, **kwargs):
"""
Clone object and substitute attributes with explicitly given.
Expand Down

0 comments on commit a3b781c

Please sign in to comment.