device-list-attached event returns a dev/options tupples list
This commit is contained in:
parent
1c9636c5af
commit
9da28c9c15
@ -195,7 +195,11 @@ class DeviceCollection(object):
|
|||||||
|
|
||||||
def attached(self):
|
def attached(self):
|
||||||
'''List devices which are (or may be) attached to this vm '''
|
'''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):
|
def persistent(self):
|
||||||
''' Devices persistently attached and safe to access before libvirt
|
''' 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,
|
devices = self._vm.fire_event('device-list-attached:' + self._class,
|
||||||
persistent=persistent)
|
persistent=persistent)
|
||||||
result = []
|
result = []
|
||||||
for dev in devices:
|
for dev, options in devices:
|
||||||
if dev in self._set and persistent is False:
|
if dev in self._set and persistent is False:
|
||||||
continue
|
continue
|
||||||
elif dev in self._set:
|
elif dev in self._set:
|
||||||
@ -228,7 +232,7 @@ class DeviceCollection(object):
|
|||||||
else:
|
else:
|
||||||
result.append(
|
result.append(
|
||||||
DeviceAssignment(backend_domain=dev.backend_domain,
|
DeviceAssignment(backend_domain=dev.backend_domain,
|
||||||
ident=dev.ident, options=dev.options,
|
ident=dev.ident, options=options,
|
||||||
frontend_domain=self._vm))
|
frontend_domain=self._vm))
|
||||||
if persistent is not False and len(result) == 0:
|
if persistent is not False and len(result) == 0:
|
||||||
result.extend(self._set)
|
result.extend(self._set)
|
||||||
|
@ -212,7 +212,7 @@ class PCIDeviceExtension(qubes.ext.Extension):
|
|||||||
device=device,
|
device=device,
|
||||||
function=function,
|
function=function,
|
||||||
)
|
)
|
||||||
yield PCIDevice(vm.app.domains[0], ident)
|
yield (PCIDevice(vm.app.domains[0], ident), {})
|
||||||
|
|
||||||
@qubes.ext.handler('device-pre-attach:pci')
|
@qubes.ext.handler('device-pre-attach:pci')
|
||||||
def on_device_pre_attached_pci(self, vm, event, device):
|
def on_device_pre_attached_pci(self, vm, event, device):
|
||||||
|
@ -60,7 +60,7 @@ class TestVM(qubes.tests.TestEmitter):
|
|||||||
def dev_testclass_list_attached(self, event, persistent = False):
|
def dev_testclass_list_attached(self, event, persistent = False):
|
||||||
for vm in self.app.domains:
|
for vm in self.app.domains:
|
||||||
if vm.device.frontend_domain == self:
|
if vm.device.frontend_domain == self:
|
||||||
yield vm.device
|
yield (vm.device, {})
|
||||||
|
|
||||||
@qubes.events.handler('device-list:testclass')
|
@qubes.events.handler('device-list:testclass')
|
||||||
def dev_testclass_list(self, event):
|
def dev_testclass_list(self, event):
|
||||||
|
Loading…
Reference in New Issue
Block a user