Event.next: lazily evaluate the snapshot

The database_callback was previously generating a snapshot
(eg VM.get_record) for every database write, and then throwing
it away in events_notify when no-one was registered.

- This is fixed by replacing 'snapshot' with 'snapshot_fn', a
  thunk which generates the snapshot

The database_callback snapshots sitting in the event.next queue
contain lots of duplicated data, since one field changes at a time.

- This is fixed by ensuring the 'snapshot_fn' captures the database
  in its closure, so all the duplicated data stays shared and is
  only expanded out into XML if the user requests it.

In a simple case where a VM changes name, each event was responsible
for about 160 extra heap words.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>