Ejemplo n.º 1
0
Archivo: core.c Proyecto: 0day-ci/xen
xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger,
                                               unsigned open_flags)
{
    xenforeignmemory_handle *fmem = malloc(sizeof(*fmem));
    int rc;

    if (!fmem) return NULL;

    fmem->fd = -1;
    fmem->logger = logger;
    fmem->logger_tofree = NULL;

    if (!fmem->logger) {
        fmem->logger = fmem->logger_tofree =
            (xentoollog_logger*)
            xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0);
        if (!fmem->logger) goto err;
    }

    rc = osdep_xenforeignmemory_open(fmem);
    if ( rc  < 0 ) goto err;

    return fmem;

err:
    osdep_xenforeignmemory_close(fmem);
    xtl_logger_destroy(fmem->logger_tofree);
    free(fmem);
    return NULL;
}
Ejemplo n.º 2
0
int vchan_send(struct libxenvchan * chan, char * message, int size){
  xentoollog_logger_stdiostream * logger =  createDebugLogger();

  int res =  sendChunkedMessage((xentoollog_logger *)logger, chan, message, size);
  xtl_logger_destroy((xentoollog_logger *)logger);
  return res;
}
Ejemplo n.º 3
0
Archivo: core.c Proyecto: 0day-ci/xen
xenevtchn_handle *xenevtchn_open(xentoollog_logger *logger, unsigned open_flags)
{
    xenevtchn_handle *xce = malloc(sizeof(*xce));
    int rc;

    if (!xce) return NULL;

    xce->fd = -1;
    xce->logger = logger;
    xce->logger_tofree  = NULL;

    if (!xce->logger) {
        xce->logger = xce->logger_tofree =
            (xentoollog_logger*)
            xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0);
        if (!xce->logger) goto err;
    }

    rc = osdep_evtchn_open(xce);
    if ( rc  < 0 ) goto err;

    return xce;

err:
    osdep_evtchn_close(xce);
    xtl_logger_destroy(xce->logger_tofree);
    free(xce);
    return NULL;
}
Ejemplo n.º 4
0
char * vchan_receive(struct libxenvchan * chan, int* size){
  xentoollog_logger_stdiostream * logger =  createDebugLogger();

  char * msg=readChunkedMessage((xentoollog_logger *)logger,chan,size); 

  xtl_logger_destroy((xentoollog_logger *)logger);
  return msg;
}
Ejemplo n.º 5
0
static int xc_interface_close_common(xc_interface *xch)
{
    int rc = 0;

    if (!xch)
	return 0;

    xc__hypercall_buffer_cache_release(xch);

    xtl_logger_destroy(xch->dombuild_logger_tofree);
    xtl_logger_destroy(xch->error_handler_tofree);

    rc = xch->ops->close(xch, xch->ops_handle);
    if (rc) PERROR("Could not close hypervisor interface");

    free(xch);
    return rc;
}
Ejemplo n.º 6
0
struct xc_interface_core *xc_interface_open(xentoollog_logger *logger,
                                            xentoollog_logger *dombuild_logger,
                                            unsigned open_flags)
{
    struct xc_interface_core xch_buf = { 0 }, *xch = &xch_buf;

    xch->flags = open_flags;
    xch->dombuild_logger_file = 0;
    xc_clear_last_error(xch);

    xch->error_handler   = logger;           xch->error_handler_tofree   = 0;
    xch->dombuild_logger = dombuild_logger;  xch->dombuild_logger_tofree = 0;

    if (!xch->error_handler) {
        xch->error_handler = xch->error_handler_tofree =
            (xentoollog_logger*)
            xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0);
        if (!xch->error_handler)
            goto err;
    }

    xch = malloc(sizeof(*xch));
    if (!xch) {
        xch = &xch_buf;
        PERROR("Could not allocate new xc_interface struct");
        goto err;
    }
    *xch = xch_buf;

    if (open_flags & XC_OPENFLAG_DUMMY)
        return xch; /* We are done */

    xch->xcall = xencall_open(xch->error_handler,
        open_flags & XC_OPENFLAG_NON_REENTRANT ? XENCALL_OPENFLAG_NON_REENTRANT : 0U);
    if ( xch->xcall == NULL )
        goto err;

    xch->fmem = xenforeignmemory_open(xch->error_handler, 0);
    if ( xch->fmem == NULL )
        goto err;

    xch->dmod = xendevicemodel_open(xch->error_handler, 0);
    if ( xch->dmod == NULL )
        goto err;

    return xch;

 err:
    xenforeignmemory_close(xch->fmem);
    xencall_close(xch->xcall);
    xtl_logger_destroy(xch->error_handler_tofree);
    if (xch != &xch_buf) free(xch);
    return NULL;
}
Ejemplo n.º 7
0
void xen_free_interface(xen_interface_t* xen) {
    if (xen) {
        if (xen->xl_ctx)
            libxl_ctx_free(xen->xl_ctx);
        if (xen->xl_logger)
            xtl_logger_destroy(xen->xl_logger);
        //if (xen->xsh) xs_close(xen->xsh);
        if (xen->xc)
            xc_interface_close(xen->xc);
        free(xen);
    }
}
Ejemplo n.º 8
0
Archivo: core.c Proyecto: 0day-ci/xen
int xenforeignmemory_close(xenforeignmemory_handle *fmem)
{
    int rc;

    if ( !fmem )
        return 0;

    rc = osdep_xenforeignmemory_close(fmem);
    xtl_logger_destroy(fmem->logger_tofree);
    free(fmem);
    return rc;
}
Ejemplo n.º 9
0
Archivo: core.c Proyecto: 0day-ci/xen
int xenevtchn_close(xenevtchn_handle *xce)
{
    int rc;

    if ( !xce )
        return 0;

    rc = osdep_evtchn_close(xce);
    xtl_logger_destroy(xce->logger_tofree);
    free(xce);
    return rc;
}
Ejemplo n.º 10
0
int xc_interface_close(xc_interface *xch)
{
    int rc = 0;

    if (!xch)
        return 0;

    rc = xencall_close(xch->xcall);
    if (rc) PERROR("Could not close xencall interface");

    rc = xenforeignmemory_close(xch->fmem);
    if (rc) PERROR("Could not close foreign memory interface");

    rc = xendevicemodel_close(xch->dmod);
    if (rc) PERROR("Could not close device model interface");

    xtl_logger_destroy(xch->dombuild_logger_tofree);
    xtl_logger_destroy(xch->error_handler_tofree);

    free(xch);
    return rc;
}
Ejemplo n.º 11
0
Archivo: core.c Proyecto: royger/xen
int xendevicemodel_close(xendevicemodel_handle *dmod)
{
    int rc;

    if (!dmod)
        return 0;

    rc = osdep_xendevicemodel_close(dmod);

    xencall_close(dmod->xcall);
    xtl_logger_destroy(dmod->logger_tofree);
    free(dmod);
    return rc;
}
Ejemplo n.º 12
0
Archivo: xl.c Proyecto: Chong-Li/xen
static void xl_ctx_free(void)
{
    if (ctx) {
        libxl_ctx_free(ctx);
        ctx = NULL;
    }
    if (logger) {
        xtl_logger_destroy((xentoollog_logger*)logger);
        logger = NULL;
    }
    if (lockfile) {
        free(lockfile);
        lockfile = NULL;
    }
}
Ejemplo n.º 13
0
static void
libxlDriverConfigDispose(void *obj)
{
    libxlDriverConfigPtr cfg = obj;

    virObjectUnref(cfg->caps);
    libxl_ctx_free(cfg->ctx);
    xtl_logger_destroy(cfg->logger);
    if (cfg->logger_file)
        VIR_FORCE_FCLOSE(cfg->logger_file);

    VIR_FREE(cfg->configDir);
    VIR_FREE(cfg->autostartDir);
    VIR_FREE(cfg->logDir);
    VIR_FREE(cfg->stateDir);
    VIR_FREE(cfg->libDir);
    VIR_FREE(cfg->saveDir);
}
Ejemplo n.º 14
0
Archivo: core.c Proyecto: royger/xen
xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger,
                                           unsigned open_flags)
{
    xendevicemodel_handle *dmod = calloc(1, sizeof(*dmod));
    int rc;

    if (!dmod)
        return NULL;

    dmod->flags = open_flags;
    dmod->logger = logger;
    dmod->logger_tofree = NULL;

    if (!dmod->logger) {
        dmod->logger = dmod->logger_tofree =
            (xentoollog_logger*)
            xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0);
        if (!dmod->logger)
            goto err;
    }

    dmod->xcall = xencall_open(dmod->logger, 0);
    if (!dmod->xcall)
        goto err;

    rc = osdep_xendevicemodel_open(dmod);
    if (rc)
        goto err;

    return dmod;

err:
    xtl_logger_destroy(dmod->logger_tofree);
    xencall_close(dmod->xcall);
    free(dmod);
    return NULL;
}
Ejemplo n.º 15
0
int  hyperxl_initialize_driver(hyperxl_driver** pdriver, bool verbose) {

#ifndef LIBXL_HAVE_BUILDINFO_KERNEL

    return -1;

#else

    hyperxl_driver *driver;
    const libxl_version_info* version = NULL;
    uint32_t mem = 0;
    xentoollog_level log_level = XTL_INFO;

    *pdriver = (hyperxl_driver*)malloc(sizeof(hyperxl_driver));
    if ( *pdriver == NULL ) {
        return -1;
    }

    driver = *pdriver;

    if (verbose) {
        log_level = XTL_DEBUG;
    }
    driver->logger = (xentoollog_logger*)xtl_createlogger_hyperxl(log_level, 0);
    if (driver->logger == NULL) {
        goto release_driver;
    }

    if(libxl_ctx_alloc(&driver->ctx, LIBXL_VERSION, 0, driver->logger)) {
        goto close_logger;
    }

    libxl_childproc_setmode(driver->ctx, &libxl_child_hooks, driver->ctx);

    version = libxl_get_version_info(driver->ctx);
    if (version == NULL) {
        goto free_ctx;
    }

    driver->version = version->xen_version_major * 1000000 + version->xen_version_minor * 1000;
    driver->capabilities = strdup(version->capabilities);

    if(libxl_get_free_memory(driver->ctx, &mem)) {
        goto free_ctx;
    }

    libxl_event_register_callbacks(driver->ctx, &ev_hooks, driver);

    return 0;

free_ctx:
    libxl_ctx_free(driver->ctx);
close_logger:
    xtl_logger_destroy(driver->logger);
release_driver:
    free(driver);
    driver = NULL;
    return -1;

#endif //LIBXL_HAVE_BUILDINFO_KERNEL
}
Ejemplo n.º 16
0
static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *logger,
                                                          xentoollog_logger *dombuild_logger,
                                                          unsigned open_flags,
                                                          enum xc_osdep_type type)
{
    struct xc_interface_core xch_buf, *xch = &xch_buf;

    xch->type = type;
    xch->flags = open_flags;
    xch->dombuild_logger_file = 0;
    xc_clear_last_error(xch);

    xch->error_handler   = logger;           xch->error_handler_tofree   = 0;
    xch->dombuild_logger = dombuild_logger;  xch->dombuild_logger_tofree = 0;

    xch->hypercall_buffer_cache_nr = 0;

    xch->hypercall_buffer_total_allocations = 0;
    xch->hypercall_buffer_total_releases = 0;
    xch->hypercall_buffer_current_allocations = 0;
    xch->hypercall_buffer_maximum_allocations = 0;
    xch->hypercall_buffer_cache_hits = 0;
    xch->hypercall_buffer_cache_misses = 0;
    xch->hypercall_buffer_cache_toobig = 0;

    xch->ops_handle = XC_OSDEP_OPEN_ERROR;
    xch->ops = NULL;

    if (!xch->error_handler) {
        xch->error_handler = xch->error_handler_tofree =
            (xentoollog_logger*)
            xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0);
        if (!xch->error_handler)
            goto err;
    }

    xch = malloc(sizeof(*xch));
    if (!xch) {
        xch = &xch_buf;
        PERROR("Could not allocate new xc_interface struct");
        goto err;
    }
    *xch = xch_buf;

    if (!(open_flags & XC_OPENFLAG_DUMMY)) {
        if ( xc_osdep_get_info(xch, &xch->osdep) < 0 )
            goto err;

        xch->ops = xch->osdep.init(xch, type);
        if ( xch->ops == NULL )
        {
            DPRINTF("OSDEP: interface %d (%s) not supported on this platform",
                  type, xc_osdep_type_name(type));
            goto err_put_iface;
        }

        xch->ops_handle = xch->ops->open(xch);
        if (xch->ops_handle == XC_OSDEP_OPEN_ERROR)
            goto err_put_iface;
    }

    return xch;

err_put_iface:
    xc_osdep_put(&xch->osdep);
 err:
    xtl_logger_destroy(xch->error_handler_tofree);
    if (xch != &xch_buf) free(xch);
    return NULL;
}