diff --git a/qubesadmin/device_protocol.py b/qubesadmin/device_protocol.py index 6c577040..049da454 100644 --- a/qubesadmin/device_protocol.py +++ b/qubesadmin/device_protocol.py @@ -862,6 +862,7 @@ class DeviceInfo(VirtualDevice): def __init__( self, port: Port, + *, vendor: Optional[str] = None, product: Optional[str] = None, manufacturer: Optional[str] = None, @@ -1225,6 +1226,7 @@ def new( port_id: str, devclass: str, device_id: Optional[str] = None, + *, frontend_domain: Optional[QubesVM] = None, options=None, mode: Union[str, AssignmentMode] = "manual", diff --git a/qubesadmin/tests/app.py b/qubesadmin/tests/app.py index b5afedcb..e724ff23 100644 --- a/qubesadmin/tests/app.py +++ b/qubesadmin/tests/app.py @@ -736,7 +736,7 @@ def test_043_clone_devices(self): self.app.expected_calls[ ('test-vm', 'admin.vm.device.pci.Assigned', None, None)] = \ (b"0\0test-vm2+dev1 port_id='dev1' devclass='pci' " - b"backend_domain='test-vm2' mode='auto-attach' " + b"backend_domain='test-vm2' mode='required' " b"_ro='yes'\n" b"test-vm3+dev2 port_id='dev2' devclass='pci' " b"backend_domain='test-vm3' mode='required'\n") @@ -744,7 +744,7 @@ def test_043_clone_devices(self): self.app.expected_calls[ ('new-name', 'admin.vm.device.pci.Assign', 'test-vm2+dev1:*', b"device_id='*' port_id='dev1' " - b"devclass='pci' backend_domain='test-vm2' mode='auto-attach' " + b"devclass='pci' backend_domain='test-vm2' mode='required' " b"frontend_domain='new-name' _ro='yes'")] = b'0\0' self.app.expected_calls[ @@ -783,7 +783,7 @@ def test_044_clone_devices_fail(self): self.app.expected_calls[ ('test-vm', 'admin.vm.device.pci.Assigned', None, None)] = \ (b"0\0test-vm2+dev1 port_id='dev1' devclass='pci' " - b"backend_domain='test-vm2' mode='auto-attach' " + b"backend_domain='test-vm2' mode='required' " b"_ro='yes'\n" b"test-vm3+dev2 port_id='dev2' devclass='pci' " b"backend_domain='test-vm3' mode='required'\n") @@ -791,7 +791,7 @@ def test_044_clone_devices_fail(self): self.app.expected_calls[ ('new-name', 'admin.vm.device.pci.Assign', 'test-vm2+dev1:*', b"device_id='*' port_id='dev1' " - b"devclass='pci' backend_domain='test-vm2' mode='auto-attach' " + b"devclass='pci' backend_domain='test-vm2' mode='required' " b"frontend_domain='new-name' _ro='yes'")] = b'0\0' self.app.expected_calls[ diff --git a/qubesadmin/tests/events.py b/qubesadmin/tests/events.py index 5510ca91..fe7a15d9 100644 --- a/qubesadmin/tests/events.py +++ b/qubesadmin/tests/events.py @@ -24,6 +24,9 @@ import subprocess import qubesadmin.tests import unittest + +from qubesadmin.device_protocol import VirtualDevice, Port + try: # qubesadmin.events require python3, so this tests can also use python3 features import asyncio @@ -257,8 +260,12 @@ def test_030_events_device(self): handler = unittest.mock.Mock() self.dispatcher.add_handler('device-attach:test', handler) self.dispatcher.handle('test-vm', 'device-attach:test', - device='test-vm2:dev', options='{}') + device='test-vm2:dev:id', options='{}') vm = self.app.domains.get_blind('test-vm') + self.app.domains.get_blind('test-vm2').devices = { + 'test': {'dev': VirtualDevice( + Port(self.app.domains.get_blind('test-vm2'),"dev", "test"), + device_id="id")}} dev = self.app.domains.get_blind('test-vm2').devices['test']['dev'] handler.assert_called_once_with(vm, 'device-attach:test', device=dev, options='{}')