Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:olh:xen-4.9
libvirt
libvirt.xentoollog_logger_libvirt.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File libvirt.xentoollog_logger_libvirt.patch of Package libvirt
From: Olaf Hering <olaf@aepfle.de> Date: Thu, 22 Jul 2021 16:54:53 +0200 Subject: xentoollog_logger_libvirt Signed-off-by: Olaf Hering <olaf@aepfle.de> --- src/libxl/libxl_conf.c | 2 +- src/libxl/libxl_logger.c | 39 +++++---- src/libxl/libxl_logger.h | 3 +- 3 files changed, 26 insertions(+), 18 deletions(-) --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1803,25 +1803,25 @@ libxlDriverConfigNew(void) int libxlDriverConfigInit(libxlDriverConfig *cfg) { uint64_t free_mem; if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) { virReportSystemError(errno, _("failed to create log dir '%1$s'"), cfg->logDir); return -1; } - cfg->logger = libxlLoggerNew(cfg->logDir, virLogGetDefaultPriority()); + cfg->logger = libxlLoggerNew(cfg->logDir); if (!cfg->logger) { VIR_ERROR(_("cannot create logger for libxenlight, disabling driver")); return -1; } if (libxl_ctx_alloc(&cfg->ctx, LIBXL_VERSION, 0, (xentoollog_logger *)cfg->logger)) { VIR_ERROR(_("cannot initialize libxenlight context, probably not running in a Xen Dom0, disabling driver")); return -1; } if ((cfg->verInfo = libxl_get_version_info(cfg->ctx)) == NULL) { VIR_ERROR(_("cannot version information from libxenlight, disabling driver")); --- a/src/libxl/libxl_logger.c +++ b/src/libxl/libxl_logger.c @@ -19,24 +19,25 @@ */ #include <config.h> #include <libxl.h> #include "internal.h" #include "libxl_logger.h" #include "util/viralloc.h" #include "util/virfile.h" #include "util/virhash.h" #include "util/virthread.h" #include "util/virtime.h" +#include "virstring.h" #define VIR_FROM_THIS VIR_FROM_LIBXL VIR_LOG_INIT("libxl.libxl_logger"); typedef struct xentoollog_logger_libvirt xentoollog_logger_libvirt; struct xentoollog_logger_libvirt { xentoollog_logger vtable; xentoollog_level minLevel; const char *logDir; @@ -121,43 +122,51 @@ libvirt_progress(xentoollog_logger *logger_in G_GNUC_UNUSED, /* This function purposedly does nothing: it's no logging info */ } static void libvirt_destroy(xentoollog_logger *logger_in) { xentoollog_logger_libvirt *lg = (xentoollog_logger_libvirt*)logger_in; VIR_FREE(lg); } libxlLogger * -libxlLoggerNew(const char *logDir, virLogPriority minLevel) +libxlLoggerNew(const char *logDir) { xentoollog_logger_libvirt logger; g_autofree char *path = NULL; - - switch (minLevel) { - case VIR_LOG_DEBUG: - logger.minLevel = XTL_DEBUG; - break; - case VIR_LOG_INFO: - logger.minLevel = XTL_INFO; - break; - case VIR_LOG_WARN: - logger.minLevel = XTL_WARN; - break; - case VIR_LOG_ERROR: - logger.minLevel = XTL_ERROR; - break; + char *xenlight_minlevel = getenv("xenlight_minlevel"); + int minlevel; + + if (!(xenlight_minlevel && *xenlight_minlevel && + virStrToLong_i(xenlight_minlevel, NULL, 10, &minlevel) >= 0 && + minlevel > XTL_NONE && minlevel < XTL_NUM_LEVELS)) { + minlevel = virLogGetDefaultPriority(); + switch (minlevel) { + case VIR_LOG_DEBUG: + minlevel = XTL_DEBUG; + break; + case VIR_LOG_INFO: + minlevel = XTL_INFO; + break; + case VIR_LOG_WARN: + minlevel = XTL_WARN; + break; + case VIR_LOG_ERROR: + minlevel = XTL_ERROR; + break; + } } + logger.minLevel = minlevel; logger.logDir = logDir; path = g_strdup_printf("%s/libxl-driver.log", logDir); if ((logger.defaultLogFile = fopen(path, "a")) == NULL) return NULL; if (virMutexInit(&logger.tableLock) < 0) { VIR_FORCE_FCLOSE(logger.defaultLogFile); return NULL; } --- a/src/libxl/libxl_logger.h +++ b/src/libxl/libxl_logger.h @@ -15,19 +15,18 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. */ #pragma once #include "util/virlog.h" typedef struct xentoollog_logger_libvirt libxlLogger; -libxlLogger *libxlLoggerNew(const char *logDir, - virLogPriority minLevel); +libxlLogger *libxlLoggerNew(const char *logDir); void libxlLoggerFree(libxlLogger *logger); void libxlLoggerOpenFile(libxlLogger *logger, int id, const char *name, const char *domain_config); void libxlLoggerCloseFile(libxlLogger *logger, int id);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor