return rc;
}
+/*
+ * immediate non-reentrant callback
+ */
+
+void libxl__ev_immediate_register(libxl__egc *egc, libxl__ev_immediate *ei)
+{
+ LIBXL_STAILQ_INSERT_TAIL(&egc->ev_immediates, ei, entry);
+}
+
/*
* domain death/destruction
*/
EGC_GC;
libxl_event *ev, *ev_tmp;
libxl__aop_occurred *aop, *aop_tmp;
+ libxl__ev_immediate *ei;
+
+ while (!LIBXL_STAILQ_EMPTY(&egc->ev_immediates)) {
+ ei = LIBXL_STAILQ_FIRST(&egc->ev_immediates);
+ LIBXL_STAILQ_REMOVE_HEAD(&egc->ev_immediates, entry);
+ CTX_LOCK;
+ /* This callback is internal to libxl and expects CTX to be
+ * locked. */
+ ei->callback(egc, ei);
+ CTX_UNLOCK;
+ }
LIBXL_TAILQ_FOREACH_SAFE(ev, &egc->occurred_for_callback, link, ev_tmp) {
LIBXL_TAILQ_REMOVE(&egc->occurred_for_callback, ev, link);
typedef struct libxl__dm_resume_state libxl__dm_resume_state;
typedef struct libxl__ao_device libxl__ao_device;
typedef struct libxl__multidev libxl__multidev;
+typedef struct libxl__ev_immediate libxl__ev_immediate;
typedef struct libxl__domain_create_state libxl__domain_create_state;
typedef void libxl__domain_create_cb(struct libxl__egc *egc,
LIBXL_LIST_ENTRY(struct libxl__ev_child) entry;
};
+/* libxl__ev_immediate
+ *
+ * Allow to call a non-reentrant callback.
+ *
+ * `callback' will be called immediately as a new event.
+ */
+struct libxl__ev_immediate {
+ /* filled by user */
+ void (*callback)(libxl__egc *, libxl__ev_immediate *);
+ /* private to libxl__ev_immediate */
+ LIBXL_STAILQ_ENTRY(libxl__ev_immediate) entry;
+};
+void libxl__ev_immediate_register(libxl__egc *, libxl__ev_immediate *);
+
/*
* Lock for device hotplug, qmp_lock.
*
struct libxl__event_list occurred_for_callback;
LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback;
LIBXL_TAILQ_HEAD(, libxl__aop_occurred) aops_for_callback;
+ LIBXL_STAILQ_HEAD(, libxl__ev_immediate) ev_immediates;
};
struct libxl__aop_occurred {
LIBXL_TAILQ_INIT(&(egc).occurred_for_callback); \
LIBXL_TAILQ_INIT(&(egc).aos_for_callback); \
LIBXL_TAILQ_INIT(&(egc).aops_for_callback); \
+ LIBXL_STAILQ_INIT(&(egc).ev_immediates); \
} while(0)
_hidden void libxl__egc_cleanup(libxl__egc *egc);