CA-91927: Reduce the frequency of VM.allowed_operations updates.

When xapi receives a VM update from xenopsd, allowed_operations should
only be updated if a VM field which could affect the allowed_operations
was changed.

Signed-off-by: John Else <john.else@citrix.com>
Whitespace: Xapi_vdi.check_operation_error

$ camlp4o -printer o -no_comments ocaml/xapi/xapi_vdi| md5sum
089dfa0d238d159793ae1bd7e172d0d5  -
$ git checkout HEAD^
$ camlp4o -printer o -no_comments ocaml/xapi/xapi_vdi.ml | md5sum
089dfa0d238d159793ae1bd7e172d0d5  -

Signed-off-by: John Else <john.else@citrix.com>
CA-90263: Pass through a list of SR, PBD and VBD records to Xapi_vdi.check_operation_error

Signed-off-by: John Else <john.else@citrix.com>
CA-90263: Improve efficiency of Xapi_vdi.check_operation_error.

This changeset removes most of the database calls from this function,
assuming it is passed lists of SR, PBD and VBD records.

Signed-off-by: John Else <john.else@citrix.com>
CA-90263: Cache the return values of Helpers.is_tools_sr

Signed-off-by: John Else <john.else@citrix.com>
Whitespace: Cancel_tasks.update_all_allowed_operations.

$ camlp4o -printer o -no_comments ocaml/xapi/cancel_tasks.ml | md5sum
c2950b0075ab9d737e34ce8728258560  -
$ git checkout HEAD^
$ camlp4o -printer o -no_comments ocaml/xapi/cancel_tasks.ml | md5sum
c2950b0075ab9d737e34ce8728258560  -

Signed-off-by: John Else <john.else@citrix.com>
Rebased-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-90263: Improve efficiency of Cancel_tasks.update_all_allowed_operations.

Instead of calling Xapi_vdi.update_allowed_operations, call
Xapi_vdi.update_allowed_operations_internal and pass in cached lists of
SR, PBD and VBD records.

Signed-off-by: John Else <john.else@citrix.com>
Add timing stats to Cancel_tasks.update_all_allowed_operations

Signed-off-by: John Else <john.else@citrix.com>
Rebased-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Add timing stats to Db_gc.single_pass

Signed-off-by: John Else <john.else@citrix.com>
CA-90263: Don't get the SR UUID for each VDI when resynchronising VDI activations.

Signed-off-by: John Else <john.else@citrix.com>
CA-91927: Xapi_xenops event thread should update VM.allowed_operations on master instead of localhost.

Signed-off-by: John Else <john.else@citrix.com>
CA-90263: Remove the need to ever get an SR record as part of Xapi_vdi.check_operation_error

Signed-off-by: John Else <john.else@citrix.com>
CA-91931: Prevent spurious exceptions being raised by Event.from

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-91927: Reduce the number of times a guest agent updated causes an allowed-operations update

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-91930: Remove union of subscriptions between event.from invocations.

This fixes an issue whereby when parallel event.from calls were being
processed, each call would get the union of events meant for each. This
causes particular problems when XenCenter is connected as it registers
for _all_ events. Therefore any other calls made to event.from will
receive _all_ events whenever the GUI is connected. Additionally, as
there is no way to generate a token for 'now', this means that the
initial call to event.from will dump the _entire_ database, including
all the messages, requiring reading these from the disk.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-91930: Add some warning comments to make sure we don't regress this fix.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-92156: Revert commit 1c13665b2305d4a73be7422d1765a3ef3e27e09a

Caching is_tools_sr broke pool join - presumably because it cached
the result when the tools SR was there but didn't have the other-config
key marking it as such - the pool join subsequently failed due to
xapi thinking the slave-to-be had a shared SR.

The failure only seems to happen on first boot - any toolstack restart
flushes the cache and it gets repopulated correctly, making this quite
hard to test.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
CA-92156: Reapply the c/s that caused the problem with a fix.

The is_tools_sr cache is incorrect when the tools SR is introduced.
This is an attempt at a fix by simply clearing the cache after
dbsync_master might have introduced the tools SR.

Signed-off-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Merge pull request #875 from jonludlam/xop_issues