device-list-attached event returns a dev/options tupples list

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2017-04-15 19:12:39 +02:00
parent 1c9636c5af
commit 9da28c9c15
No known key found for this signature in database
GPG Key ID: 07799AE179ED4FD4
3 changed files with 9 additions and 5 deletions

View File

@ -195,7 +195,11 @@ class DeviceCollection(object):
def attached(self):
'''List devices which are (or may be) attached to this vm '''
return self._vm.fire_event('device-list-attached:' + self._class) or []
attached = self._vm.fire_event('device-list-attached:' + self._class)
if attached:
return [dev for dev, _ in attached]
return []
def persistent(self):
''' Devices persistently attached and safe to access before libvirt
@ -218,7 +222,7 @@ class DeviceCollection(object):
devices = self._vm.fire_event('device-list-attached:' + self._class,
persistent=persistent)
result = []
for dev in devices:
for dev, options in devices:
if dev in self._set and persistent is False:
continue
elif dev in self._set:
@ -228,7 +232,7 @@ class DeviceCollection(object):
else:
result.append(
DeviceAssignment(backend_domain=dev.backend_domain,
ident=dev.ident, options=dev.options,
ident=dev.ident, options=options,
frontend_domain=self._vm))
if persistent is not False and len(result) == 0:
result.extend(self._set)

View File

@ -212,7 +212,7 @@ class PCIDeviceExtension(qubes.ext.Extension):
device=device,
function=function,
)
yield PCIDevice(vm.app.domains[0], ident)
yield (PCIDevice(vm.app.domains[0], ident), {})
@qubes.ext.handler('device-pre-attach:pci')
def on_device_pre_attached_pci(self, vm, event, device):

View File

@ -60,7 +60,7 @@ class TestVM(qubes.tests.TestEmitter):
def dev_testclass_list_attached(self, event, persistent = False):
for vm in self.app.domains:
if vm.device.frontend_domain == self:
yield vm.device
yield (vm.device, {})
@qubes.events.handler('device-list:testclass')
def dev_testclass_list(self, event):