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); } }
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; } }
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); }
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 }