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.
This commit is contained in:
Cole Robinson 2013-07-07 08:12:15 -04:00
parent b7ee86541d
commit ed5e67485c
3 changed files with 8 additions and 11 deletions

View File

@ -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:

View File

@ -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)

View File

@ -79,8 +79,8 @@ class vmmLibvirtObject(vmmGObject):
ignore = xml
return
def tick(self, now):
ignore = now
def tick(self):
pass
##################