From ed5e67485c30eb4a9c7cfd46099fd502b652238b Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 7 Jul 2013 08:12:15 -0400 Subject: [PATCH] domain: Don't pass timestamp to domain tick() Since we might not poll stats info until a decent amount of time after this timestamp, it messes up VM stats reporting. Our usage still isn't correct because we use a later timestamp for calculating total host usage. We could fix it by averaging out the timestamp of each VM but I don't care that much at the moment. --- virtManager/connection.py | 9 ++++----- virtManager/domain.py | 6 ++---- virtManager/libvirtobject.py | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/virtManager/connection.py b/virtManager/connection.py index 022d84f7e..eda4d909a 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -1223,14 +1223,12 @@ class vmmConnection(vmmGObject): self.idle_add(tick_send_signals) - now = time.time() - ticklist = [] def add_to_ticklist(l, args=()): ticklist.extend([(o, args) for o in l.values()]) updateVMs = noStatsUpdate and newVMs or vms - add_to_ticklist(updateVMs, (now,)) + add_to_ticklist(updateVMs) add_to_ticklist(noStatsUpdate and newNets or nets) add_to_ticklist(noStatsUpdate and newPools or pools) add_to_ticklist(noStatsUpdate and newInterfaces or interfaces) @@ -1251,15 +1249,16 @@ class vmmConnection(vmmGObject): "Ignoring.") if not noStatsUpdate: - self._recalculate_stats(now, updateVMs.values()) + self._recalculate_stats(updateVMs.values()) self.idle_emit("resources-sampled") return 1 - def _recalculate_stats(self, now, vms): + def _recalculate_stats(self, vms): if not self._backend.is_open(): return + now = time.time() expected = self.config.get_stats_history_length() current = len(self.record) if current > expected: diff --git a/virtManager/domain.py b/virtManager/domain.py index 6d884eca6..8fa76b62f 100644 --- a/virtManager/domain.py +++ b/virtManager/domain.py @@ -1713,10 +1713,7 @@ class vmmDomain(vmmLibvirtObject): return rd, wr - def tick(self, now=None): - if now is None: - now = time.time() - + def tick(self): # Invalidate cached values self._invalidate_xml() @@ -1734,6 +1731,7 @@ class vmmDomain(vmmLibvirtObject): self.is_management_domain()): info[1] = self.conn.host_memory_size() + now = time.time() (cpuTime, cpuTimeAbs, pcentHostCpu, pcentGuestCpu) = self._sample_cpu_stats(info, now) pcentCurrMem, curmem = self._sample_mem_stats(info) diff --git a/virtManager/libvirtobject.py b/virtManager/libvirtobject.py index ec761ffa1..0c5f00098 100644 --- a/virtManager/libvirtobject.py +++ b/virtManager/libvirtobject.py @@ -79,8 +79,8 @@ class vmmLibvirtObject(vmmGObject): ignore = xml return - def tick(self, now): - ignore = now + def tick(self): + pass ##################