Francesco Romani has uploaded a new change for review. Change subject: guest manager: use the attachMonitor API ......................................................................
guest manager: use the attachMonitor API This patch make use of the new attachMonitor API. Fallback code is added to preserve the old behaviour if the hypervisor does not support the new API. Change-Id: Ib9475ad4405f08a9a90557b2ea7ecc32d5f1a657 Signed-off-by: Francesco Romani <[email protected]> --- M mom/GuestManager.py 1 file changed, 26 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/93/31593/1 diff --git a/mom/GuestManager.py b/mom/GuestManager.py index 5aa50c3..badeddb 100644 --- a/mom/GuestManager.py +++ b/mom/GuestManager.py @@ -51,14 +51,14 @@ "can't start", id) continue guest = GuestMonitor(self.config, info, self.hypervisor_iface) - guest.start() - if guest.isAlive(): - self.guests_sem.acquire() - if id not in self.guests: - self.guests[id] = guest - else: - del guest - self.guests_sem.release() + if self.hypervisor_iface.attachMonitor(id, guest.collect, + guest.interval): + self._register_guest(guest) + else: + t = GuestMonitorThread(info, guest) + t.start() + if guest.isAlive(): + self._register_guest(guest, t) def wait_for_guest_monitors(self): """ @@ -66,14 +66,23 @@ """ while True: with self.guests_sem: - if len(self.guests) > 0: - (id, thread) = self.guests.popitem() + if self.guests + (id, (mon, thread)) = self.guests.popitem() else: - id = None + id, thread = None, None if id is not None: - thread.join(0) + if thread is not None: + thread.join(0) else: break + + def _register_guest(self, guest, thread=None): + self.guests_sem.acquire() + if id not in self.guests: + self.guests[id] = (guest, thread) + else: + del guest + self.guests_sem.release() def check_threads(self, domain_list): """ @@ -81,6 +90,9 @@ """ with self.guests_sem: for (id, (mon, thread)) in self.guests.items(): + if thread is None: + # no thread to babysit + continue # Check if the thread has died if not thread.isAlive(): del self.guests[id] @@ -96,7 +108,7 @@ """ ret = {} with self.guests_sem: - for (id, monitor) in self.guests.items(): + for (id, (monitor, thread)) in self.guests.items(): entity = monitor.interrogate() if entity is not None: ret[id] = entity @@ -121,7 +133,7 @@ def rpc_get_active_guests(self): ret = [] with self.guests_sem: - for (id, monitor) in self.guests.items(): + for (id, (monitor, thread)) in self.guests.items(): if monitor.isReady(): name = monitor.getGuestName() if name is not None: -- To view, visit http://gerrit.ovirt.org/31593 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib9475ad4405f08a9a90557b2ea7ecc32d5f1a657 Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
