Exemple #1
0
static virDomainEventPtr
virDomainEventDiskChangeNew(int id, const char *name,
                            unsigned char *uuid,
                            const char *oldSrcPath,
                            const char *newSrcPath,
                            const char *devAlias, int reason)
{
    virDomainEventPtr ev =
        virDomainEventNewInternal(VIR_DOMAIN_EVENT_ID_DISK_CHANGE,
                                  id, name, uuid);

    if (ev) {
        if (!(ev->data.diskChange.devAlias = strdup(devAlias)))
            goto error;

        if (oldSrcPath &&
            !(ev->data.diskChange.oldSrcPath = strdup(oldSrcPath)))
            goto error;

        if (newSrcPath &&
            !(ev->data.diskChange.newSrcPath = strdup(newSrcPath)))
            goto error;

        ev->data.diskChange.reason = reason;
    }

    return ev;

error:
    virReportOOMError();
    virDomainEventFree(ev);
    return NULL;
}
Exemple #2
0
/**
 * virDomainEventQueueFree:
 * @queue: pointer to the queue
 *
 * Free the memory in the queue. We process this like a list here
 */
void
virDomainEventQueueFree(virDomainEventQueuePtr queue)
{
    int i;
    if (!queue)
        return;

    for (i = 0; i < queue->count ; i++) {
        virDomainEventFree(queue->events[i]);
    }
    VIR_FREE(queue->events);
    VIR_FREE(queue);
}
Exemple #3
0
static virDomainEventPtr
virDomainEventBlockJobNew(int id, const char *name, unsigned char *uuid,
                          const char *path, int type, int status)
{
    virDomainEventPtr ev =
        virDomainEventNewInternal(VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
                                  id, name, uuid);

    if (ev) {
        if (!(ev->data.blockJob.path = strdup(path))) {
            virReportOOMError();
            virDomainEventFree(ev);
            return NULL;
        }
        ev->data.blockJob.type = type;
        ev->data.blockJob.status = status;
    }

    return ev;
}
Exemple #4
0
static virDomainEventPtr virDomainEventIOErrorNewFromObjImpl(int event,
                                                             virDomainObjPtr obj,
                                                             const char *srcPath,
                                                             const char *devAlias,
                                                             int action,
                                                             const char *reason)
{
    virDomainEventPtr ev =
        virDomainEventNewInternal(event,
                                  obj->def->id, obj->def->name, obj->def->uuid);

    if (ev) {
        ev->data.ioError.action = action;
        if (!(ev->data.ioError.srcPath = strdup(srcPath)) ||
            !(ev->data.ioError.devAlias = strdup(devAlias)) ||
            (reason && !(ev->data.ioError.reason = strdup(reason)))) {
            virDomainEventFree(ev);
            ev = NULL;
        }
    }

    return ev;
}
Exemple #5
0
virDomainEventPtr virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
                                                   int phase,
                                                   virDomainEventGraphicsAddressPtr local,
                                                   virDomainEventGraphicsAddressPtr remote,
                                                   const char *authScheme,
                                                   virDomainEventGraphicsSubjectPtr subject)
{
    virDomainEventPtr ev =
        virDomainEventNewInternal(VIR_DOMAIN_EVENT_ID_GRAPHICS,
                                  obj->def->id, obj->def->name, obj->def->uuid);

    if (ev) {
        ev->data.graphics.phase = phase;
        if (!(ev->data.graphics.authScheme = strdup(authScheme))) {
            virDomainEventFree(ev);
            return NULL;
        }
        ev->data.graphics.local = local;
        ev->data.graphics.remote = remote;
        ev->data.graphics.subject = subject;
    }

    return ev;
}
Exemple #6
0
static virDomainEventPtr
virDomainEventTrayChangeNew(int id, const char *name,
                            unsigned char *uuid,
                            const char *devAlias,
                            int reason)
{
    virDomainEventPtr ev =
        virDomainEventNewInternal(VIR_DOMAIN_EVENT_ID_TRAY_CHANGE,
                                  id, name, uuid);

    if (ev) {
        if (!(ev->data.trayChange.devAlias = strdup(devAlias)))
            goto error;

        ev->data.trayChange.reason = reason;
    }

    return ev;

error:
    virReportOOMError();
    virDomainEventFree(ev);
    return NULL;
}