Remove WrongAssignment exception
Signed-off-by: Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
This commit is contained in:
parent
e446e7a2f4
commit
5a8cc9bdd3
@ -55,10 +55,6 @@ class DeviceAlreadyAttached(qubes.exc.QubesException, KeyError):
|
||||
'''Trying to attach already attached device'''
|
||||
pass
|
||||
|
||||
class WrongAssignment(qubes.exc.QubesException, KeyError):
|
||||
'''Trying to attach non permanent assignment to a halted vm'''
|
||||
pass
|
||||
|
||||
|
||||
class DeviceAssignment(object): # pylint: disable=too-few-public-methods
|
||||
''' Maps a device to a frontend_domain. '''
|
||||
@ -155,13 +151,13 @@ class DeviceCollection(object):
|
||||
|
||||
if not device_assignment.frontend_domain:
|
||||
device_assignment.frontend_domain = self._vm
|
||||
else:
|
||||
assert device_assignment.frontend_domain == self._vm, \
|
||||
"Trying to attach DeviceAssignment belonging to other domain"
|
||||
|
||||
if device_assignment.frontend_domain != self._vm:
|
||||
raise WrongAssignment(
|
||||
"Trying to attach DeviceAssignment belonging to other domain")
|
||||
if not device_assignment.persistent and self._vm.is_halted():
|
||||
raise WrongAssignment("Devices can only be attached persistent to "
|
||||
"a halted vm")
|
||||
raise qubes.exc.QubesVMNotRunningError(self._vm,
|
||||
"Devices can only be attached non-persistent to a running vm")
|
||||
device = self._device(device_assignment)
|
||||
if device in self.assignments():
|
||||
raise DeviceAlreadyAttached(
|
||||
@ -182,7 +178,7 @@ class DeviceCollection(object):
|
||||
device_assignment.frontend_domain = self._vm
|
||||
|
||||
if device_assignment in self._set and not self._vm.is_halted():
|
||||
raise WrongAssignment(
|
||||
raise qubes.exc.QubesVMNotHaltedError(self._vm,
|
||||
"Can not remove a persistent attachment from a non halted vm")
|
||||
if device_assignment not in self.assignments():
|
||||
raise DeviceNotAttached(
|
||||
|
@ -101,7 +101,7 @@ class TC_00_Devices_PCI(qubes.tests.SystemTestsMixin,
|
||||
dev_col = self.vm.devices['pci']
|
||||
self.assertDeviceNotInCollection(self.dev, dev_col)
|
||||
self.assignment.persistent = False
|
||||
with self.assertRaises(qubes.devices.WrongAssignment):
|
||||
with self.assertRaises(qubes.exc.QubesVMNotRunningError):
|
||||
dev_col.attach(self.assignment)
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ class TC_00_Devices_PCI(qubes.tests.SystemTestsMixin,
|
||||
dev_col.attach(self.assignment)
|
||||
self.app.save()
|
||||
self.vm.start()
|
||||
with self.assertRaises(qubes.devices.WrongAssignment):
|
||||
with self.assertRaises(qubes.exc.QubesVMNotHaltedError):
|
||||
self.vm.devices['pci'].detach(self.assignment)
|
||||
|
||||
def test_030_persist_attach_detach_offline(self):
|
||||
|
Loading…
Reference in New Issue
Block a user