[virt-tools-list] Failure to update CPU usage display
Charles Arnold
carnold at suse.com
Wed Apr 1 21:42:14 UTC 2015
Under certain conditions I see the guest CPU usage display not
being updated. The problem seems most prevalent when Xen
is the underlying hypervisor but I have seen it occasionally with
KVM.
What appears to be happening is that when a VM is created, the
engine's _handle_tick_queue() calls the connection tick() method
which in turn calls _tick(). In here it calls _update_vms() which
gets a new vmmDomain object. Then it spawns a new thread to
call tick_send_signals() where if 'pollvm' is True then 'self._vms'
will get the newly create vmmDomain object.
The problem (I think) is that under certain conditions the thread
spun up by self.idle_add(tick_send_signals) doesn't run quickly
enough (and therefore doesn't set self._vms) until after _tick() returns
and is called again and second vmmDomain object is created.
At this point it appears that the first vmmDomain object collects the
cpu stats from libvirt while the second vmmDomain object updates
the display which doesn't have the stats and therefore nothing appears.
Below are a couple approaches to solving the problem (assuming
my analysis is correct). This first one simply yields to give the
tick_send_signals thread a chance to run.
diff --git a/virtManager/connection.py b/virtManager/connection.py
index a907a3f..af27141 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -1240,6 +1240,9 @@ class vmmConnection(vmmGObject):
self._change_state(self._STATE_ACTIVE)
self.idle_add(tick_send_signals)
+ if len(self._vms) < len(vms):
+ # Allow time for tick_send_signals to run
+ time.sleep(.1)
ticklist = []
def add_to_ticklist(l, args=()):
This second solution doesn't wait for the thread and sets self._vms
if pollvm is True.
diff --git a/virtManager/connection.py b/virtManager/connection.py
index a907a3f..96c208e 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -1240,6 +1240,8 @@ class vmmConnection(vmmGObject):
self._change_state(self._STATE_ACTIVE)
self.idle_add(tick_send_signals)
+ if pollvm:
+ self._vms = vms
ticklist = []
def add_to_ticklist(l, args=()):
Any thoughts on this problem and the potential solutions?
- Charles
More information about the virt-tools-list
mailing list