QubesWatch: do not create multiple dom0 QubesDB connections

When calling _register_watches() multiple times for dom0 (by passing
None or since 7e9c816b by passing the corresponding libvirt domain) the
check was missing if there is already a QubesDB in _qdb. Therefore a new
QubesDB was created and the old one is destroyed by the GC. As a
consequence the watch_fd is closed but the libvirt event handle for this
fd is still registered. So when libvirt calls poll() it returns
immediately POLLNVAL with the closed fd. This is not caught in libvirt
and the callback is called as if an event happened. _qdb_handler() now
calls read_watch() on the new fd for dom0 and thereby hangs the thread.
This leads (at leads) to qubes-manager to miss VM status updates and
block device events.

Fixes QubesOS/qubes-issues#2178
This commit is contained in:
HW42 2016-07-17 21:35:16 +02:00 committed by Marek Marczykowski-Górecki
parent 9751981f69
commit b467dd6218
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -761,6 +761,8 @@ class QubesWatch(object):
return return
else: else:
name = "dom0" name = "dom0"
if name in self._qdb:
return
self._qdb[name] = QubesDB(name) self._qdb[name] = QubesDB(name)
try: try:
self._qdb[name].watch('/qubes-block-devices') self._qdb[name].watch('/qubes-block-devices')