}
+/**
+ * qemuMonitorJSONValidateEventHandlers:
+ *
+ * Used by 'qemumonitorjsontest' to validate that the 'eventHandlers' array
+ * is properly sorted to use 'bsearch'.
+ */
+char *
+qemuMonitorJSONValidateEventHandlers(void)
+{
+ size_t i;
+
+ for (i = 1; i < G_N_ELEMENTS(eventHandlers); i++) {
+ if (strcmp(eventHandlers[i-1].type, eventHandlers[i].type) > -1)
+ return g_strdup_printf("mis-ordered 'eventHandlers': '%s', '%s'",
+ eventHandlers[i-1].type, eventHandlers[i].type);
+ }
+
+ return NULL;
+}
+
+
static int
qemuMonitorJSONIOProcessEvent(qemuMonitor *mon,
virJSONValue *obj)
}
+static int
+testEventHandlersOrdering(const void *opaque G_GNUC_UNUSED)
+{
+ g_autofree char *errmsg = NULL;
+
+ if ((errmsg = qemuMonitorJSONValidateEventHandlers())) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", errmsg);
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
mymain(void)
{
qapiData.schema = qapischema_x86_64;
+ if (virTestRun("'eventHandlers' ordering check", testEventHandlersOrdering,
+ NULL) < 0)
+ ret = -1;
+
#define DO_TEST(name) \
do { \
testGenericData data = { driver.xmlopt, qapiData.schema }; \