mgmt: send artificial 'connection-established' event just after connection
This allows avoid race condition between registering event handlers and performing some action. The important thing is the event sent after registering event handlers in qubesd. This means state changes (like VM start/stop) after 'connection-established' event will be included in event stream. QubesOS/qubes-issues#2622
This commit is contained in:
parent
8cc0af1eda
commit
643cef1e65
@ -583,6 +583,9 @@ class QubesMgmt(AbstractQubesMgmt):
|
||||
type(self.app).add_handler('*', handler)
|
||||
qubes.vm.BaseVM.add_handler('*', handler)
|
||||
|
||||
# send artificial event as a confirmation that connection is established
|
||||
self.send_event(self.app, 'connection-established')
|
||||
|
||||
try:
|
||||
yield from wait_for_cancel
|
||||
except asyncio.CancelledError:
|
||||
|
@ -856,7 +856,10 @@ class TC_00_VMs(MgmtTestCase):
|
||||
self.assertEventFired(self.emitter,
|
||||
'mgmt-permission:' + 'mgmt.Events')
|
||||
self.assertEqual(send_event.mock_calls,
|
||||
[unittest.mock.call(self.vm, 'test-event', arg1='abc')])
|
||||
[
|
||||
unittest.mock.call(self.app, 'connection-established'),
|
||||
unittest.mock.call(self.vm, 'test-event', arg1='abc')
|
||||
])
|
||||
|
||||
|
||||
def test_990_vm_unexpected_payload(self):
|
||||
|
Loading…
Reference in New Issue
Block a user