+static size_t close_callback_called = 0;
+
+/* This callback deletes all test keys in the handle. */
+static void
+close_callback (guestfs_h *g,
+ void *opaque,
+ uint64_t event,
+ int event_handle,
+ int flags,
+ const char *buf, size_t buf_len,
+ const uint64_t *array, size_t array_len)
+{
+ const char *key;
+ void *data;
+
+ close_callback_called++;
+
+ again:
+ data = guestfs_first_private (g, &key);
+ while (data != NULL) {
+ if (strncmp (key, PREFIX, strlen (PREFIX)) == 0) {
+ guestfs_set_private (g, key, NULL);
+ goto again;
+ }
+ data = guestfs_next_private (g, &key);
+ }
+}
+