Skip to content

Commit

Permalink
q-dev: update pci tests and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 15, 2024
1 parent e73d56d commit b8bee03
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
1 change: 0 additions & 1 deletion qubes/ext/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ async def on_domain_start(self, vm, _event, **_kwargs):
if assignment.required:
# already attached
continue
# TODO: notify?
for device in assignment.devices:
if isinstance(device, qubes.device_protocol.UnknownDevice):
continue
Expand Down
2 changes: 0 additions & 2 deletions qubes/ext/pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ def on_device_pre_attached_pci(self, vm, event, device, options):
return

try:
# TODO?
device = _cache_get(device.backend_domain, device.port_id)
self.bind_pci_to_pciback(vm.app, device)
vm.libvirt_domain.attachDevice(
Expand Down Expand Up @@ -446,7 +445,6 @@ def on_device_pre_detached_pci(self, vm, event, port):
def on_domain_pre_start(self, vm, _event, **_kwargs):
# Bind pci devices to pciback driver
for assignment in vm.devices['pci'].get_assigned_devices():
# TODO?
device = _cache_get(assignment.backend_domain, assignment.port_id)
self.bind_pci_to_pciback(vm.app, device)

Expand Down
21 changes: 9 additions & 12 deletions qubes/tests/integ/devices_pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ def setUp(self):
pcidev = os.environ['QUBES_TEST_PCIDEV']
self.dev = self.app.domains[0].devices['pci'][pcidev]
self.assignment = DeviceAssignment(
self.dev, mode='auto-attach'
)
self.required_assignment = DeviceAssignment(
self.dev, mode='required',
self.dev, mode='required'
)
if isinstance(self.dev, qubes.device_protocol.UnknownDevice):
self.skipTest('Specified device {} does not exists'.format(pcidev))
Expand Down Expand Up @@ -91,19 +88,19 @@ def assertDeviceIs(
dedicated = assigned or attached
self.assertTrue(dedicated == device in dev_col.get_dedicated_devices())

def test_010_assign_offline(self): # TODO required
def test_010_assign_offline(self):
dev_col = self.vm.devices['pci']
self.assertDeviceIs(
self.dev, attached=False, assigned=False, required=False)

self.loop.run_until_complete(dev_col.assign(self.assignment))
self.app.save()
self.assertDeviceIs(
self.dev, attached=False, assigned=True, required=False)
self.dev, attached=False, assigned=True, required=True)

self.loop.run_until_complete(self.vm.start())
self.assertDeviceIs(
self.dev, attached=True, assigned=False, required=False)
self.dev, attached=True, assigned=False, required=True)

(stdout, _) = self.loop.run_until_complete(
self.vm.run_for_stdio('lspci'))
Expand All @@ -119,7 +116,7 @@ def test_011_attach_offline_temp_fail(self):
self.loop.run_until_complete(
dev_col.attach(self.assignment))

def test_020_attach_online_persistent(self): # TODO: required
def test_020_attach_online_persistent(self):
self.loop.run_until_complete(
self.vm.start())
dev_col = self.vm.devices['pci']
Expand All @@ -129,7 +126,7 @@ def test_020_attach_online_persistent(self): # TODO: required
self.loop.run_until_complete(
dev_col.attach(self.assignment))
self.assertDeviceIs(
self.dev, attached=True, assigned=True, required=False)
self.dev, attached=True, assigned=True, required=True)

# give VM kernel some time to discover new device
time.sleep(1)
Expand All @@ -151,7 +148,7 @@ def test_021_persist_detach_online_fail(self):
self.loop.run_until_complete(
self.vm.devices['pci'].detach(self.assignment))

def test_030_persist_attach_detach_offline(self): # TODO: required
def test_030_persist_attach_detach_offline(self):
dev_col = self.vm.devices['pci']
self.assertDeviceIs(
self.dev, attached=False, assigned=False, required=False)
Expand All @@ -160,14 +157,14 @@ def test_030_persist_attach_detach_offline(self): # TODO: required
dev_col.attach(self.assignment))
self.app.save()
self.assertDeviceIs(
self.dev, attached=False, assigned=True, required=False)
self.dev, attached=False, assigned=True, required=True)

self.loop.run_until_complete(
dev_col.detach(self.assignment))
self.assertDeviceIs(
self.dev, attached=False, assigned=False, required=False)

def test_031_attach_detach_online_temp(self): # TODO: requiured
def test_031_attach_detach_online_temp(self):
dev_col = self.vm.devices['pci']
self.loop.run_until_complete(
self.vm.start())
Expand Down

0 comments on commit b8bee03

Please sign in to comment.