Hi, currently every monitor command is dumped into the domain logfiles, this can lead to huge logs[1]. Since we're not going through the normal logging facilites to get per domain logfiles we should at least resepct the default priority. Cheers, -- Guido [1] http://bugs.debian.org/524145
>From 53264a3ee26ab57bf37f2fe26208513428553c03 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx@xxxxxxxxxxx> Date: Thu, 16 Apr 2009 14:08:33 +0200 Subject: [PATCH] only log qemu monitor commands if default log priority is VIR_LOG_DEBUG --- src/libvirt_debug.syms | 1 + src/logging.c | 9 +++++++++ src/logging.h | 2 ++ src/qemu_driver.c | 27 +++++++++++++++------------ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/libvirt_debug.syms b/src/libvirt_debug.syms index 1742a0b..e2e0dbd 100644 --- a/src/libvirt_debug.syms +++ b/src/libvirt_debug.syms @@ -10,6 +10,7 @@ debugFlag; # logging.h virLogMessage; virLogSetDefaultPriority; +virLogGetDefaultPriority; virLogDefineFilter; virLogDefineOutput; virLogParseFilters; diff --git a/src/logging.c b/src/logging.c index 9c8b0b9..c96c8d5 100644 --- a/src/logging.c +++ b/src/logging.c @@ -326,6 +326,15 @@ int virLogSetDefaultPriority(int priority) { } /** + * virLogGetDefaultPriority: + * + * Get the default priority level. + */ +int virLogGetDefaultPriority() { + return virLogDefaultPriority; +} + +/** * virLogResetFilters: * * Removes the set of logging filters defined. diff --git a/src/logging.h b/src/logging.h index 7ea8935..614aefb 100644 --- a/src/logging.h +++ b/src/logging.h @@ -111,6 +111,7 @@ typedef void (*virLogCloseFunc) (void *data); #ifdef ENABLE_DEBUG extern int virLogSetDefaultPriority(int priority); +extern int virLogGetDefaultPriority(void); extern int virLogDefineFilter(const char *match, int priority, int flags); extern int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c, void *data, int priority, int flags); @@ -131,6 +132,7 @@ extern void virLogMessage(const char *category, int priority, #else /* ENABLE_DEBUG */ #define virLogSetDefaultPriority(p) +#define virLogGetDefaultPriority() #define virLogDefineFilter(m, p, f) #define virLogDefineOutput(func, c, d, p, f) #define virLogStartup() diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 79ee072..d8cd4ee 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1711,25 +1711,28 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm, } } - /* Log, but ignore failures to write logfile for VM */ - if (safewrite(vm->logfile, buf, strlen(buf)) < 0) { - char ebuf[1024]; - VIR_WARN(_("Unable to log VM console data: %s\n"), - virStrerror(errno, ebuf, sizeof ebuf)); + if (virLogGetDefaultPriority() <= VIR_LOG_DEBUG) { + /* Log, but ignore failures to write logfile for VM */ + if (safewrite(vm->logfile, buf, strlen(buf)) < 0) { + char ebuf[1024]; + VIR_WARN(_("Unable to log VM console data: %s\n"), + virStrerror(errno, ebuf, sizeof ebuf)); + } } - *reply = buf; return 0; error: if (buf) { - /* Log, but ignore failures to write logfile for VM */ - if (safewrite(vm->logfile, buf, strlen(buf)) < 0) { - char ebuf[1024]; - VIR_WARN(_("Unable to log VM console data: %s\n"), - virStrerror(errno, ebuf, sizeof ebuf)); + if (virLogGetDefaultPriority() <= VIR_LOG_WARN) { + /* Log, but ignore failures to write logfile for VM */ + if (safewrite(vm->logfile, buf, strlen(buf)) < 0) { + char ebuf[1024]; + VIR_WARN(_("Unable to log VM console data: %s\n"), + virStrerror(errno, ebuf, sizeof ebuf)); + } + VIR_FREE(buf); } - VIR_FREE(buf); } return -1; } -- 1.6.2.1
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list