#include "logging.h"
#include "datatypes.h"
#include "memory.h"
+#include "virterror_internal.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+#define eventReportError(conn, code, fmt...) \
+ virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, fmt)
/**
return 0;
}
}
+
+ eventReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not find event callback for removal"));
return -1;
}
return 0;
}
}
+
+ eventReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not find event callback for deletion"));
return -1;
}
for (n=0; n < cbList->count; n++) {
if(cbList->callbacks[n]->cb == callback &&
conn == cbList->callbacks[n]->conn) {
- DEBUG0("WARNING: Callback already tracked");
+ eventReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("event callback already tracked"));
return -1;
}
}
/* Allocate new event */
if (VIR_ALLOC(event) < 0) {
- DEBUG0("Error allocating event");
+ virReportOOMError(conn);
return -1;
}
event->conn = conn;
/* Make space on list */
n = cbList->count;
if (VIR_REALLOC_N(cbList->callbacks, n + 1) < 0) {
- DEBUG0("Error reallocating list");
+ virReportOOMError(conn);
VIR_FREE(event);
return -1;
}
{
virDomainEventQueuePtr ret;
- if (VIR_ALLOC(ret) < 0)
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError(NULL);
return NULL;
+ }
return ret;
}
{
virDomainEventPtr event;
- if (VIR_ALLOC(event) < 0)
+ if (VIR_ALLOC(event) < 0) {
+ virReportOOMError(NULL);
return NULL;
+ }
event->type = type;
event->detail = detail;
if (!(event->name = strdup(name))) {
+ virReportOOMError(NULL);
VIR_FREE(event);
return NULL;
}
{
virDomainEventPtr ret;
- if(!evtQueue || evtQueue->count == 0 )
+ if (!evtQueue || evtQueue->count == 0 ) {
+ eventReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("event queue is empty, nothing to pop"));
return NULL;
+ }
ret = evtQueue->events[0];
/* Make space on queue */
if (VIR_REALLOC_N(evtQueue->events,
evtQueue->count + 1) < 0) {
- DEBUG0("Error reallocating queue");
+ virReportOOMError(NULL);
return -1;
}