static void * virDomainEventNew(virClassPtr klass, int eventID, int id, const char *name, const unsigned char *uuid) { virDomainEventPtr event; if (virDomainEventsInitialize() < 0) return NULL; if (!virClassIsDerivedFrom(klass, virDomainEventClass)) { virReportInvalidArg(klass, _("Class %s must derive from virDomainEvent"), virClassName(klass)); return NULL; } if (!(event = virObjectEventNew(klass, virDomainEventDispatchDefaultFunc, eventID, id, name, uuid))) return NULL; return (virObjectEventPtr)event; }
/** * virObjectEventNew: * @klass: subclass of event to be created * @dispatcher: callback for dispatching the particular subclass of event * @eventID: id of the event * @id: id of the object the event describes, or 0 * @name: name of the object the event describes * @uuid: uuid of the object the event describes * @key: key for per-object filtering * * Create a new event, with the information common to all events. */ void * virObjectEventNew(virClassPtr klass, virObjectEventDispatchFunc dispatcher, int eventID, int id, const char *name, const unsigned char *uuid, const char *key) { virObjectEventPtr event; if (virObjectEventInitialize() < 0) return NULL; if (!virClassIsDerivedFrom(klass, virObjectEventClass)) { virReportInvalidArg(klass, _("Class %s must derive from virObjectEvent"), virClassName(klass)); return NULL; } if (!(event = virObjectNew(klass))) return NULL; event->dispatch = dispatcher; event->eventID = eventID; event->remoteID = -1; if (VIR_STRDUP(event->meta.name, name) < 0 || VIR_STRDUP(event->meta.key, key) < 0) { virObjectUnref(event); return NULL; } event->meta.id = id; if (uuid) memcpy(event->meta.uuid, uuid, VIR_UUID_BUFLEN); VIR_DEBUG("obj=%p", event); return event; }