qubeswatch: use always "dom0" name for dom0

Libvirt reports dom0 as "Domain-0". Which is incompatible with how Qubes
and libxl toolstack names it ("dom0"). So handle this as a special case.
Otherwise reconnection retries leaks event object every iteration.

Fixes QubesOS/qubes-issues#860
Thanks @alex-mazzariol for help with debugging!
This commit is contained in:
Marek Marczykowski-Górecki 2016-07-01 12:11:13 +02:00
parent 78437f7012
commit 7e9c816b7b
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -729,6 +729,10 @@ class QubesWatch(object):
return '/local/domain/%s/memory/meminfo' % xid
def _register_watches(self, libvirt_domain):
if libvirt_domain and libvirt_domain.ID() == 0:
# don't use libvirt object for dom0, to always have the same
# hardcoded "dom0" name
libvirt_domain = None
if libvirt_domain:
name = libvirt_domain.name()
if name in self._qdb:
@ -769,7 +773,10 @@ class QubesWatch(object):
self._register_watches(libvirt_domain)
def _unregister_watches(self, libvirt_domain):
name = libvirt_domain.name()
if libvirt_domain and libvirt_domain.ID() == 0:
name = "dom0"
else:
name = libvirt_domain.name()
if name in self._qdb_events:
libvirt.virEventRemoveHandle(self._qdb_events[name])
del(self._qdb_events[name])