connection: Fix race when updating conn.vms

We update the canonical conn.vms list in an idle callback, so any parts
of the main UI thread won't see the conn.vms change while they are
iterating over it.

Problem with this, is that if multiple ticks() are scheduled before
the first idle handler has a chance to run, we can overwrite the VM
list can fail to be correctly updated.

Fix this by only updating 'vms' if it actually changed.
This commit is contained in:
Cole Robinson 2014-02-13 11:11:21 -05:00
parent 078e1a4d05
commit 3f27bc1bd1

View File

@ -1160,11 +1160,16 @@ class vmmConnection(vmmGObject):
if not self._backend.is_open(): if not self._backend.is_open():
return return
if pollvm:
self.vms = vms self.vms = vms
self.nodedevs = nodedevs if pollnet:
self.interfaces = interfaces
self.pools = pools
self.nets = nets self.nets = nets
if polliface:
self.interfaces = interfaces
if pollpool:
self.pools = pools
if pollnodedev:
self.nodedevs = nodedevs
# Make sure device polling is setup # Make sure device polling is setup
if not self.netdev_initialized: if not self.netdev_initialized: