Signed-off-by: Oleg Vasilev <oleg.vasilev(a)virtuozzo.com>
---
src/logging/log_daemon.c | 6 ++----
src/logging/log_handler.c | 29 ++++++++++++-----------------
src/logging/log_handler.h | 17 ++++++++---------
3 files changed, 22 insertions(+), 30 deletions(-)
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 9b70ffad2f..8025245350 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -145,8 +145,7 @@ virLogDaemonNew(virLogDaemonConfig *config, bool privileged)
g_clear_pointer(&srv, virObjectUnref);
if (!(logd->handler = virLogHandlerNew(privileged,
- config->max_size,
- config->max_backups,
+ config,
virLogDaemonInhibitor,
logd)))
goto error;
@@ -231,8 +230,7 @@ virLogDaemonNewPostExecRestart(virJSONValue *object, bool privileged,
if (!(logd->handler = virLogHandlerNewPostExecRestart(child,
privileged,
- config->max_size,
- config->max_backups,
+ config,
virLogDaemonInhibitor,
logd)))
goto error;
diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c
index bf1e3f35c5..7342404b00 100644
--- a/src/logging/log_handler.c
+++ b/src/logging/log_handler.c
@@ -58,8 +58,7 @@ struct _virLogHandler {
virObjectLockable parent;
bool privileged;
- size_t max_size;
- size_t max_backups;
+ virLogDaemonConfig *config;
virLogHandlerLogFile **files;
size_t nfiles;
@@ -185,8 +184,7 @@ virLogHandlerDomainLogFileEvent(int watch,
virLogHandler *
virLogHandlerNew(bool privileged,
- size_t max_size,
- size_t max_backups,
+ virLogDaemonConfig *config,
virLogHandlerShutdownInhibitor inhibitor,
void *opaque)
{
@@ -199,8 +197,7 @@ virLogHandlerNew(bool privileged,
return NULL;
handler->privileged = privileged;
- handler->max_size = max_size;
- handler->max_backups = max_backups;
+ handler->config = config;
handler->inhibitor = inhibitor;
handler->opaque = opaque;
@@ -253,8 +250,8 @@ virLogHandlerLogFilePostExecRestart(virLogHandler *handler,
}
if ((file->file = virRotatingFileWriterNew(path,
- handler->max_size,
- handler->max_backups,
+ handler->config->max_size,
+ handler->config->max_backups,
false,
DEFAULT_MODE)) == NULL)
goto error;
@@ -282,8 +279,7 @@ virLogHandlerLogFilePostExecRestart(virLogHandler *handler,
virLogHandler *
virLogHandlerNewPostExecRestart(virJSONValue *object,
bool privileged,
- size_t max_size,
- size_t max_backups,
+ virLogDaemonConfig *config,
virLogHandlerShutdownInhibitor inhibitor,
void *opaque)
{
@@ -292,8 +288,7 @@ virLogHandlerNewPostExecRestart(virJSONValue *object,
size_t i;
if (!(handler = virLogHandlerNew(privileged,
- max_size,
- max_backups,
+ config,
inhibitor,
opaque)))
return NULL;
@@ -393,8 +388,8 @@ virLogHandlerDomainOpenLogFile(virLogHandler *handler,
file->domname = g_strdup(domname);
if ((file->file = virRotatingFileWriterNew(path,
- handler->max_size,
- handler->max_backups,
+ handler->config->max_size,
+ handler->config->max_backups,
trunc,
DEFAULT_MODE)) == NULL)
goto error;
@@ -525,7 +520,7 @@ virLogHandlerDomainReadLogFile(virLogHandler *handler,
virObjectLock(handler);
- if (!(file = virRotatingFileReaderNew(path, handler->max_backups)))
+ if (!(file = virRotatingFileReaderNew(path, handler->config->max_backups)))
goto error;
if (virRotatingFileReaderSeek(file, inode, offset) < 0)
@@ -579,8 +574,8 @@ virLogHandlerDomainAppendLogFile(virLogHandler *handler,
if (!writer) {
if (!(newwriter = virRotatingFileWriterNew(path,
- handler->max_size,
- handler->max_backups,
+ handler->config->max_size,
+ handler->config->max_backups,
false,
DEFAULT_MODE)))
goto cleanup;
diff --git a/src/logging/log_handler.h b/src/logging/log_handler.h
index 099378b361..c9af033cd3 100644
--- a/src/logging/log_handler.h
+++ b/src/logging/log_handler.h
@@ -22,6 +22,7 @@
#include "internal.h"
#include "virjson.h"
+#include "log_daemon_config.h"
typedef struct _virLogHandler virLogHandler;
@@ -30,16 +31,14 @@ typedef void (*virLogHandlerShutdownInhibitor)(bool inhibit,
void *opaque);
virLogHandler *virLogHandlerNew(bool privileged,
- size_t max_size,
- size_t max_backups,
- virLogHandlerShutdownInhibitor inhibitor,
- void *opaque);
+ virLogDaemonConfig *config,
+ virLogHandlerShutdownInhibitor inhibitor,
+ void *opaque);
virLogHandler *virLogHandlerNewPostExecRestart(virJSONValue *child,
- bool privileged,
- size_t max_size,
- size_t max_backups,
- virLogHandlerShutdownInhibitor
inhibitor,
- void *opaque);
+ bool privileged,
+ virLogDaemonConfig *config,
+ virLogHandlerShutdownInhibitor inhibitor,
+ void *opaque);
void virLogHandlerFree(virLogHandler *handler);
--
2.39.1